In this PR we address the problem of using libopencm3 as a subproject dependency in Black Magic Debug as part of the new Meson build system that's being prepared in blackmagic-debug/blackmagic#1528.
This PR implements a new Meson build system for this project, with adaptions made to the NVIC irq.json -> {nvic.h,vector_nvic.c,irqhandlers.h} converter script to allow it to be used with an out-of-tree build directory (like that of any Meson build).
It is noted that this conversion is incomplete, only converting the STM32F{0,1,3,4,7} and LM4F target platforms and leaving the rest as a later exercise. This has been done this way as BMD only uses these 6 target platforms, but conversion of further platforms should be fairly simple at this point, with so much of the required infrastructure having been built to support these 6.
This PR blocks the one in BMD as that builds on this one.
Usage of this new build system works as follows:
git clone https://github.com/blackmagic-debug/libopencm3 -b feature/meson
cd libopencm3
meson setup build --cross-file=cross-files/arm-none-eabi.ini -Dtarget=<platform>
ninja -C build # This can optionally be `cd build` then `ninja`, they're identical operations.
The result of this will be a libopencm3_.a library in the build directory under the same path as the matching source - eg, lib/stm32/f1/libopencm3_stm32f1.a for -Dtarget=stm32f1.
There will be additional warnings spat out by this to a normal Makefile-based build as this PR enables some of the enhanced warnings set we use and which BMD itself is getting to find bugs and issues. There is a follow-up PR needed to fix some issues in libopencm3 that these warnings have found, such as UB misuse of void * pointers in maths, which the C standard has never allowed and expressly forbidden.
Due to the likelihood that upstream libopencm3 will not want this build system, we are not opening a PR there unless the maintainer asks us to, as we figure this is specific to the needs and direction of BMD. We do not have a problem doing so though if the project is interested in this landing there.
In this PR we address the problem of using libopencm3 as a subproject dependency in Black Magic Debug as part of the new Meson build system that's being prepared in blackmagic-debug/blackmagic#1528.
This PR implements a new Meson build system for this project, with adaptions made to the NVIC irq.json -> {nvic.h,vector_nvic.c,irqhandlers.h} converter script to allow it to be used with an out-of-tree build directory (like that of any Meson build).
It is noted that this conversion is incomplete, only converting the STM32F{0,1,3,4,7} and LM4F target platforms and leaving the rest as a later exercise. This has been done this way as BMD only uses these 6 target platforms, but conversion of further platforms should be fairly simple at this point, with so much of the required infrastructure having been built to support these 6.
This PR blocks the one in BMD as that builds on this one.
Usage of this new build system works as follows:
```bash
git clone https://github.com/blackmagic-debug/libopencm3 -b feature/meson
cd libopencm3
meson setup build --cross-file=cross-files/arm-none-eabi.ini -Dtarget=<platform>
ninja -C build # This can optionally be `cd build` then `ninja`, they're identical operations.
```
The result of this will be a libopencm3_<platform>.a library in the build directory under the same path as the matching source - eg, `lib/stm32/f1/libopencm3_stm32f1.a` for `-Dtarget=stm32f1`.
There will be additional warnings spat out by this to a normal Makefile-based build as this PR enables some of the enhanced warnings set we use and which BMD itself is getting to find bugs and issues. There is a follow-up PR needed to fix some issues in libopencm3 that these warnings have found, such as UB misuse of `void *` pointers in maths, which the C standard has never allowed and expressly forbidden.
Due to the likelihood that upstream libopencm3 will not want this build system, we are not opening a PR there unless the maintainer asks us to, as we figure this is specific to the needs and direction of BMD. We do not have a problem doing so though if the project is interested in this landing there.