kdsch.org · about · rss

2023 May 2

A port of libopencm3's build system to Meson

I am porting libopencm3’s build system to Meson. I’ve used Make for a long time. Here’s why I want to use Meson for new projects.

Status

The Meson port builds all targets. It supports building a subset of targets when used as a Meson subproject. I’ve been testing the STM32F4 target on an example project. This project has been running well on the stm32f4-discovery development board. I have not run code for other targets. The port does not yet support running libopencm3’s tests or building Doxygen documentation. The port does not interoperate with libopencm3’s examples or template repositories.

Goals

  1. Don’t break the original build system.

  2. Avoid changing existing files. Adding new files is OK.

  3. Write idiomatic Meson code.

  4. Support operating as a Meson subproject.

  5. Match the original toolchain invocations as closely as possible.

The port was created by manual and automated processes. An Awk script translates target Makefiles into Meson code. To simplify the script, I changed a few Makefiles to be more uniform. Meson assumes that source files with a .c extension are valid translation units. This isn’t true in the case of vector_nvic.c: it is not compiled itself, but is included by another file. I worked around this by changing the filename to vector_nvic.h.

The port has four build-time dependencies: Meson (obviously), Python (which was already used), Ninja, and Awk. The Awk script is checked in. (It may be removed if the two build systems no longer need to be synchronized.) Ninja is widely available. There is also a Ninja-compatible alternative called Samurai, written in C.

If upstream were to consider accepting Meson support for libopencm3, they should think about:


Feedback

Discuss this page by emailing my public inbox. Please note the etiquette guidelines.

© 2024 Karl Schultheisz — source