mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-23 06:03:40 +00:00
3ff0cd7263
Also strip the `HAREPATH` make variable embedded in the binary from empty `$(SRCDIR)/hare/third-party`, since since nix does not follows the FHS and relies on the `HAREPATH` environment variable to find third party libraries.
32 lines
844 B
Nix
32 lines
844 B
Nix
{ lib
|
|
, buildPackages
|
|
, hare
|
|
, runCommandNoCC
|
|
, stdenv
|
|
, writeText
|
|
}:
|
|
let
|
|
inherit (stdenv.hostPlatform.uname) processor;
|
|
inherit (stdenv.hostPlatform) emulator;
|
|
mainDotHare = writeText "main.ha" ''
|
|
use fmt;
|
|
use os;
|
|
export fn main() void = {
|
|
const machine = os::machine();
|
|
if (machine == "${processor}") {
|
|
fmt::println("os::machine() matches ${processor}")!;
|
|
} else {
|
|
fmt::fatalf("os::machine() does not match ${processor}: {}", machine);
|
|
};
|
|
};
|
|
'';
|
|
in
|
|
runCommandNoCC "${hare.pname}-cross-compilation-test" { meta.timeout = 60; } ''
|
|
HARECACHE="$(mktemp -d --tmpdir harecache.XXXXXXXX)"
|
|
export HARECACHE
|
|
outbin="test-${processor}"
|
|
${lib.getExe hare} build -q -a "${processor}" -o "$outbin" ${mainDotHare}
|
|
${emulator buildPackages} "./$outbin"
|
|
: 1>$out
|
|
''
|