From 10f35ff05df1f3c1f1c2a04f8dcb525950f70e8a Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Fri, 6 Oct 2023 08:09:52 +0000 Subject: meson.setupHook: prefer meson commands over ninja MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Meson now comes with its own set of commands for building, testing, installing etc., that by default wrap around Ninja. The reason to prefer using the Meson commands is that they take additional options (e.g. setting custom timeouts for tests — my motivation for this change). Here, I've modified the Meson setup hook so that Meson's test and install commands will be used instead of Ninja's when Meson's configurePhase is used. This restriction is to avoid starting to run Meson directly when dealing with custom build systems that wrap around Meson, like QEMU's. We don't use meson's compile command, as it just runs ninja, and that's handled fine by the existing Ninja setup hook. Naturally the Meson commands don't support entirely the same set of options that the Ninja ones did, but I checked through Nixpkgs to find any packages using Meson that used any options that wouldn't be picked up by this new system. I only found one, and it was just setting checkTarget = "test", which is the default value for Ninja and has no Meson equivalent (because we directly tell Meson to run the tests rather than going through a generic job system like Ninja). Link: https://github.com/NixOS/nixpkgs/issues/113829 Co-authored-by: Jan Tojnar --- doc/hooks/meson.section.md | 26 +++++++++++++++++++++++--- doc/hooks/ninja.section.md | 2 ++ 2 files changed, 25 insertions(+), 3 deletions(-) (limited to 'doc') diff --git a/doc/hooks/meson.section.md b/doc/hooks/meson.section.md index fd7779e6468f..7496def5806f 100644 --- a/doc/hooks/meson.section.md +++ b/doc/hooks/meson.section.md @@ -1,16 +1,28 @@ # Meson {#meson} -Overrides the configure phase to run meson to generate Ninja files. To run these files, you should accompany Meson with ninja. By default, `enableParallelBuilding` is enabled as Meson supports parallel building almost everywhere. +Overrides the configure, check, and install phases to run `meson setup`, `meson test`, and `meson install`. + +Meson is a meta-build system so you will need a secondary build system to run the generated build files in build phase. In Nixpkgs context, you will want to accompany Meson with ninja, which provides a [setup hook](#ninja) registering a ninja-based build phase. + +By default, `enableParallelBuilding` is enabled as Meson supports parallel building almost everywhere. ## Variables controlling Meson {#variables-controlling-meson} ### `mesonFlags` {#mesonflags} -Controls the flags passed to meson. +Controls the flags passed to `meson setup`. + +##### `mesonCheckFlags` {#mesoncheckflags} + +Controls the flags passed to `meson test`. + +##### `mesonInstallFlags` {#mesoninstallflags} + +Controls the flags passed to `meson install`. ### `mesonBuildType` {#mesonbuildtype} -Which [`--buildtype`](https://mesonbuild.com/Builtin-options.html#core-options) to pass to Meson. We default to `plain`. +Which [`--buildtype`](https://mesonbuild.com/Builtin-options.html#core-options) to pass to `meson setup`. We default to `plain`. ### `mesonAutoFeatures` {#mesonautofeatures} @@ -23,3 +35,11 @@ What value to set [`-Dwrap_mode=`](https://mesonbuild.com/Builtin-options.html#c ### `dontUseMesonConfigure` {#dontusemesonconfigure} Disables using Meson’s `configurePhase`. + +##### `dontUseMesonCheck` {#dontusemesoncheck} + +Disables using Meson’s `checkPhase`. + +##### `dontUseMesonInstall` {#dontusemesoninstall} + +Disables using Meson’s `installPhase`. diff --git a/doc/hooks/ninja.section.md b/doc/hooks/ninja.section.md index 4b0e33feb5c3..bbc948108804 100644 --- a/doc/hooks/ninja.section.md +++ b/doc/hooks/ninja.section.md @@ -1,3 +1,5 @@ # ninja {#ninja} Overrides the build, install, and check phase to run ninja instead of make. You can disable this behavior with the `dontUseNinjaBuild`, `dontUseNinjaInstall`, and `dontUseNinjaCheck`, respectively. Parallel building is enabled by default in Ninja. + +Note that if the [Meson setup hook](#meson) is also active, Ninja's install and check phases will be disabled in favor of Meson's. -- cgit 1.4.1 From 31ebe7b4598145f4009873be59d88d4fcbe952a1 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Sat, 21 Oct 2023 08:41:21 +0000 Subject: doc: fix heading levels of Meson hook documentation Fixes: 10f35ff05df1 ("meson.setupHook: prefer meson commands over ninja") --- doc/hooks/meson.section.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'doc') diff --git a/doc/hooks/meson.section.md b/doc/hooks/meson.section.md index 7496def5806f..93e7019c311b 100644 --- a/doc/hooks/meson.section.md +++ b/doc/hooks/meson.section.md @@ -12,11 +12,11 @@ By default, `enableParallelBuilding` is enabled as Meson supports parallel build Controls the flags passed to `meson setup`. -##### `mesonCheckFlags` {#mesoncheckflags} +### `mesonCheckFlags` {#mesoncheckflags} Controls the flags passed to `meson test`. -##### `mesonInstallFlags` {#mesoninstallflags} +### `mesonInstallFlags` {#mesoninstallflags} Controls the flags passed to `meson install`. @@ -36,10 +36,10 @@ What value to set [`-Dwrap_mode=`](https://mesonbuild.com/Builtin-options.html#c Disables using Meson’s `configurePhase`. -##### `dontUseMesonCheck` {#dontusemesoncheck} +### `dontUseMesonCheck` {#dontusemesoncheck} Disables using Meson’s `checkPhase`. -##### `dontUseMesonInstall` {#dontusemesoninstall} +### `dontUseMesonInstall` {#dontusemesoninstall} Disables using Meson’s `installPhase`. -- cgit 1.4.1 From 36eff4f43199433fdeba4d098f7799d1bb81d576 Mon Sep 17 00:00:00 2001 From: Julian Stecklina Date: Thu, 19 Oct 2023 12:23:31 +0200 Subject: meson: introduce mesonInstallTags Projects building with meson are currently installTargets. Map these to install tags, which are roughly equivalent. This allows projects to selectively install components. --- doc/hooks/meson.section.md | 9 +++++++++ pkgs/development/tools/build-managers/meson/setup-hook.sh | 4 ++++ 2 files changed, 13 insertions(+) (limited to 'doc') diff --git a/doc/hooks/meson.section.md b/doc/hooks/meson.section.md index 93e7019c311b..dc261271326a 100644 --- a/doc/hooks/meson.section.md +++ b/doc/hooks/meson.section.md @@ -43,3 +43,12 @@ Disables using Meson’s `checkPhase`. ### `dontUseMesonInstall` {#dontusemesoninstall} Disables using Meson’s `installPhase`. + +### `mesonInstallFlags` {#mesoninstallflags} + +Controls the flags passed to meson install. + +### `mesonInstallTags` (#mesoninstalltags) + +Tags specified here will be passed to Meson as via `--tags` during +installation and controls which components will be installed. diff --git a/pkgs/development/tools/build-managers/meson/setup-hook.sh b/pkgs/development/tools/build-managers/meson/setup-hook.sh index 21faac529c6d..dc7780b2fd3d 100644 --- a/pkgs/development/tools/build-managers/meson/setup-hook.sh +++ b/pkgs/development/tools/build-managers/meson/setup-hook.sh @@ -55,6 +55,10 @@ mesonInstallPhase() { # shellcheck disable=SC2086 local flagsArray=($mesonInstallFlags "${mesonInstallFlagsArray[@]}") + if [[ -n "$mesonInstallTags" ]]; then + flagsArray+=("--tags" "${mesonInstallTags// /,}") + fi + echoCmd 'install flags' "${flagsArray[@]}" meson install --no-rebuild "${flagsArray[@]}" -- cgit 1.4.1