mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-22 23:13:19 +00:00
buildRustCrate: Add extraRustcOptsForBuild
`extraRustcOpts` should not be used for build.rs, lest it contain host-platform-specific options during cross builds.
This commit is contained in:
parent
0ee5640d78
commit
4430761186
@ -13,7 +13,7 @@
|
|||||||
, crateRenames
|
, crateRenames
|
||||||
, crateVersion
|
, crateVersion
|
||||||
, extraLinkFlags
|
, extraLinkFlags
|
||||||
, extraRustcOpts
|
, extraRustcOptsForBuildRs
|
||||||
, libName
|
, libName
|
||||||
, libPath
|
, libPath
|
||||||
, release
|
, release
|
||||||
@ -24,7 +24,7 @@ let version_ = lib.splitString "-" crateVersion;
|
|||||||
version = lib.splitVersion (lib.head version_);
|
version = lib.splitVersion (lib.head version_);
|
||||||
rustcOpts = lib.foldl' (opts: opt: opts + " " + opt)
|
rustcOpts = lib.foldl' (opts: opt: opts + " " + opt)
|
||||||
(if release then "-C opt-level=3" else "-C debuginfo=2")
|
(if release then "-C opt-level=3" else "-C debuginfo=2")
|
||||||
(["-C codegen-units=$NIX_BUILD_CORES"] ++ extraRustcOpts);
|
(["-C codegen-units=$NIX_BUILD_CORES"] ++ extraRustcOptsForBuildRs);
|
||||||
buildDeps = mkRustcDepArgs buildDependencies crateRenames;
|
buildDeps = mkRustcDepArgs buildDependencies crateRenames;
|
||||||
authors = lib.concatStringsSep ":" crateAuthors;
|
authors = lib.concatStringsSep ":" crateAuthors;
|
||||||
optLevel = if release then 3 else 0;
|
optLevel = if release then 3 else 0;
|
||||||
|
@ -172,6 +172,11 @@ crate_: lib.makeOverridable
|
|||||||
# Example: [ "-Z debuginfo=2" ]
|
# Example: [ "-Z debuginfo=2" ]
|
||||||
# Default: []
|
# Default: []
|
||||||
, extraRustcOpts
|
, extraRustcOpts
|
||||||
|
# A list of extra options to pass to rustc when building a build.rs.
|
||||||
|
#
|
||||||
|
# Example: [ "-Z debuginfo=2" ]
|
||||||
|
# Default: []
|
||||||
|
, extraRustcOptsForBuildRs
|
||||||
# Whether to enable building tests.
|
# Whether to enable building tests.
|
||||||
# Use true to enable.
|
# Use true to enable.
|
||||||
# Default: false
|
# Default: false
|
||||||
@ -228,6 +233,7 @@ crate_: lib.makeOverridable
|
|||||||
nativeBuildInputs_ = nativeBuildInputs;
|
nativeBuildInputs_ = nativeBuildInputs;
|
||||||
buildInputs_ = buildInputs;
|
buildInputs_ = buildInputs;
|
||||||
extraRustcOpts_ = extraRustcOpts;
|
extraRustcOpts_ = extraRustcOpts;
|
||||||
|
extraRustcOptsForBuildRs_ = extraRustcOptsForBuildRs;
|
||||||
buildTests_ = buildTests;
|
buildTests_ = buildTests;
|
||||||
|
|
||||||
# crate2nix has a hack for the old bash based build script that did split
|
# crate2nix has a hack for the old bash based build script that did split
|
||||||
@ -308,12 +314,16 @@ crate_: lib.makeOverridable
|
|||||||
lib.optionals (crate ? extraRustcOpts) crate.extraRustcOpts
|
lib.optionals (crate ? extraRustcOpts) crate.extraRustcOpts
|
||||||
++ extraRustcOpts_
|
++ extraRustcOpts_
|
||||||
++ (lib.optional (edition != null) "--edition ${edition}");
|
++ (lib.optional (edition != null) "--edition ${edition}");
|
||||||
|
extraRustcOptsForBuildRs =
|
||||||
|
lib.optionals (crate ? extraRustcOptsForBuildRs) crate.extraRustcOptsForBuildRs
|
||||||
|
++ extraRustcOptsForBuildRs_
|
||||||
|
++ (lib.optional (edition != null) "--edition ${edition}");
|
||||||
|
|
||||||
|
|
||||||
configurePhase = configureCrate {
|
configurePhase = configureCrate {
|
||||||
inherit crateName buildDependencies completeDeps completeBuildDeps crateDescription
|
inherit crateName buildDependencies completeDeps completeBuildDeps crateDescription
|
||||||
crateFeatures crateRenames libName build workspace_member release libPath crateVersion
|
crateFeatures crateRenames libName build workspace_member release libPath crateVersion
|
||||||
extraLinkFlags extraRustcOpts
|
extraLinkFlags extraRustcOptsForBuildRs
|
||||||
crateAuthors crateHomepage verbose colors;
|
crateAuthors crateHomepage verbose colors;
|
||||||
};
|
};
|
||||||
buildPhase = buildCrate {
|
buildPhase = buildCrate {
|
||||||
@ -337,6 +347,7 @@ crate_: lib.makeOverridable
|
|||||||
release = crate_.release or true;
|
release = crate_.release or true;
|
||||||
verbose = crate_.verbose or true;
|
verbose = crate_.verbose or true;
|
||||||
extraRustcOpts = [ ];
|
extraRustcOpts = [ ];
|
||||||
|
extraRustcOptsForBuildRs = [ ];
|
||||||
features = [ ];
|
features = [ ];
|
||||||
nativeBuildInputs = [ ];
|
nativeBuildInputs = [ ];
|
||||||
buildInputs = [ ];
|
buildInputs = [ ];
|
||||||
|
Loading…
Reference in New Issue
Block a user