Skip to content

Meson support

Brian Tarricone requested to merge kelnos/xfce4-dev-tools:meson-support into master

This adds support for meson to:

  • Build the xfce-build container properly for project libs that use meson.
  • Allow CI to work for projects that are switching to meson.
  • Build release tarballs properly when using xfce-do-release.

Additionally, I've added a "project template" that folks can use to help get started in their own migrations, including a README that describes how it works, as well as including some useful information.

I opted to create a separate GitLab CI yaml file for Meson rather than attempting to make the existing one work for both, with conditionals and whatnot. First off, after reading some GitLab CI docs, it wasn't straightforward how to do it. Second, I think we should let each project switch over explicitly: that is, a maintainer might want to check in some Meson files, but leave their autotools files there until they're satisfied and happy, but be able to pick which build system (or both!) CI uses.

I was a bit opinionated on the topic of project version number management. Meson doesn't have any built-in way to deal with dynamic or automated version number changes, or appending git hashes. So I "invented" something: each repo needs to have a version file in its root that has one or two lines: first line has the latest release version string, and second line optionally says "git". If it says "git", it's considered a non-release version, and the git hash is appended to the version string specified on the first line. I've included a print-version script (that each project will have to copy-paste into their tree) that takes care of that process, and the provided meson.build template makes use of it. After some discussion, we still have a version.sh script, but instead of having a version file, it uses git describe to determine the version and git hash, uses meson.add_dist_script() to rewrite the meson.build when making the dist tarball so it hard-codes the release version (since otherwise it'd require a git checkout to build).

I also did my best in the provided meson.build file to set up compiler warnings and errors, as well as debug defines and settings, similarly to how our autotools M4 macros do it. The only difference (well, aside from any mistakes I may have made) is that there's no way to set the default buildtype (release vs. debugoptimized) based on whether it's a release tarball or a git checkout. That's unfortunately a limitation of Meson. But I think it's fine to set the default to debugoptimized (which sets things up more or less like our autotools --enable-debug=yes option), and users and distro packagers will need to pass --buildtype=release to meson setup.

At any rate, here's how I've set things up so Meson's --buildtype matches to our autotools --enable-debug:

--buildtype=? --enable-debug=?
minsize no
plain minimal (but without debug symbols)
release minimal
debugoptimized yes
debug full

The minsize type is a little off the beaten path, so I appropriated it for our no setup. It kinda makes sense, I guess, as disabling gobject cast checks and asserts does make the binary smaller? Sure... A quick check suggests that Debian doesn't pass --enable-debug at all, which would give them minimal, which seems like a safe thing to do. Of course, now they'll need to pass something, or they'll get debugoptimized.

Still to be done:

  • Actually test these changes. I haven't yet!
  • meson dist builds an xz archive, whereas with autotools we use bz2. It looks like there's no option to create bz2 archives. Is xz ok? Or should we unpack and repack it as bz2? (.xz should be fine)
  • Update the Transifex sync so it'll work with meson projects. I think I just found that over in infra/transifex, so I'll take a look at that in a bit. Looks like it doesn't actually do make foo.pot to generate the potfile, and uses xgettext directly, so I think all that needs to be done there is teach it that it can use xgettext if po/meson.build exists. infra/transifex!2
  • Update xfce-test when projects change over. It looks like it already has support for meson, but needs to be told which project uses what build system.

cc: @skunnyk @Tamaranch @alexxcons @andreldm

Edited by Brian Tarricone

Merge request reports

Loading