-
Notifications
You must be signed in to change notification settings - Fork 49
Allow a 'paths-relative-to' key in the firmware config #70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
… final fw_configs fw_configs will always be a dictionnary, but individual ones might not.
configs paths-relative-to can be CWD, THIS_FILE, or a literal path. It defaults to CWD. The firmware configs will be patched accordingly: binary paths will be prefixed by either the current working directory (this is the old behaviour), the directory containing the firmware config file, or the literal path.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! I've requested a few changes. There's also a linter error, so you might want to run "ruff check" on your sources.
def patch_firmware_image_paths(fw_config: dict, this_file_path: str) -> dict: | ||
paths_relative_to_conf = fw_config.pop("paths-relative-to", "CWD") | ||
if paths_relative_to_conf == "CWD": | ||
path_relative_to = os.getcwd() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned in your PR message, I'd prefer we didn't modify the path at all if "CWD" is specified. I'm pretty sure it wouldn't change anything but I'd rather not take an unnecessary risk.
@@ -76,6 +77,20 @@ def check_soc_model(soc_model: str): | |||
return None | |||
|
|||
|
|||
def patch_firmware_image_paths(fw_config: dict, this_file_path: str) -> dict: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function doesn't actually need to return anything. It just modifies the dict in-place.
@@ -76,6 +77,20 @@ def check_soc_model(soc_model: str): | |||
return None | |||
|
|||
|
|||
def patch_firmware_image_paths(fw_config: dict, this_file_path: str) -> dict: | |||
paths_relative_to_conf = fw_config.pop("paths-relative-to", "CWD") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a user interface change, so it needs to be documented. You can describe this configuration option in docs/fw_binaries.md, in the introduction section.
@@ -127,6 +142,7 @@ def init_config(args: list): | |||
cli_error( | |||
f"firmware config passed to CLI did not evaluate to dict: {fw_configs}" | |||
) | |||
fw_config_file = patch_firmware_image_paths(fw_config_file, path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I'd prefer "complete_fw_paths()"
also, as mentioned above, this function doesn't return anything.
Closes #68
paths-relative-to can be CWD, THIS_FILE, or a literal path. It defaults
to CWD.
The firmware configs will be patched accordingly: binary paths will be
prefixed by either the current working directory (this is the old
behaviour), the directory containing the firmware config file, or the
literal path.
Let me know if you prefer the CWD behaviour to do nothing (like the current behaviour) instead of prefixing with os.getcwd().