4
0
Fork
You've already forked libopencm3
3

Feature: Meson build system support #1

Merged
esden merged 17 commits from feature/meson into main 2023年12月04日 09:58:41 +01:00

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.
esden (Migrated from github.com) approved these changes 2023年12月04日 09:58:29 +01:00
esden (Migrated from github.com) left a comment
Copy link

Tested it out on my Mac build machine. Looks good!

Tested it out on my Mac build machine. Looks good!
Sign in to join this conversation.
No reviewers
Labels
Clear labels
No items
No labels
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
blackmagic-debug/libopencm3!1
Reference in a new issue
blackmagic-debug/libopencm3
No description provided.
Delete branch "feature/meson"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?