2023-06-10 15:54:02 +00:00
|
|
|
# Meson {#meson}
|
2022-10-13 13:36:04 +00:00
|
|
|
|
2023-10-27 20:46:01 +00:00
|
|
|
[Meson](https://mesonbuild.com/) is an open source meta build system meant to be
|
|
|
|
fast and user-friendly.
|
meson.setupHook: prefer meson commands over ninja
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 <jtojnar@gmail.com>
2023-10-06 08:09:52 +00:00
|
|
|
|
2023-10-27 20:46:01 +00:00
|
|
|
In Nixpkgs, meson comes with a setup hook that overrides the configure, check,
|
|
|
|
and install phases.
|
meson.setupHook: prefer meson commands over ninja
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 <jtojnar@gmail.com>
2023-10-06 08:09:52 +00:00
|
|
|
|
2023-10-27 20:46:01 +00:00
|
|
|
Being a meta build system, meson needs an accompanying backend. In the context
|
|
|
|
of Nixpkgs, the typical companion backend is [Ninja](#ninja), that provides a
|
|
|
|
setup hook registering ninja-based build and install phases.
|
2022-10-13 13:36:04 +00:00
|
|
|
|
2023-10-27 20:46:01 +00:00
|
|
|
## Variables controlling Meson {#meson-variables-controlling}
|
2022-10-13 13:36:04 +00:00
|
|
|
|
2023-10-27 20:46:01 +00:00
|
|
|
### Meson Exclusive Variables {#meson-exclusive-variables}
|
2022-10-13 13:36:04 +00:00
|
|
|
|
2023-10-27 20:46:01 +00:00
|
|
|
#### `mesonFlags` {#meson-flags}
|
meson.setupHook: prefer meson commands over ninja
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 <jtojnar@gmail.com>
2023-10-06 08:09:52 +00:00
|
|
|
|
2023-10-27 20:46:01 +00:00
|
|
|
Controls the flags passed to `meson setup` during configure phase.
|
meson.setupHook: prefer meson commands over ninja
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 <jtojnar@gmail.com>
2023-10-06 08:09:52 +00:00
|
|
|
|
2024-09-18 19:54:02 +00:00
|
|
|
#### `mesonBuildDir` {#meson-build-dir}
|
|
|
|
|
|
|
|
Directory where Meson will put intermediate files.
|
|
|
|
|
|
|
|
Setting this can be useful for debugging multiple Meson builds while in the same source directory, for example, when building for different platforms.
|
|
|
|
Different values for each build will prevent build artefacts from interefering with each other.
|
|
|
|
This setting has no tangible effect when running the build in a sandboxed derivation.
|
|
|
|
|
|
|
|
The default value is `build`.
|
|
|
|
|
2023-10-27 20:46:01 +00:00
|
|
|
#### `mesonWrapMode` {#meson-wrap-mode}
|
meson.setupHook: prefer meson commands over ninja
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 <jtojnar@gmail.com>
2023-10-06 08:09:52 +00:00
|
|
|
|
2023-10-27 20:46:01 +00:00
|
|
|
Which value is passed as
|
|
|
|
[`-Dwrap_mode=`](https://mesonbuild.com/Builtin-options.html#core-options)
|
|
|
|
to. In Nixpkgs the default value is `nodownload`, so that no subproject will be
|
|
|
|
downloaded (since network access is already disabled during deployment in
|
|
|
|
Nixpkgs).
|
meson.setupHook: prefer meson commands over ninja
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 <jtojnar@gmail.com>
2023-10-06 08:09:52 +00:00
|
|
|
|
2023-10-27 20:46:01 +00:00
|
|
|
Note: Meson allows pre-population of subprojects that would otherwise be
|
|
|
|
downloaded.
|
2022-10-13 13:36:04 +00:00
|
|
|
|
2023-10-27 20:46:01 +00:00
|
|
|
#### `mesonBuildType` {#meson-build-type}
|
2023-10-27 14:59:43 +00:00
|
|
|
|
2023-10-27 20:46:01 +00:00
|
|
|
Which value is passed as
|
|
|
|
[`--buildtype`](https://mesonbuild.com/Builtin-options.html#core-options) to
|
|
|
|
`meson setup` during configure phase. In Nixpkgs the default value is `plain`.
|
2023-10-27 14:59:43 +00:00
|
|
|
|
2023-10-27 20:46:01 +00:00
|
|
|
#### `mesonAutoFeatures` {#meson-auto-features}
|
2022-10-13 13:36:04 +00:00
|
|
|
|
2023-10-27 20:46:01 +00:00
|
|
|
Which value is passed as
|
|
|
|
[`-Dauto_features=`](https://mesonbuild.com/Builtin-options.html#core-options)
|
|
|
|
to `meson setup` during configure phase. In Nixpkgs the default value is
|
|
|
|
`enabled`, meaning that every feature declared as "auto" by the meson scripts
|
|
|
|
will be enabled.
|
2022-10-13 13:36:04 +00:00
|
|
|
|
2023-10-27 20:46:01 +00:00
|
|
|
#### `mesonCheckFlags` {#meson-check-flags}
|
2022-10-13 13:36:04 +00:00
|
|
|
|
2023-10-27 20:46:01 +00:00
|
|
|
Controls the flags passed to `meson test` during check phase.
|
2022-10-13 13:36:04 +00:00
|
|
|
|
2023-10-27 20:46:01 +00:00
|
|
|
#### `mesonInstallFlags` {#meson-install-flags}
|
2022-10-13 13:36:04 +00:00
|
|
|
|
2023-10-27 20:46:01 +00:00
|
|
|
Controls the flags passed to `meson install` during install phase.
|
2022-10-13 13:36:04 +00:00
|
|
|
|
2023-10-27 20:46:01 +00:00
|
|
|
#### `mesonInstallTags` {#meson-install-tags}
|
2022-10-13 13:36:04 +00:00
|
|
|
|
2023-10-27 20:46:01 +00:00
|
|
|
A list of installation tags passed to Meson's commandline option
|
|
|
|
[`--tags`](https://mesonbuild.com/Installing.html#installation-tags) during
|
|
|
|
install phase.
|
meson.setupHook: prefer meson commands over ninja
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 <jtojnar@gmail.com>
2023-10-06 08:09:52 +00:00
|
|
|
|
2023-10-27 20:46:01 +00:00
|
|
|
Note: `mesonInstallTags` should be a list of strings, that will be converted to
|
|
|
|
a comma-separated string that is recognized to `--tags`.
|
|
|
|
Example: `mesonInstallTags = [ "emulator" "assembler" ];` will be converted to
|
|
|
|
`--tags emulator,assembler`.
|
meson.setupHook: prefer meson commands over ninja
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 <jtojnar@gmail.com>
2023-10-06 08:09:52 +00:00
|
|
|
|
2023-10-27 20:46:01 +00:00
|
|
|
#### `dontUseMesonConfigure` {#dont-use-meson-configure}
|
meson.setupHook: prefer meson commands over ninja
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 <jtojnar@gmail.com>
2023-10-06 08:09:52 +00:00
|
|
|
|
2023-10-27 20:46:01 +00:00
|
|
|
When set to true, don't use the predefined `mesonConfigurePhase`.
|
meson.setupHook: prefer meson commands over ninja
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 <jtojnar@gmail.com>
2023-10-06 08:09:52 +00:00
|
|
|
|
2023-10-27 20:46:01 +00:00
|
|
|
#### `dontUseMesonCheck` {#dont-use-meson-check}
|
|
|
|
|
|
|
|
When set to true, don't use the predefined `mesonCheckPhase`.
|
|
|
|
|
|
|
|
#### `dontUseMesonInstall` {#dont-use-meson-install}
|
|
|
|
|
|
|
|
When set to true, don't use the predefined `mesonInstallPhase`.
|
|
|
|
|
|
|
|
### Honored variables {#meson-honored-variables}
|
|
|
|
|
|
|
|
The following variables commonly used by `stdenv.mkDerivation` are honored by
|
|
|
|
Meson setup hook.
|
|
|
|
|
|
|
|
- `prefixKey`
|
|
|
|
- `enableParallelBuilding`
|