Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: m-labs/misoc
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 54e1ef82515b
Choose a base ref
...
head repository: m-labs/misoc
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: a70983bf6b03
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Jan 17, 2017

  1. Remove misleading comment.

    whitequark committed Jan 17, 2017
    Copy the full SHA
    e6427e0 View commit details
  2. Do not overwrite generated files with the same contents.

    This avoids incessant rebuilds in development when running a builder
    repeatedly without any changes to CSRs etc.
    whitequark committed Jan 17, 2017
    Copy the full SHA
    a70983b View commit details
Showing with 27 additions and 12 deletions.
  1. +27 −9 misoc/integration/builder.py
  2. +0 −3 misoc/software/common.mak
36 changes: 27 additions & 9 deletions misoc/integration/builder.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import io
import subprocess
import struct

@@ -33,6 +34,22 @@ def _makefile_escape(s):
return s.replace("\\", "\\\\")


class WriteGenerated(io.StringIO):
def __init__(self, generated_dir, name):
super().__init__()
self.name = os.path.join(generated_dir, name)

def __enter__(self):
return self

def __exit__(self, *args):
with open(self.name, "r") as f:
content = f.read()
if content != self.getvalue():
with open(self.name, "w") as f:
f.write(self.getvalue())


class Builder:
def __init__(self, soc, output_dir=None,
compile_software=True, compile_gateware=True,
@@ -78,7 +95,8 @@ def _generate_includes(self):
buildinc_dir = os.path.join(self.output_dir, "software", "include")
generated_dir = os.path.join(buildinc_dir, "generated")
os.makedirs(generated_dir, exist_ok=True)
with open(os.path.join(generated_dir, "variables.mak"), "w") as f:

with WriteGenerated(generated_dir, "variables.mak") as f:
def define(k, v):
f.write("{}={}\n".format(k, _makefile_escape(v)))
for k, v in cpu_interface.get_cpu_mak(cpu_type):
@@ -89,25 +107,25 @@ def define(k, v):
for name, src_dir in self.software_packages:
define(name.upper() + "_DIRECTORY", src_dir)

with open(os.path.join(generated_dir, "output_format.ld"), "w") as f:
with WriteGenerated(generated_dir, "output_format.ld") as f:
f.write(cpu_interface.get_linker_output_format(cpu_type))
with open(os.path.join(generated_dir, "regions.ld"), "w") as f:
with WriteGenerated(generated_dir, "regions.ld") as f:
f.write(cpu_interface.get_linker_regions(memory_regions))

with open(os.path.join(generated_dir, "mem.h"), "w") as f:
with WriteGenerated(generated_dir, "mem.h") as f:
f.write(cpu_interface.get_mem_header(memory_regions, flash_boot_address))
with open(os.path.join(generated_dir, "csr.h"), "w") as f:
with WriteGenerated(generated_dir, "csr.h") as f:
f.write(cpu_interface.get_csr_header(csr_regions, constants))

with open(os.path.join(generated_dir, "mem.rs"), "w") as f:
with WriteGenerated(generated_dir, "mem.rs") as f:
f.write(cpu_interface.get_mem_rust(memory_regions, flash_boot_address))
with open(os.path.join(generated_dir, "csr.rs"), "w") as f:
with WriteGenerated(generated_dir, "csr.rs") as f:
f.write(cpu_interface.get_csr_rust(csr_regions, constants))
with open(os.path.join(generated_dir, "rust-cfg"), "w") as f:
with WriteGenerated(generated_dir, "rust-cfg") as f:
f.write(cpu_interface.get_rust_cfg(csr_regions, constants))

if sdram_phy_settings is not None:
with open(os.path.join(generated_dir, "sdram_phy.h"), "w") as f:
with WriteGenerated(generated_dir, "sdram_phy.h") as f:
f.write(sdram_init.get_sdram_phy_header(sdram_phy_settings))

if self.csr_csv is not None:
3 changes: 0 additions & 3 deletions misoc/software/common.mak
Original file line number Diff line number Diff line change
@@ -42,9 +42,6 @@ CFLAGS = $(COMMONFLAGS) -fexceptions -Wstrict-prototypes -Wold-style-definition
CXXFLAGS = $(COMMONFLAGS) -std=c++11 -I$(MISOC_DIRECTORY)/software/include/basec++ -fexceptions -fno-rtti -ffreestanding
LDFLAGS = -nostdlib -nodefaultlibs -L$(BUILDINC_DIRECTORY)

# compile and generate dependencies, based on
# http://scottmcpeak.com/autodepend/autodepend.html

define compilexx
$(CX) -c $(CXXFLAGS) $(1) $< -o $@
endef