mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-03 06:28:27 -04:00
AP_HAL_ChibiOS: Fix waf --default-parameters
If a defaults.parm file was present in the hwdef, waf ignored the --default-parameters=xyz.parm command line argument. This will allow it to use that command line argument specified file.
This commit is contained in:
parent
73e51c480a
commit
e6f32f4572
@ -350,7 +350,7 @@ def configure(cfg):
|
|||||||
|
|
||||||
if cfg.options.default_parameters:
|
if cfg.options.default_parameters:
|
||||||
cfg.msg('Default parameters', cfg.options.default_parameters, color='YELLOW')
|
cfg.msg('Default parameters', cfg.options.default_parameters, color='YELLOW')
|
||||||
env.DEFAULT_PARAMETERS = srcpath(cfg.options.default_parameters)
|
env.DEFAULT_PARAMETERS = cfg.options.default_parameters
|
||||||
|
|
||||||
# we need to run chibios_hwdef.py at configure stage to generate the ldscript.ld
|
# we need to run chibios_hwdef.py at configure stage to generate the ldscript.ld
|
||||||
# that is needed by the remaining configure checks
|
# that is needed by the remaining configure checks
|
||||||
@ -368,7 +368,7 @@ def configure(cfg):
|
|||||||
os.mkdir(hwdef_out)
|
os.mkdir(hwdef_out)
|
||||||
python = sys.executable
|
python = sys.executable
|
||||||
try:
|
try:
|
||||||
cmd = "{0} '{1}' -D '{2}' '{3}' {4}".format(python, hwdef_script, hwdef_out, env.HWDEF, env.BOOTLOADER_OPTION)
|
cmd = "{0} '{1}' -D '{2}' '{3}' {4} --params '{5}'".format(python, hwdef_script, hwdef_out, env.HWDEF, env.BOOTLOADER_OPTION, cfg.options.default_parameters)
|
||||||
ret = subprocess.call(cmd, shell=True)
|
ret = subprocess.call(cmd, shell=True)
|
||||||
except Exception:
|
except Exception:
|
||||||
cfg.fatal("Failed to process hwdef.dat")
|
cfg.fatal("Failed to process hwdef.dat")
|
||||||
@ -391,8 +391,8 @@ def build(bld):
|
|||||||
bld(
|
bld(
|
||||||
# build hwdef.h from hwdef.dat. This is needed after a waf clean
|
# build hwdef.h from hwdef.dat. This is needed after a waf clean
|
||||||
source=bld.path.ant_glob(bld.env.HWDEF),
|
source=bld.path.ant_glob(bld.env.HWDEF),
|
||||||
rule="%s '${AP_HAL_ROOT}/hwdef/scripts/chibios_hwdef.py' -D '${BUILDROOT}' '%s' %s" % (
|
rule="%s '${AP_HAL_ROOT}/hwdef/scripts/chibios_hwdef.py' -D '${BUILDROOT}' '%s' %s --params '%s'" % (
|
||||||
bld.env.get_flat('PYTHON'), bld.env.HWDEF, bld.env.BOOTLOADER_OPTION),
|
bld.env.get_flat('PYTHON'), bld.env.HWDEF, bld.env.BOOTLOADER_OPTION, bld.env.default_parameters),
|
||||||
group='dynamic_sources',
|
group='dynamic_sources',
|
||||||
target=[bld.bldnode.find_or_declare('hwdef.h'),
|
target=[bld.bldnode.find_or_declare('hwdef.h'),
|
||||||
bld.bldnode.find_or_declare('ldscript.ld')]
|
bld.bldnode.find_or_declare('ldscript.ld')]
|
||||||
|
@ -20,6 +20,8 @@ parser.add_argument(
|
|||||||
'--bootloader', action='store_true', default=False, help='configure for bootloader')
|
'--bootloader', action='store_true', default=False, help='configure for bootloader')
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'hwdef', type=str, default=None, help='hardware definition file')
|
'hwdef', type=str, default=None, help='hardware definition file')
|
||||||
|
parser.add_argument(
|
||||||
|
'--params', type=str, default=None, help='user default params path')
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
@ -1774,11 +1776,19 @@ def build_peripheral_list():
|
|||||||
def write_env_py(filename):
|
def write_env_py(filename):
|
||||||
'''write out env.py for environment variables to control the build process'''
|
'''write out env.py for environment variables to control the build process'''
|
||||||
|
|
||||||
# see if board has a defaults.parm file
|
# see if board has a defaults.parm file or a --default-parameters file was specified
|
||||||
defaults_filename = os.path.join(os.path.dirname(args.hwdef), 'defaults.parm')
|
defaults_filename = os.path.join(os.path.dirname(args.hwdef), 'defaults.parm')
|
||||||
if os.path.exists(defaults_filename) and not args.bootloader:
|
defaults_path = os.path.join(os.path.dirname(args.hwdef), args.params)
|
||||||
print("Adding defaults.parm")
|
|
||||||
env_vars['DEFAULT_PARAMETERS'] = os.path.abspath(defaults_filename)
|
if not args.bootloader:
|
||||||
|
if os.path.exists(defaults_path):
|
||||||
|
env_vars['DEFAULT_PARAMETERS'] = os.path.abspath(defaults_path)
|
||||||
|
print("Default parameters path from command line: %s" % defaults_path)
|
||||||
|
elif os.path.exists(defaults_filename):
|
||||||
|
env_vars['DEFAULT_PARAMETERS'] = os.path.abspath(defaults_filename)
|
||||||
|
print("Default parameters path from hwdef: %s" % defaults_filename)
|
||||||
|
else:
|
||||||
|
print("No default parameter file found")
|
||||||
|
|
||||||
# CHIBIOS_BUILD_FLAGS is passed to the ChibiOS makefile
|
# CHIBIOS_BUILD_FLAGS is passed to the ChibiOS makefile
|
||||||
env_vars['CHIBIOS_BUILD_FLAGS'] = ' '.join(build_flags)
|
env_vars['CHIBIOS_BUILD_FLAGS'] = ' '.join(build_flags)
|
||||||
|
Loading…
Reference in New Issue
Block a user