diff options
author | Alyssa Ross <hi@alyssa.is> | 2022-02-10 19:31:20 +0000 |
---|---|---|
committer | Alyssa Ross <hi@alyssa.is> | 2022-06-04 21:26:54 +0000 |
commit | 7a4ec5c4fa75e4ccd68f9402c7d9871d89dc9655 (patch) | |
tree | 73ebe9b35a2980ae9fcc5670b811b7f1cf9ef9f0 /pkgs/development/tools | |
parent | b7d2bceeb0f0cfcd49ceb22594c62015ba88da0a (diff) | |
download | nixpkgs-7a4ec5c4fa75e4ccd68f9402c7d9871d89dc9655.tar nixpkgs-7a4ec5c4fa75e4ccd68f9402c7d9871d89dc9655.tar.gz nixpkgs-7a4ec5c4fa75e4ccd68f9402c7d9871d89dc9655.tar.bz2 nixpkgs-7a4ec5c4fa75e4ccd68f9402c7d9871d89dc9655.tar.lz nixpkgs-7a4ec5c4fa75e4ccd68f9402c7d9871d89dc9655.tar.xz nixpkgs-7a4ec5c4fa75e4ccd68f9402c7d9871d89dc9655.tar.zst nixpkgs-7a4ec5c4fa75e4ccd68f9402c7d9871d89dc9655.zip |
meson: pull cross-file logic out of stdenv
Since Meson isn't part of stdenv, it doesn't really make sense for stdenv to handle mesonFlags. And putting it in stdenv imposes some limitations — we can't depend on e.g. rust.toRustTargetSpec, which we'll need to introduce Rust support in the cross file.
Diffstat (limited to 'pkgs/development/tools')
-rw-r--r-- | pkgs/development/tools/build-managers/meson/default.nix | 28 | ||||
-rw-r--r-- | pkgs/development/tools/build-managers/meson/setup-hook.sh | 2 |
2 files changed, 28 insertions, 2 deletions
diff --git a/pkgs/development/tools/build-managers/meson/default.nix b/pkgs/development/tools/build-managers/meson/default.nix index f62bb22314d..88426ae713d 100644 --- a/pkgs/development/tools/build-managers/meson/default.nix +++ b/pkgs/development/tools/build-managers/meson/default.nix @@ -1,4 +1,5 @@ { lib +, stdenv , fetchpatch , installShellFiles , ninja @@ -71,7 +72,32 @@ python3.pkgs.buildPythonApplication rec { ./fix-gtkdoc-when-using-multiple-apple-frameworks.patch ]; - setupHook = ./setup-hook.sh; + cpuFamily = with stdenv.targetPlatform; + /**/ if isAarch32 then "arm" + else if isAarch64 then "aarch64" + else if isx86_32 then "x86" + else if isx86_64 then "x86_64" + else parsed.cpu.family + builtins.toString parsed.cpu.bits; + + crossFile = if stdenv.hostPlatform == stdenv.targetPlatform then null else + builtins.toFile "cross-file.conf" '' + [properties] + needs_exe_wrapper = true + + [host_machine] + system = '${stdenv.targetPlatform.parsed.kernel.name}' + cpu_family = '${cpuFamily}' + cpu = '${stdenv.targetPlatform.parsed.cpu.name}' + endian = ${if stdenv.targetPlatform.isLittleEndian then "'little'" else "'big'"} + + [binaries] + llvm-config = 'llvm-config-native' + ''; + + setupHook = substituteAll { + src = ./setup-hook.sh; + crossFlags = lib.optionalString (crossFile != null) "--cross-file=${crossFile}"; + }; # Meson included tests since 0.45, however they fail in Nixpkgs because they # require a typical building environment (including C compiler and stuff). diff --git a/pkgs/development/tools/build-managers/meson/setup-hook.sh b/pkgs/development/tools/build-managers/meson/setup-hook.sh index 3d946fcffd5..6a7087174e5 100644 --- a/pkgs/development/tools/build-managers/meson/setup-hook.sh +++ b/pkgs/development/tools/build-managers/meson/setup-hook.sh @@ -6,7 +6,7 @@ mesonConfigurePhase() { fi # See multiple-outputs.sh and meson’s coredata.py - mesonFlags="\ + mesonFlags="@crossFlags@ \ --libdir=${!outputLib}/lib --libexecdir=${!outputLib}/libexec \ --bindir=${!outputBin}/bin --sbindir=${!outputBin}/sbin \ --includedir=${!outputInclude}/include \ |