diff --git a/toolchain/mfc/build.py b/toolchain/mfc/build.py index ee827dec1..d8f12157f 100644 --- a/toolchain/mfc/build.py +++ b/toolchain/mfc/build.py @@ -31,20 +31,20 @@ def compute(self) -> typing.Set: def __hash__(self) -> int: return hash(self.name) - # Get path to directory that will store the build files - def get_build_dirpath(self) -> str: + def get_slug(self) -> str: if self.isDependency: - slug = self.name - else: - slug = f"{CFG().make_slug()}-{self.name}" + return self.name - if ARG("case_optimization"): - m = hashlib.sha256() - m.update(input.load().get_fpp(self).encode()) + m = hashlib.sha256() + m.update(self.name.encode()) + m.update(CFG().make_slug().encode()) + m.update(input.load({}).get_fpp(self).encode()) - slug = f"{slug}-{m.hexdigest()[:6]}" + return m.hexdigest()[:10] - return os.sep.join([os.getcwd(), "build", slug ]) + # Get path to directory that will store the build files + def get_staging_dirpath(self) -> str: + return os.sep.join([os.getcwd(), "build", "staging", self.get_slug() ]) # Get the directory that contains the target's CMakeLists.txt def get_cmake_dirpath(self) -> str: @@ -58,13 +58,13 @@ def get_cmake_dirpath(self) -> str: def get_install_dirpath(self) -> str: # The install directory is located: - # Regular: /build/install/ + # Regular: /build/install/ # Dependency: /build/install/dependencies (shared) return os.sep.join([ os.getcwd(), "build", "install", - 'dependencies' if self.isDependency else CFG().make_slug() + 'dependencies' if self.isDependency else self.get_slug(), ]) def get_install_binpath(self) -> str: @@ -75,14 +75,14 @@ def is_configured(self) -> bool: # We assume that if the CMakeCache.txt file exists, then the target is # configured. (this isn't perfect, but it's good enough for now) return os.path.isfile( - os.sep.join([self.get_build_dirpath(), "CMakeCache.txt"]) + os.sep.join([self.get_staging_dirpath(), "CMakeCache.txt"]) ) def get_configuration_txt(self) -> typing.Optional[dict]: if not self.is_configured(): return None - configpath = os.path.join(self.get_build_dirpath(), "configuration.txt") + configpath = os.path.join(self.get_staging_dirpath(), "configuration.txt") if not os.path.exists(configpath): return None @@ -101,7 +101,7 @@ def is_buildable(self) -> bool: return True def configure(self): - build_dirpath = self.get_build_dirpath() + build_dirpath = self.get_staging_dirpath() cmake_dirpath = self.get_cmake_dirpath() install_dirpath = self.get_install_dirpath() @@ -154,7 +154,7 @@ def configure(self): def build(self): input.load({}).generate_fpp(self) - command = ["cmake", "--build", self.get_build_dirpath(), + command = ["cmake", "--build", self.get_staging_dirpath(), "--target", self.name, "--parallel", ARG("jobs"), "--config", 'Debug' if ARG('debug') else 'Release'] @@ -167,7 +167,7 @@ def build(self): cons.print(no_indent=True) def install(self): - command = ["cmake", "--install", self.get_build_dirpath()] + command = ["cmake", "--install", self.get_staging_dirpath()] if system(command).returncode != 0: raise MFCException(f"Failed to install the [bold magenta]{self.name}[/bold magenta] target.") @@ -175,7 +175,7 @@ def install(self): cons.print(no_indent=True) def clean(self): - build_dirpath = self.get_build_dirpath() + build_dirpath = self.get_staging_dirpath() if not os.path.isdir(build_dirpath): return diff --git a/toolchain/mfc/run/input.py b/toolchain/mfc/run/input.py index a0f95bc00..6118ca56a 100644 --- a/toolchain/mfc/run/input.py +++ b/toolchain/mfc/run/input.py @@ -74,7 +74,7 @@ def __contents_equal(str_a: str, str_b: str) -> bool: return lhs == rhs - inc_dir = os.path.join(target.get_build_dirpath(), "include", target.name) + inc_dir = os.path.join(target.get_staging_dirpath(), "include", target.name) common.create_directory(inc_dir) fpp_path = os.path.join(inc_dir, "case.fpp")