ninja: fix cross compilation

This commit is contained in:
Nick Cao 2023-01-11 11:26:46 +08:00
parent 7c824bb1b1
commit 70599398d8
No known key found for this signature in database

View File

@ -9,6 +9,7 @@
, libxslt
, python3
, re2c
, buildPackages
, buildDocs ? true
}:
@ -23,6 +24,8 @@ stdenv.mkDerivation rec {
hash = "sha256-LvV/Fi2ARXBkfyA1paCRmLUwCh/rTyz+tGMg2/qEepI=";
};
depsBuildBuild = [ buildPackages.stdenv.cc ];
nativeBuildInputs = [
python3
re2c
@ -35,10 +38,25 @@ stdenv.mkDerivation rec {
libxslt.bin
];
postPatch = ''
# write rebuild args to file after bootstrap
substituteInPlace configure.py --replace "subprocess.check_call(rebuild_args)" "open('rebuild_args','w').write(rebuild_args[0])"
'';
buildPhase = ''
runHook preBuild
# for list of env vars
# see https://github.com/ninja-build/ninja/blob/v1.11.1/configure.py#L264
CXX="$CXX_FOR_BUILD" \
AR="$AR_FOR_BUILD" \
CFLAGS="$CFLAGS_FOR_BUILD" \
CXXFLAGS="$CXXFLAGS_FOR_BUILD" \
LDFLAGS="$LDFLAGS_FOR_BUILD" \
python configure.py --bootstrap
python configure.py
source rebuild_args
'' + lib.optionalString buildDocs ''
# "./ninja -vn manual" output copied here to support cross compilation.
asciidoc -b docbook -d book -o build/manual.xml doc/manual.asciidoc