From fba834a64e8e77da074c622467a43aff20120fe2 Mon Sep 17 00:00:00 2001 From: Rafael Silva Date: Sat, 11 Nov 2023 02:24:51 +0000 Subject: [PATCH] misc: add experimental meson buildsystem initially some additional flags where added to stm32 platform flags, but later removed, because `-ffreestanding` has a particular meaning to do with not using any libc, and this changed recently to exclude things like all libm usage by making it really mean what it says it should. Avoid this as we use newlib's libc and libm extensively Co-authored-by: dragonmux --- cross-file/arm-none-eabi.ini | 21 ++++ meson.build | 127 +++++++++++++++++++++++++ meson_options.txt | 6 ++ src/include/version.h.in | 1 + src/meson.build | 82 ++++++++++++++++ src/platforms/common/meson.build | 45 +++++++++ src/platforms/common/stm32/meson.build | 110 +++++++++++++++++++++ src/platforms/meson.build | 44 +++++++++ src/platforms/native/meson.build | 54 +++++++++++ src/target/meson.build | 102 ++++++++++++++++++++ 10 files changed, 592 insertions(+) create mode 100644 cross-file/arm-none-eabi.ini create mode 100644 meson.build create mode 100644 meson_options.txt create mode 100644 src/include/version.h.in create mode 100644 src/meson.build create mode 100644 src/platforms/common/meson.build create mode 100644 src/platforms/common/stm32/meson.build create mode 100644 src/platforms/meson.build create mode 100644 src/platforms/native/meson.build create mode 100644 src/target/meson.build diff --git a/cross-file/arm-none-eabi.ini b/cross-file/arm-none-eabi.ini new file mode 100644 index 00000000..7a9b2b51 --- /dev/null +++ b/cross-file/arm-none-eabi.ini @@ -0,0 +1,21 @@ +[constants] +# Allow easy overridding of the default path and prefix +gcc_path = '' +gcc_prefix = 'arm-none-eabi-' +gcc_base = gcc_path / gcc_prefix + +[binaries] +c = gcc_base + 'gcc' +ld = gcc_base + 'gcc' +ar = gcc_base + 'ar' +nm = gcc_base + 'nm' +strip = gcc_base + 'strip' +objcopy = gcc_base + 'objcopy' +objdump = gcc_base + 'objdump' +size = gcc_base + 'size' + +[host_machine] +system = 'bare-metal' +cpu_family = 'arm' +cpu = 'arm' +endian = 'little' diff --git a/meson.build b/meson.build new file mode 100644 index 00000000..dde63a67 --- /dev/null +++ b/meson.build @@ -0,0 +1,127 @@ +# This file is part of the Black Magic Debug project. +# +# Copyright (C) 2023 1BitSquared +# Written by Rafael Silva +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +project( + 'Black Magic Debug', + 'c', + version: '1.10.0', + license: 'GPL-3.0-or-later OR BSD-3-Clause OR MIT', + default_options: [ + 'c_std=c11', + 'optimization=s', + 'debug=true', + 'warning_level=2', + 'werror=true', + 'b_ndebug=if-release', + ], + meson_version: '>= 0.58.0', + subproject_dir: 'deps', +) + +# Version from version control system +# fallback to meson project version (f.i. when building from source tarball) +# TODO: when no vcs version is available, we should mark it somehow (-static?) as it may not be 'clean' +version = vcs_tag( + command: ['git', 'describe', '--always', '--dirty', '--tags'], + input: 'src/include/version.h.in', + output: 'version.h', + fallback: meson.project_version(), +) + +## Black Magic Debug (BMD) sources +## _______________________________ + +# Project wide flags +add_project_arguments('-Wreturn-type', '-Wno-char-subscripts', language: 'c') +if host_machine.system() in ['macos', 'darwin'] + add_project_arguments( + '-Wmaybe-uninitialized', + '-Wstringop-overflow', + '-Wunsafe-loop-optimizations', + language: 'c', + ) +endif + +subdir('src') + +## Black Magic Firmware (BMF) targets +## __________________________________ + +if get_option('print_memory_usage') + add_project_link_arguments('-Wl,--print-memory-usage', language: 'c') +endif + +# System binary utilities +size = find_program('size') +objcopy = find_program('objcopy') + +# Base name for output files +bmf_base_name = 'black_magic_firmware_@0@'.format(get_option('probe')).to_lower().underscorify() + +# Main firmware elf file +bmf_elf = executable( + f'@bmf_base_name@.elf', + dependencies: [bmd_core, probe_host], +) +alias_target('elf', bmf_elf) + +# Firmware binary and hex files +bmf_bin = custom_target( + 'bin', + output: f'@bmf_base_name@.bin', + input: bmf_elf, + command: [objcopy, ['-O', 'binary', '@INPUT@', '@OUTPUT@']], + depends: bmf_elf, + build_by_default: true, +) +alias_target('bin', bmf_bin) + +bmf_hex = custom_target( + 'hex', + input: bmf_elf, + output: f'@bmf_base_name@.hex', + command: [objcopy, ['-O', 'ihex', '@INPUT@', '@OUTPUT@']], + depends: bmf_elf, +) +alias_target('hex', bmf_hex) + +# Firmware size report +run_target( + 'size', + command: [size, bmf_elf.full_path(), '-B'], + depends: bmf_elf, +) + +# We report this at the end of the configuration, so it's easier to spot +warning( + '''The meson build system is experimental and not yet fully supported. Please use the Makefile build system instead. +Please report any issues you find to https://github.com/blackmagic-debug/blackmagic/issues +''' +) diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 00000000..734fb39e --- /dev/null +++ b/meson_options.txt @@ -0,0 +1,6 @@ +option('probe', type: 'combo', choices : ['native'], value: 'native', description: 'Hardware platform where the BMD firmware will run') +option('print_memory_usage', type: 'boolean', value: true, description: 'Print firmware static memory usage at the end of the build') +option('debug_output', type: 'boolean', value: false, description: 'Enable debug output (for debugging the BMD stack, not debug targets)') +option('rtt_support', type: 'boolean', value: true, description: 'Enable RTT (Real Time Transfer) support') +option('rtt_ident', type: 'string', description: 'RTT (Real Time Transfer) identifier string') +option('no_own_ll', type: 'boolean', value: false, description: 'Use generic interface routines (for when low level routines are not available)') diff --git a/src/include/version.h.in b/src/include/version.h.in new file mode 100644 index 00000000..735e0a20 --- /dev/null +++ b/src/include/version.h.in @@ -0,0 +1 @@ +#define FIRMWARE_VERSION "@VCS_TAG@" diff --git a/src/meson.build b/src/meson.build new file mode 100644 index 00000000..a55a0f6d --- /dev/null +++ b/src/meson.build @@ -0,0 +1,82 @@ +# This file is part of the Black Magic Debug project. +# +# Copyright (C) 2023 1BitSquared +# Written by Rafael Silva +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +bmd_core_includes = include_directories( + '.', + 'include', +) + +bmd_core_sources = files( + 'command.c', + 'crc32.c', + 'exception.c', + 'gdb_hostio.c', + 'gdb_main.c', + 'gdb_packet.c', + 'hex_utils.c', + 'main.c', + 'maths_utils.c', + 'morse.c', + 'remote.c', + 'timing.c', +) + +bmd_core_args = [] + +# Debug output handling +if (get_option('debug_output')) + bmd_core_args += ['-DENABLE_DEBUG=1'] +endif + +# RTT support handling +if get_option('rtt_support') + bmd_core_sources += files('rtt.c') + bmd_core_args += ['-DENABLE_RTT=1'] + + rtt_ident = get_option('rtt_ident') + if rtt_ident != '' + bmd_core_args += [f'-DRTT_IDENT=@rtt_ident@'] + endif +endif + +# Get BMD targets dependency +subdir('target') + +# Core BMD "library" (a dependency with all sources and flags to build the BMD core) +bmd_core = declare_dependency( + compile_args: bmd_core_args, + include_directories: bmd_core_includes, + sources: [bmd_core_sources, version], + dependencies: bmd_targets, +) + +# Get probe host and platform dependencies +# TODO: when support for build as a host library is added, this can be conditional? +subdir('platforms') diff --git a/src/platforms/common/meson.build b/src/platforms/common/meson.build new file mode 100644 index 00000000..1d09c16f --- /dev/null +++ b/src/platforms/common/meson.build @@ -0,0 +1,45 @@ +# This file is part of the Black Magic Debug project. +# +# Copyright (C) 2023 1BitSquared +# Written by Rafael Silva +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +platform_common_includes = include_directories('.') + +platform_common_sources = files( + 'aux_serial.c', + 'jtagtap.c', + 'swdptap.c', + 'usb.c', + 'usb_dfu_stub.c', + 'usb_serial.c', +) + +platform_common = declare_dependency( + include_directories: platform_common_includes, + sources: platform_common_sources, +) diff --git a/src/platforms/common/stm32/meson.build b/src/platforms/common/stm32/meson.build new file mode 100644 index 00000000..7da7411d --- /dev/null +++ b/src/platforms/common/stm32/meson.build @@ -0,0 +1,110 @@ +# This file is part of the Black Magic Debug project. +# +# Copyright (C) 2023 1BitSquared +# Written by Rafael Silva +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +platform_stm32_includes = include_directories('.') + +platform_stm32_sources = files( + 'gdb_if.c', + 'serialno.c', + 'timing_stm32.c', + 'traceswodecode.c', +) + +# TODO: add proper traceswoasync support +# This is a temporary hack to allow selecting traceswoasync vs traceswo implementation +fixme_platform_stm32_traceswo = declare_dependency(sources: files('traceswo.c')) +fixme_platform_stm32_traceswoasync = declare_dependency(sources: files('traceswoasync.c')) +fixme_platform_stm32f7_traceswoasync = declare_dependency(sources: files('traceswoasync_f723.c')) + +# RTT support handling +if get_option('rtt_support') + platform_stm32_sources += files('rtt_if.c') +endif + +platform_stm32_dfu_sources = files( + 'dfucore.c', + 'serialno.c', +) + +platform_stm32_args = [ + '-mthumb', + '-nostartfiles', + '-DPC_HOSTED=0', +] + +platform_stm32_link_args = [ + '-mthumb', + '-lc', + '-nostartfiles', + '--specs=nano.specs', + get_option('debug_output') ? '--specs=rdimon.specs' : '--specs=nosys.specs', + '-Wl,-gc-sections', +] + +platform_stm32_common = declare_dependency( + include_directories: platform_stm32_includes, + sources: platform_stm32_sources, + compile_args: platform_stm32_args, + link_args: platform_stm32_link_args, +) + +platform_stm32_dfu_common = declare_dependency( + include_directories: platform_stm32_includes, + sources: platform_stm32_dfu_sources, + compile_args: platform_stm32_args, + link_args: platform_stm32_link_args, +) + +## STM32F1 Platform +## ________________ + +platform_stm32f1_dfu_sources = files('dfu_f1.c') + +platform_stm32f1_args = [ + '-mcpu=cortex-m3', + '-DSTM32F1', +] + +platform_stm32f1_link_args = [ + '-mcpu=cortex-m3', +] + +platform_stm32f1 = declare_dependency( + compile_args: platform_stm32f1_args, + link_args: platform_stm32f1_link_args, + dependencies: [platform_stm32_common, dependency('opencm3_stm32f1')], +) + +platform_stm32f1_dfu = declare_dependency( + sources: platform_stm32f1_dfu_sources, + compile_args: platform_stm32f1_args, + link_args: platform_stm32f1_link_args, + dependencies: [platform_stm32_dfu_common, dependency('opencm3_stm32f1')], +) diff --git a/src/platforms/meson.build b/src/platforms/meson.build new file mode 100644 index 00000000..556f47ac --- /dev/null +++ b/src/platforms/meson.build @@ -0,0 +1,44 @@ +# This file is part of the Black Magic Debug project. +# +# Copyright (C) 2023 1BitSquared +# Written by Rafael Silva +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +# Ensure we are cross-compiling and not building for the build host +# TODO: when support for build as a host library is added, this check needs to change +assert( + meson.is_cross_build(), + '''Black Magic Firmware must be cross-compiled to the probe +Try adding the option `--cross-file @0@` for ARM based probes'''.format( + meson.project_source_root() / 'cross-file' / 'arm-none-eabi.ini' + ), +) + +subdir('common') +subdir('common/stm32') + +subdir(get_option('probe')) diff --git a/src/platforms/native/meson.build b/src/platforms/native/meson.build new file mode 100644 index 00000000..57865de3 --- /dev/null +++ b/src/platforms/native/meson.build @@ -0,0 +1,54 @@ +# This file is part of the Black Magic Debug project. +# +# Copyright (C) 2023 1BitSquared +# Written by Rafael Silva +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +probe_native_includes = include_directories('.') + +probe_native_sources = files('platform.c') + +probe_native_dfu_sources = files('usbdfu.c') + +probe_native_args = [ + '-DDFU_SERIAL_LENGTH=9', + '-DBLACKMAGIC', +] + +probe_native_link_args = [ + '-L@0@'.format(meson.current_source_dir()), + '-T@0@'.format('native.ld'), + '-Wl,-Ttext=0x8002000', +] + +probe_host = declare_dependency( + include_directories: probe_native_includes, + sources: probe_native_sources, + compile_args: probe_native_args, + link_args: probe_native_link_args, + dependencies: [platform_common, platform_stm32f1, fixme_platform_stm32_traceswo], +) diff --git a/src/target/meson.build b/src/target/meson.build new file mode 100644 index 00000000..402fd3b3 --- /dev/null +++ b/src/target/meson.build @@ -0,0 +1,102 @@ +# This file is part of the Black Magic Debug project. +# +# Copyright (C) 2023 1BitSquared +# Written by Rafael Silva +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +target_common_includes = include_directories('.') + +# !TODO: selective include +target_sources = files( + 'adiv5.c', + 'adiv5_jtag.c', + 'adiv5_swd.c', + 'at32f43x.c', + 'ch32f1.c', + 'cortex.c', + 'cortexar.c', + 'cortexm.c', + 'efm32.c', + 'gdb_reg.c', + 'hc32l110.c', + 'imxrt.c', + 'jtag_devs.c', + 'jtag_scan.c', + 'kinetis.c', + 'lmi.c', + 'lpc11xx.c', + 'lpc15xx.c', + 'lpc17xx.c', + 'lpc40xx.c', + 'lpc43xx.c', + 'lpc546xx.c', + 'lpc55xx.c', + 'lpc_common.c', + 'msp432e4.c', + 'msp432p4.c', + 'nrf51.c', + 'nrf91.c', + 'nxpke04.c', + 'renesas.c', + 'riscv32.c', + 'riscv64.c', + 'riscv_debug.c', + 'riscv_jtag_dtm.c', + 'rp.c', + 'sam3x.c', + 'sam4l.c', + 'samd.c', + 'samx5x.c', + 'sfdp.c', + 'spi.c', + 'stm32f1.c', + 'stm32f4.c', + 'stm32g0.c', + 'stm32h5.c', + 'stm32h7.c', + 'stm32l0.c', + 'stm32l4.c', + 'stm32mp15.c', + 'zynq7000.c', + 'target.c', + 'target_flash.c', + 'target_probe.c', +) + +# Handle generic routines, used when low-level routines are not available +if (get_option('no_own_ll')) + target_sources += files( + 'jtagtap_generic.c', + 'swdptap_generic.c', + ) +endif + +# BMD target dependency +bmd_targets = declare_dependency( + include_directories: target_common_includes, + sources: target_sources, +)