buildRustPackage: support cross-compilation to x86_64-pc-mingw32
This commit is contained in:
parent
ddf15d321f
commit
0fcffe88db
|
@ -41,12 +41,20 @@ let
|
|||
cargoDepsCopy="$sourceRoot/${cargoVendorDir}"
|
||||
'';
|
||||
|
||||
hostConfig = stdenv.hostPlatform.config;
|
||||
|
||||
rustHostConfig = {
|
||||
"x86_64-pc-mingw32" = "x86_64-pc-windows-gnu";
|
||||
}."${hostConfig}" or hostConfig;
|
||||
|
||||
ccForBuild="${buildPackages.stdenv.cc}/bin/${buildPackages.stdenv.cc.targetPrefix}cc";
|
||||
cxxForBuild="${buildPackages.stdenv.cc}/bin/${buildPackages.stdenv.cc.targetPrefix}c++";
|
||||
ccForHost="${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc";
|
||||
cxxForHost="${stdenv.cc}/bin/${stdenv.cc.targetPrefix}c++";
|
||||
releaseDir = "target/${stdenv.hostPlatform.config}/${buildType}";
|
||||
in stdenv.mkDerivation (args // {
|
||||
releaseDir = "target/${rustHostConfig}/${buildType}";
|
||||
in
|
||||
|
||||
stdenv.mkDerivation (args // {
|
||||
inherit cargoDeps;
|
||||
|
||||
patchRegistryDeps = ./patch-registry-deps;
|
||||
|
@ -84,7 +92,7 @@ in stdenv.mkDerivation (args // {
|
|||
[target."${stdenv.buildPlatform.config}"]
|
||||
"linker" = "${ccForBuild}"
|
||||
${stdenv.lib.optionalString (stdenv.buildPlatform.config != stdenv.hostPlatform.config) ''
|
||||
[target."${stdenv.hostPlatform.config}"]
|
||||
[target."${rustHostConfig}"]
|
||||
"linker" = "${ccForHost}"
|
||||
''}
|
||||
EOF
|
||||
|
@ -104,7 +112,7 @@ in stdenv.mkDerivation (args // {
|
|||
"CXX_${stdenv.hostPlatform.config}"="${cxxForHost}" \
|
||||
cargo build \
|
||||
${stdenv.lib.optionalString (buildType == "release") "--release"} \
|
||||
--target ${stdenv.hostPlatform.config} \
|
||||
--target ${rustHostConfig} \
|
||||
--frozen ${concatStringsSep " " cargoBuildFlags}
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in New Issue