aboutsummaryrefslogtreecommitdiff
path: root/package.nix
diff options
context:
space:
mode:
Diffstat (limited to 'package.nix')
-rw-r--r--package.nix52
1 files changed, 47 insertions, 5 deletions
diff --git a/package.nix b/package.nix
index 9a2e08038..6b9fbf6d2 100644
--- a/package.nix
+++ b/package.nix
@@ -100,6 +100,43 @@ let
testConfigureFlags = [ "RAPIDCHECK_HEADERS=${lib.getDev rapidcheck}/extras/gtest/include" ];
+ # Reimplementation of Nixpkgs' Meson cross file, with some additions to make
+ # it actually work.
+ mesonCrossFile =
+ let
+ cpuFamily =
+ platform:
+ with platform;
+ if isAarch32 then
+ "arm"
+ else if isx86_32 then
+ "x86"
+ else
+ platform.uname.processor;
+ in
+ builtins.toFile "lix-cross-file.conf" ''
+ [properties]
+ bindgen_clang_arguments = ['-target', '${stdenv.targetPlatform.config}']
+ # Meson is convinced that if !buildPlatform.canExecute hostPlatform then we cannot
+ # build anything at all, which is not at all correct. If we can't execute the host
+ # platform, we'll just disable tests and doc gen.
+ needs_exe_wrapper = false
+
+ [host_machine]
+ system = '${stdenv.targetPlatform.parsed.kernel.name}'
+ cpu_family = '${cpuFamily stdenv.targetPlatform}'
+ cpu = '${stdenv.targetPlatform.parsed.cpu.name}'
+ endian = ${if stdenv.targetPlatform.isLittleEndian then "'little'" else "'big'"}
+
+ [binaries]
+ llvm-config = 'llvm-config-native'
+ rust = ['rustc', '--target', '${stdenv.targetPlatform.rust.rustcTargetSpec}']
+ # Meson refuses to consider any CMake binary during cross compilation if it's
+ # not explicitly specified here, in the cross file.
+ # https://github.com/mesonbuild/meson/blob/0ed78cf6fa6d87c0738f67ae43525e661b50a8a2/mesonbuild/cmake/executor.py#L72
+ cmake = 'cmake'
+ '';
+
# The internal API docs need these for the build, but if we're not building
# Nix itself, then these don't need to be propagated.
maybePropagatedInputs = [
@@ -184,10 +221,15 @@ stdenv.mkDerivation (finalAttrs: {
]
++ lib.optional stdenv.hostPlatform.isStatic "-Denable-embedded-sandbox-shell=true"
++ lib.optional (finalAttrs.dontBuild) "-Denable-build=false"
- # mesonConfigurePhase automatically passes -Dauto_features=enabled,
- # so we must explicitly enable or disable features that we are not passing
- # dependencies for.
- ++ lib.singleton (lib.mesonEnable "internal-api-docs" internalApiDocs);
+ ++ [
+ # mesonConfigurePhase automatically passes -Dauto_features=enabled,
+ # so we must explicitly enable or disable features that we are not passing
+ # dependencies for.
+ (lib.mesonEnable "internal-api-docs" internalApiDocs)
+ (lib.mesonBool "enable-tests" finalAttrs.doCheck)
+ (lib.mesonBool "enable-docs" canRunInstalled)
+ ]
+ ++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) "--cross-file=${mesonCrossFile}";
# We only include CMake so that Meson can locate toml11, which only ships CMake dependency metadata.
dontUseCmakeConfigure = true;
@@ -315,7 +357,7 @@ stdenv.mkDerivation (finalAttrs: {
makeFlags = "profiledir=$(out)/etc/profile.d PRECOMPILE_HEADERS=1";
- doCheck = true;
+ doCheck = canRunInstalled;
mesonCheckFlags = lib.optionals (buildWithMeson || forDevShell) [ "--suite=check" ];