buildRustPackage: factor out build phase to cargoBuildHook
- API change: remove the `target` argument of `buildRustPackage`, the target should always be in sync with the C/C++ compiler that is used. - Gathering of binaries has moved from `buildPhase` to `installPhase`, this simplifies the hook and orders this functionality logically with the installation logic.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
{ buildPackages
|
||||
, callPackage
|
||||
, cargo
|
||||
, diffutils
|
||||
, lib
|
||||
, makeSetupHook
|
||||
@@ -16,9 +17,24 @@ let
|
||||
shortTarget = if targetIsJSON then
|
||||
(lib.removeSuffix ".json" (builtins.baseNameOf "${target}"))
|
||||
else target;
|
||||
ccForBuild="${buildPackages.stdenv.cc}/bin/${buildPackages.stdenv.cc.targetPrefix}cc";
|
||||
ccForHost="${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc";
|
||||
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++";
|
||||
rustBuildPlatform = rust.toRustTarget stdenv.buildPlatform;
|
||||
rustTargetPlatform = rust.toRustTarget stdenv.hostPlatform;
|
||||
rustTargetPlatformSpec = rust.toRustTargetSpec stdenv.hostPlatform;
|
||||
in {
|
||||
cargoBuildHook = callPackage ({ }:
|
||||
makeSetupHook {
|
||||
name = "cargo-build-hook.sh";
|
||||
deps = [ cargo ];
|
||||
substitutions = {
|
||||
inherit ccForBuild ccForHost cxxForBuild cxxForHost
|
||||
rustBuildPlatform rustTargetPlatform rustTargetPlatformSpec;
|
||||
};
|
||||
} ./cargo-build-hook.sh) {};
|
||||
|
||||
cargoSetupHook = callPackage ({ }:
|
||||
makeSetupHook {
|
||||
name = "cargo-setup-hook.sh";
|
||||
|
||||
Reference in New Issue
Block a user