diff --git a/mibuild/altera_quartus.py b/mibuild/altera_quartus.py index 4fc785509..dbb336a75 100644 --- a/mibuild/altera_quartus.py +++ b/mibuild/altera_quartus.py @@ -74,6 +74,7 @@ quartus_sta {build_name}.qpf class AlteraQuartusPlatform(GenericPlatform): def build(self, fragment, build_dir="build", build_name="top", quartus_path="/opt/Altera", run=True): + self.finalize(fragment) tools.mkdir_noerror(build_dir) os.chdir(build_dir) diff --git a/mibuild/generic_platform.py b/mibuild/generic_platform.py index 482c485e8..2feb70e4d 100644 --- a/mibuild/generic_platform.py +++ b/mibuild/generic_platform.py @@ -152,6 +152,7 @@ class GenericPlatform: name = self.__module__.split(".")[-1] self.name = name self.sources = [] + self.finalized = False def request(self, *args, **kwargs): return self.constraint_manager.request(*args, **kwargs) @@ -162,6 +163,17 @@ class GenericPlatform: def add_platform_command(self, *args, **kwargs): return self.constraint_manager.add_platform_command(*args, **kwargs) + def finalize(self, fragment, *args, **kwargs): + if self.finalized: + raise ConstraintError("Already finalized") + self.do_finalize(fragment, *args, **kwargs) + self.finalized = True + + def do_finalize(self, fragment, *args, **kwargs): + """overload this and e.g. add_platform_command()'s after the + modules had their say""" + pass + def add_source(self, filename, language=None): if language is None: language = tools.language_by_filename(filename) diff --git a/mibuild/xilinx_ise.py b/mibuild/xilinx_ise.py index bb70fdd3c..2bc8c107f 100644 --- a/mibuild/xilinx_ise.py +++ b/mibuild/xilinx_ise.py @@ -150,6 +150,7 @@ class XilinxISEPlatform(GenericPlatform): def build(self, fragment, build_dir="build", build_name="top", ise_path="/opt/Xilinx", source=True, run=True): + self.finalize(fragment) tools.mkdir_noerror(build_dir) os.chdir(build_dir)