From 8472a505a302901ea86c4b05a5f61b5dfd46375c Mon Sep 17 00:00:00 2001 From: James O'Shannessy <12959316+joshanne@users.noreply.github.com> Date: Tue, 3 Sep 2024 17:04:50 +1000 Subject: [PATCH] hwdef: Parse parameters and detect defined defaults correctly --- .../AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py b/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py index 674ea794b89071..80320ee38d2c38 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py +++ b/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py @@ -2889,12 +2889,14 @@ def get_processed_defaults_file(self, defaults_filepath, depth=0): def write_processed_defaults_file(self, filepath): # see if board has a defaults.parm file or a --default-parameters file was specified defaults_filename = os.path.join(os.path.dirname(self.hwdef[0]), 'defaults.parm') - defaults_path = os.path.join(os.path.dirname(self.hwdef[0]), args.params) - defaults_abspath = None - if os.path.exists(defaults_path): - defaults_abspath = os.path.abspath(self.default_params_filepath) - self.progress("Default parameters path from command line: %s" % self.default_params_filepath) + if isinstance(self.default_params_filepath, str): + defaults_path = os.path.join(os.path.dirname(self.hwdef[0]), self.default_params_filepath) + if not os.path.exists(defaults_path): + self.error(f"Specified defaults file not found at path {defaults_path}") + + defaults_abspath = os.path.abspath(defaults_path) + self.progress("Default parameters path from command line: %s" % defaults_path) elif os.path.exists(defaults_filename): defaults_abspath = os.path.abspath(defaults_filename) self.progress("Default parameters path from hwdef: %s" % defaults_filename)