about summary refs log tree commit diff
path: root/pkgs/test/make-binary-wrapper/cross.nix
blob: 36758086b92b2f4cb5fe38eb9bc145dc49b02bf7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
{ stdenv
, runCommand
, makeBinaryWrapper
, binutils
, expectedArch ? stdenv.hostPlatform.parsed.cpu.name
}:

runCommand "make-binary-wrapper-test-cross" {
  nativeBuildInputs = [
    makeBinaryWrapper
    binutils
  ];
  inherit expectedArch;
} ''
  touch prog
  chmod +x prog
  makeWrapper prog $out
  read -r _ arch < <($READELF --file-header $out | grep Machine:)
  if [[ ''${arch,,} != *"''${expectedArch,,}"* ]]; then
    echo "expected $expectedArch, got $arch"
    exit 1
  fi
''