diff --git a/meson_options.txt b/meson_options.txt index d5128defb43..2a92d14dfe7 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1,2 +1,2 @@ - option('probe', type: 'string', description: 'target probe', value: 'native') +option('targets', type : 'array', value : ['cortexm', 'nrf', 'sam', 'stm', 'lpc', 'nxp', 'efm', 'ti', 'rp'], description: 'enabled debug targets') diff --git a/src/platform/meson.build b/src/platform/meson.build index d0baa2e0f6c..903cff376da 100644 --- a/src/platform/meson.build +++ b/src/platform/meson.build @@ -13,4 +13,6 @@ platform_args = [] platform_link_args = [] platform_deps = [] +summary({'active': platform}, section: 'Platform') + subdir(platform) diff --git a/src/platform/stm32/meson.build b/src/platform/stm32/meson.build index e4a0a46db55..0cbd3a0a218 100644 --- a/src/platform/stm32/meson.build +++ b/src/platform/stm32/meson.build @@ -77,3 +77,5 @@ platform_includes += include_directories('../../../libopencm3/include') platform_link_args += ['-L@0@'.format(join_paths(meson.project_source_root(), 'libopencm3/lib'))] platform_deps += [libopencm3_dep] + +summary({'family': mcu_family}, section: 'Platform') diff --git a/src/probe/meson.build b/src/probe/meson.build index 24637b1fc87..69fad45daf9 100644 --- a/src/probe/meson.build +++ b/src/probe/meson.build @@ -10,8 +10,7 @@ probe_list = run_command( capture: true, check: false).stdout().split(',') if probe not in probe_list - message('Available target probes:', probe_list) - error(f'The target probe @probe@ is not a valid probe') + error('The target probe "@0@" is not a valid probe: "@1@"'.format(probe, ', '.join(probe_list))) endif probe_includes = [] @@ -21,6 +20,8 @@ probe_link_args = [] probe_dfu_link_args = [] probe_deps = [] +summary({'active': probe}, section: 'Probe') + subdir(probe) # probe_dfu_available = false diff --git a/src/probe/native/meson.build b/src/probe/native/meson.build index e431b523388..8c5afe1c36f 100644 --- a/src/probe/native/meson.build +++ b/src/probe/native/meson.build @@ -15,14 +15,13 @@ probe_args += [ '-DBLACKMAGIC', ] -probe_common_link_args = [ -] - probe_link_args += [ '-T@0@'.format('blackmagic.ld'), '-Wl,-Ttext=0x8002000', ] +summary({'demo': 'just a demo info for probes'}, section: 'Probe') + # probe_dfu_sources += files( # probe_common_sources, # 'usbdfu.c', diff --git a/src/target/meson.build b/src/target/meson.build index 826f73f6577..367a4345cb4 100644 --- a/src/target/meson.build +++ b/src/target/meson.build @@ -1,42 +1,85 @@ +targets = get_option('targets') + target_includes = include_directories( '.', ) target_sources = files( 'target.c', - # !TODO: selective include - 'nrf51.c', - 'adiv5_swdp.c', - 'samx5x.c', - 'lpc15xx.c', - 'lpc_common.c', - 'stm32f1.c', - 'ch32f1.c', - 'cortexm.c', - 'rp.c', - 'efm32.c', 'adiv5.c', - 'msp432.c', - 'nxpke04.c', - 'cortexa.c', - 'lmi.c', - 'stm32g0.c', - 'lpc43xx.c', - 'jtag_scan.c', - 'lpc546xx.c', - 'kinetis.c', - 'stm32l4.c', - 'sam3x.c', - 'samd.c', - 'sam4l.c', + 'adiv5_swdp.c', 'adiv5_jtagdp.c', - 'swdptap_generic.c', - 'jtagtap_generic.c', - 'stm32l0.c', - 'stm32f4.c', - 'lpc17xx.c', - 'lpc11xx.c', + 'jtag_scan.c', 'jtag_devs.c', - 'stm32h7.c', + 'target_probes.c', + # 'swdptap_generic.c', + # 'jtagtap_generic.c', ) + +# targets specific files dictionary +target_dicts = { + 'cortexa': + {'files': ['cortexa.c']}, + 'cortexm': + {'files': ['cortexm.c']}, + 'efm': + {'files': ['efm32.c'], + 'depends': ['cortexm']}, + 'lpc': + {'files': ['lpc_common.c', 'lpc15xx.c', 'lpc43xx.c', 'lpc546xx.c', 'lpc17xx.c', 'lpc11xx.c'], + 'depends': ['cortexm']}, + 'nrf': + {'files': ['nrf51.c'], + 'depends': ['cortexm']}, + 'nxp': + {'files': ['nxpke04.c', 'kinetis.c'], + 'depends': ['cortexm']}, + 'rp': + {'files': ['rp.c'], + 'depends': ['cortexm']}, + 'sam': + {'files': ['samx5x.c', 'sam3x.c', 'samd.c', 'sam4l.c'], + 'depends': ['cortexm']}, + 'stm': + {'files': ['stm32f1.c', 'ch32f1.c', 'stm32g0.c', 'stm32l4.c', 'stm32l0.c', 'stm32f4.c', 'stm32h7.c',], + 'depends': ['cortexm']}, + 'ti': + {'files': ['lmi.c', 'msp432.c'], + 'depends': ['cortexm']}, +} + +# loop through selected targets and add respective sources, check for dependencies if present +foreach target: targets + # check for valid target + if target not in target_dicts.keys() + error('The target "@0@" is not a valid target: "@1@"'.format(target, ', '.join(target_dicts.keys()))) + endif + + # get 'sub' dictionary + target_dict = target_dicts[target] + + # check for dependencies + if target_dict.has_key('depends') + foreach depend: target_dict['depends'] + if depend not in targets + # it's funky to add to a list we're iterating over, but it works + targets += depend + message('The target "@0@" depends on "@1@", but this target is not enabled, enabling'.format(target, depend)) + endif + endforeach + endif + + # add target sources + target_sources += files(target_dict['files']) +endforeach + +# check for disabled targets and add to list for user feedback +disabled_targets = [] +foreach target: target_dicts.keys() + if target not in targets + disabled_targets += target + endif +endforeach + +summary({'enabled': targets, 'disabled': disabled_targets}, section: 'Targets')