Skip to content

Commit

Permalink
meson: add target enabling/disabling funtionality
Browse files Browse the repository at this point in the history
Signed-off-by: Rafael Silva <[email protected]>
  • Loading branch information
perigoso committed Jun 8, 2022
1 parent b4393a1 commit 91d3cb3
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 37 deletions.
2 changes: 1 addition & 1 deletion meson_options.txt
Original file line number Diff line number Diff line change
@@ -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')
2 changes: 2 additions & 0 deletions src/platform/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ platform_args = []
platform_link_args = []
platform_deps = []

summary({'active': platform}, section: 'Platform')

subdir(platform)
2 changes: 2 additions & 0 deletions src/platform/stm32/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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')
5 changes: 3 additions & 2 deletions src/probe/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand All @@ -21,6 +20,8 @@ probe_link_args = []
probe_dfu_link_args = []
probe_deps = []

summary({'active': probe}, section: 'Probe')

subdir(probe)

# probe_dfu_available = false
Expand Down
5 changes: 2 additions & 3 deletions src/probe/native/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
105 changes: 74 additions & 31 deletions src/target/meson.build
Original file line number Diff line number Diff line change
@@ -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')

0 comments on commit 91d3cb3

Please sign in to comment.