Skip to content

Commit

Permalink
lestarch: fixing incorrectly named setting (#94)
Browse files Browse the repository at this point in the history
* lestarch: fixing incorrectly named setting

* lestarch: fixing errored settings

* lestarch: formatting
  • Loading branch information
LeStarch committed Jul 21, 2022
1 parent abb903d commit 2ba8103
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 20 deletions.
16 changes: 10 additions & 6 deletions src/fprime/fbuild/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,8 @@ def get_cmake_args(self) -> dict:
("FPRIME_SETTINGS_FILE", "settings_file"),
("FPRIME_ENVIRONMENT_FILE", "environment_file"),
("FPRIME_AC_CONSTANTS_FILE", "ac_constants"),
("FPRIME_CONFIG_DIR", "config_dir"),
("FPRIME_INSTALL_DEST", "install_dest"),
("FPRIME_CONFIG_DIR", "config_directory"),
("FPRIME_INSTALL_DEST", "install_destination"),
]
cmake_args = {
cache: self.get_settings(setting, None)
Expand Down Expand Up @@ -402,13 +402,17 @@ def purge(self):

def purge_install(self):
"""Purge the install directory"""
assert "install_dest" in self.settings, "install_dest not present in settings"
self.cmake.purge(self.settings["install_dest"])
assert (
"install_destination" in self.settings
), "install_destination not present in settings"
self.cmake.purge(self.settings["install_destination"])

def install_dest_exists(self) -> Path:
"""Check if the install destination exists and returns the path if it does"""
assert "install_dest" in self.settings, "install_dest not present in settings"
path = Path(self.settings["install_dest"])
assert (
"install_destination" in self.settings
), "install_destination not present in settings"
path = Path(self.settings["install_destination"])
return path if path.exists() else None

@staticmethod
Expand Down
16 changes: 11 additions & 5 deletions src/fprime/fbuild/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,18 @@ class IniSettings:
]

PLATFORM_FIELDS = [
("config_dir", SettingType.PATH, partial(join, "framework_path", "config")),
(
"config_directory",
SettingType.PATH,
partial(join, "framework_path", "config"),
),
(
"ac_constants",
SettingType.PATH,
partial(join, "config_dir", "AcConstants.ini"),
partial(join, "config_directory", "AcConstants.ini"),
),
(
"install_dest",
"install_destination",
SettingType.PATH,
partial(join, "_deployment", "build-artifacts"),
),
Expand All @@ -89,8 +93,10 @@ def read_safe_path(
separated by ':'. This will also expand relative paths relative to the settings file.
:param parser: parser to read from
:param section: section to read from
:param key: key to read from
:param ini_file: ini_file path for clean errors
:param exists: expect the path to exist. Default: True, must exist.
:return: path, validated
"""
base_dir = os.path.dirname(ini_file)
Expand Down Expand Up @@ -129,7 +135,7 @@ def read_setting(
section,
key,
settings["settings_file"],
key != "install_dest",
key != "install_destination",
)
value = paths_list[0] if paths_list else get_default_value()
elif settings_type == SettingType.PATH_LIST:
Expand All @@ -138,7 +144,7 @@ def read_setting(
section,
key,
settings["settings_file"],
key != "install_dest",
key != "install_destination",
)
value = paths_list or get_default_value()
else:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[fprime]
install_dest: ../test
install_destination: ../test
framework_path: ../..
16 changes: 8 additions & 8 deletions test/fprime/fbuild/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ def test_settings():
"default_toolchain": "native",
"default_ut_toolchain": "native",
"framework_path": full_path(".."),
"install_dest": full_path("settings-data/build-artifacts"),
"install_destination": full_path("settings-data/build-artifacts"),
"library_locations": [],
"environment_file": full_path("settings-data/settings-empty.ini"),
"environment": {},
"component_cookiecutter": "default",
"ac_constants": full_path("..") / "config" / "AcConstants.ini",
"project_root": full_path(".."),
"config_dir": full_path("..") / "config",
"config_directory": full_path("..") / "config",
},
},
{
Expand All @@ -48,7 +48,7 @@ def test_settings():
"default_toolchain": "native",
"default_ut_toolchain": "native",
"framework_path": full_path(".."),
"install_dest": full_path("test"),
"install_destination": full_path("test"),
"library_locations": [],
"environment_file": full_path(
"settings-data/settings-custom-install.ini"
Expand All @@ -57,7 +57,7 @@ def test_settings():
"component_cookiecutter": "default",
"ac_constants": full_path("..") / "config" / "AcConstants.ini",
"project_root": full_path(".."),
"config_dir": full_path("..") / "config",
"config_directory": full_path("..") / "config",
},
},
{
Expand All @@ -69,7 +69,7 @@ def test_settings():
"default_toolchain": "custom1",
"default_ut_toolchain": "custom2",
"framework_path": full_path(".."),
"install_dest": full_path("settings-data/build-artifacts"),
"install_destination": full_path("settings-data/build-artifacts"),
"library_locations": [],
"environment_file": full_path(
"settings-data/settings-custom-toolchain.ini"
Expand All @@ -78,7 +78,7 @@ def test_settings():
"component_cookiecutter": "default",
"ac_constants": full_path("..") / "config" / "AcConstants.ini",
"project_root": full_path(".."),
"config_dir": full_path("..") / "config",
"config_directory": full_path("..") / "config",
},
},
{
Expand All @@ -90,7 +90,7 @@ def test_settings():
"default_toolchain": "native",
"default_ut_toolchain": "native",
"framework_path": full_path(".."),
"install_dest": full_path("settings-data/build-artifacts"),
"install_destination": full_path("settings-data/build-artifacts"),
"library_locations": [],
"environment_file": full_path(
"settings-data/settings-outside-cookiecutter.ini"
Expand All @@ -99,7 +99,7 @@ def test_settings():
"component_cookiecutter": "gh:SterlingPeet/cookiecutter-fprime-deployment",
"ac_constants": full_path("..") / "config" / "AcConstants.ini",
"project_root": full_path(".."),
"config_dir": full_path("..") / "config",
"config_directory": full_path("..") / "config",
},
},
]
Expand Down

0 comments on commit 2ba8103

Please sign in to comment.