Skip to content

Commit

Permalink
Logic rework
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-bc committed Oct 9, 2023
1 parent f01fe01 commit 73fb959
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/fprime/fbuild/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ def find_toolchain(self):
raise AmbiguousToolchainException(msg)
return toolchains[0]

def get_cmake_args(self) -> dict:
def get_cmake_args(self, user_cmake_args) -> dict:
"""Generates CMake arguments from project settings (settings.ini file)
Returns:
Expand All @@ -305,15 +305,17 @@ def get_cmake_args(self) -> dict:
("FPRIME_CONFIG_DIR", "config_directory"),
("FPRIME_INSTALL_DEST", "install_destination"),
]
for needed_setting in needed:
if user_cmake_args.get(needed_setting[0], None) is not None:
msg = f"Cannot override {needed_setting[0]} with command line argument. Use settings.ini file."
raise GenerateException(msg)

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"]]
Expand All @@ -327,7 +329,7 @@ def get_cmake_args(self) -> dict:
and self.build_type == BuildType.BUILD_TESTING
):
cmake_args["BUILD_TESTING"] = "ON"
cmake_args["CMAKE_BUILD_TYPE"] = cmake_args.get("CMAKE_BUILD_TYPE", "Debug")
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"
return cmake_args
Expand Down Expand Up @@ -408,7 +410,7 @@ def split_pair(item):
self.cmake.generate_build(
self.cmake_root,
self.build_dir,
{**default_cmake_args, **self.get_cmake_args(), **cmake_args},
{**default_cmake_args, **cmake_args, **self.get_cmake_args(cmake_args)},
environment=self.settings.get("environment", None),
)
except CMakeException as cexc:
Expand Down

0 comments on commit 73fb959

Please sign in to comment.