diff --git a/src/fprime/fbuild/builder.py b/src/fprime/fbuild/builder.py index 0a8d32d9..7238376a 100644 --- a/src/fprime/fbuild/builder.py +++ b/src/fprime/fbuild/builder.py @@ -305,31 +305,17 @@ def get_cmake_args(self) -> dict: ("FPRIME_CONFIG_DIR", "config_directory"), ("FPRIME_INSTALL_DEST", "install_destination"), ] + cmake_args = { cache: self.get_settings(setting, None) for cache, setting in needed if self.get_settings(setting, None) is not None } - # Load in the default settings - self.get_settings("default_cmake_options", None) - if "FPRIME_LIBRARY_LOCATIONS" in cmake_args: cmake_args["FPRIME_LIBRARY_LOCATIONS"] = ";".join( [str(location) for location in cmake_args["FPRIME_LIBRARY_LOCATIONS"]] ) - # When the new v3 autocoder directory exists, this means we can use the new UT api and preserve the build type - v3_autocoder_directory = Path( - cmake_args.get("FPRIME_FRAMEWORK_PATH") / "cmake" / "autocoder" - ) - if ( - v3_autocoder_directory.exists() - and self.build_type == BuildType.BUILD_TESTING - ): - cmake_args["BUILD_TESTING"] = "ON" - cmake_args["CMAKE_BUILD_TYPE"] = cmake_args.get("CMAKE_BUILD_TYPE", "Debug") - elif self.build_type == BuildType.BUILD_TESTING: - cmake_args["CMAKE_BUILD_TYPE"] = "Testing" return cmake_args def get_module_name(self, path: Path): @@ -382,14 +368,15 @@ def execute_build_target( environment=self.settings.get("environment", None), ) - def generate(self, cmake_args): + def generate(self, user_cmake_args): """Generates a build given CMake arguments This will run a generate step of the cmake build process. This will take in any argument used/passed to CMake. Args: - cmake_args: cmake arguments to pass into the generate step + user_cmake_args: cmake arguments to pass into the generate step """ + cmake_args = {} try: def split_pair(item): @@ -399,16 +386,35 @@ def split_pair(item): default_options_text = self.get_settings("default_cmake_options", None) default_options = default_options_text.split("\n") - default_cmake_args = { + default_cmake_options = { option: value for (option, value) in [split_pair(item) for item in default_options] if option != "" } + cmake_args.update(default_cmake_options) # default_cmake_options + cmake_args.update(user_cmake_args) # User-supplied values from command line + cmake_args.update(self.get_cmake_args()) # FPRIME_* values (settings.ini) + + # When the new v3 autocoder directory exists, this means we can use the new UT api and preserve the build type + v3_autocoder_directory = Path( + cmake_args.get("FPRIME_FRAMEWORK_PATH") / "cmake" / "autocoder" + ) + if ( + v3_autocoder_directory.exists() + and self.build_type == BuildType.BUILD_TESTING + ): + cmake_args["BUILD_TESTING"] = "ON" + cmake_args["CMAKE_BUILD_TYPE"] = user_cmake_args.get( + "CMAKE_BUILD_TYPE", "Debug" + ) + elif self.build_type == BuildType.BUILD_TESTING: + cmake_args["CMAKE_BUILD_TYPE"] = "Testing" + self.cmake.generate_build( self.cmake_root, self.build_dir, - {**default_cmake_args, **cmake_args, **self.get_cmake_args()}, + cmake_args, environment=self.settings.get("environment", None), ) except CMakeException as cexc: