diff options
author | John Ericson <John.Ericson@Obsidian.Systems> | 2020-04-26 16:47:27 -0400 |
---|---|---|
committer | John Ericson <John.Ericson@Obsidian.Systems> | 2020-04-28 10:55:33 -0400 |
commit | 8245230753d260b61b928fad7e00323f38ca450f (patch) | |
tree | 57863834843f4cca0fcb9479763fc1f598a98d85 /pkgs/stdenv/generic/make-derivation.nix | |
parent | 128b93e06142914a88c91f3c9f03ce52f6cb569e (diff) |
meson: Make target-agnostic
The cross file is added in the `mkDerivation`. It isn't nice putting
build tool-specific stuff here, but our current architecture gives us
little alternative.
Diffstat (limited to 'pkgs/stdenv/generic/make-derivation.nix')
-rw-r--r-- | pkgs/stdenv/generic/make-derivation.nix | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/pkgs/stdenv/generic/make-derivation.nix b/pkgs/stdenv/generic/make-derivation.nix index a11b280b047e..e6363ce42c0a 100644 --- a/pkgs/stdenv/generic/make-derivation.nix +++ b/pkgs/stdenv/generic/make-derivation.nix @@ -49,6 +49,7 @@ in rec { # Configure Phase , configureFlags ? [] , cmakeFlags ? [] + , mesonFlags ? [] , # Target is not included by default because most programs don't care. # Including it then would cause needless mass rebuilds. # @@ -252,6 +253,34 @@ in rec { ++ lib.optional (stdenv.buildPlatform.uname.system != null) "-DCMAKE_HOST_SYSTEM_NAME=${stdenv.buildPlatform.uname.system}" ++ lib.optional (stdenv.buildPlatform.uname.processor != null) "-DCMAKE_HOST_SYSTEM_PROCESSOR=${stdenv.buildPlatform.uname.processor}" ++ lib.optional (stdenv.buildPlatform.uname.release != null) "-DCMAKE_HOST_SYSTEM_VERSION=${stdenv.buildPlatform.uname.release}"; + + mesonFlags = if mesonFlags == null then null else let + # See https://mesonbuild.com/Reference-tables.html#cpu-families + cpuFamilies = { + aarch64 = "aarch64"; + armv5tel = "arm"; + armv6l = "arm"; + armv7l = "arm"; + i686 = "x86"; + x86_64 = "x86_64"; + }; + crossFile = builtins.toFile "cross-file.conf" ('' + [properties] + needs_exe_wrapper = true + + [host_machine] + system = '${stdenv.targetPlatform.parsed.kernel.name}' + cpu_family = '${cpuFamilies.${stdenv.targetPlatform.parsed.cpu.name}}' + cpu = '${stdenv.targetPlatform.parsed.cpu.name}' + endian = ${if stdenv.targetPlatform.isLittleEndian then "'little'" else "'big'"} + '' + # TODO should have target prefix too, issue #86077 + + '' + + [binaries] + pkgconfig = 'pkg-config' + ''); + in [ "--cross-file=${crossFile}" ] ++ mesonFlags; } // lib.optionalAttrs (attrs.enableParallelBuilding or false) { enableParallelChecking = attrs.enableParallelChecking or true; } // lib.optionalAttrs (hardeningDisable != [] || hardeningEnable != []) { |