3
0
Fork 0
forked from mirrors/nixpkgs

mesonEmulatorHook: check if the target binaries can be executed

this prevents having to bring in the emulator when compiling e.g. pkgsStatic
This commit is contained in:
Artturin 2022-07-07 21:29:21 +03:00
parent 71cbf3b809
commit 2cbce6b012
2 changed files with 4 additions and 4 deletions

View file

@ -155,14 +155,14 @@ doCheck = stdenv.hostPlatform == stdenv.buildPlatform;
#### Package using Meson needs to run binaries for the host platform during build. {#cross-meson-runs-host-code}
Add `mesonEmulatorHook` cross conditionally to `nativeBuildInputs`.
Add `mesonEmulatorHook` to `nativeBuildInputs` conditionally on if the target binaries can be executed.
e.g.
```
nativeBuildInputs = [
meson
] ++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [
] ++ lib.optionals (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) [
mesonEmulatorHook
];
```

View file

@ -4131,7 +4131,7 @@ with pkgs;
# example of an error which this fixes
# [Errno 8] Exec format error: './gdk3-scan'
mesonEmulatorHook =
if (stdenv.buildPlatform != stdenv.targetPlatform) then
if (!stdenv.buildPlatform.canExecute stdenv.targetPlatform) then
makeSetupHook
{
name = "mesonEmulatorHook";
@ -4142,7 +4142,7 @@ with pkgs;
'';
};
} ../development/tools/build-managers/meson/emulator-hook.sh
else throw "mesonEmulatorHook has to be in a cross conditional i.e. (stdenv.buildPlatform != stdenv.hostPlatform)";
else throw "mesonEmulatorHook has to be in a conditional to check if the target binaries can be executed i.e. (!stdenv.buildPlatform.canExecute stdenv.hostPlatform)";
meson-tools = callPackage ../misc/meson-tools { };