mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-12 04:35:41 +03:00
buildRustCrate: pass extraRustcOpts to configure crate
Previously build flags would not be available during the configure phase while they might be required to build the `build.rs` file.
This commit is contained in:
parent
5d42605b91
commit
044a8a24ed
3 changed files with 27 additions and 9 deletions
|
@ -8,11 +8,11 @@
|
||||||
let
|
let
|
||||||
|
|
||||||
deps = makeDeps dependencies;
|
deps = makeDeps dependencies;
|
||||||
rustcOpts =
|
rustcOpts =
|
||||||
lib.lists.foldl' (opts: opt: opts + " " + opt)
|
lib.lists.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=1"] ++ extraRustcOpts);
|
(["-C codegen-units=1"] ++ extraRustcOpts);
|
||||||
rustcMeta = "-C metadata=${metadata} -C extra-filename=-${metadata}";
|
rustcMeta = "-C metadata=${metadata} -C extra-filename=-${metadata}";
|
||||||
|
|
||||||
# Some platforms have different names for rustc.
|
# Some platforms have different names for rustc.
|
||||||
rustPlatform =
|
rustPlatform =
|
||||||
|
|
|
@ -1,9 +1,27 @@
|
||||||
{ lib, stdenv, echo_build_heading, noisily, makeDeps }:
|
{ lib, stdenv, echo_build_heading, noisily, makeDeps }:
|
||||||
{ build, buildDependencies, colors, completeBuildDeps, completeDeps, crateAuthors, crateFeatures, crateName, crateVersion, extraLinkFlags, libName, libPath, release, target_os, verbose, workspace_member }:
|
{ build
|
||||||
|
, buildDependencies
|
||||||
|
, colors
|
||||||
|
, completeBuildDeps
|
||||||
|
, completeDeps
|
||||||
|
, crateAuthors
|
||||||
|
, crateFeatures
|
||||||
|
, crateName
|
||||||
|
, crateVersion
|
||||||
|
, extraLinkFlags
|
||||||
|
, extraRustcOpts
|
||||||
|
, libName
|
||||||
|
, libPath
|
||||||
|
, release
|
||||||
|
, target_os
|
||||||
|
, verbose
|
||||||
|
, workspace_member }:
|
||||||
let version_ = lib.splitString "-" crateVersion;
|
let version_ = lib.splitString "-" crateVersion;
|
||||||
versionPre = if lib.tail version_ == [] then "" else builtins.elemAt version_ 1;
|
versionPre = if lib.tail version_ == [] then "" else builtins.elemAt version_ 1;
|
||||||
version = lib.splitString "." (lib.head version_);
|
version = lib.splitString "." (lib.head version_);
|
||||||
rustcOpts = (if release then "-C opt-level=3" else "-C debuginfo=2");
|
rustcOpts = lib.lists.foldl' (opts: opt: opts + " " + opt)
|
||||||
|
(if release then "-C opt-level=3" else "-C debuginfo=2")
|
||||||
|
(["-C codegen-units=1"] ++ extraRustcOpts);
|
||||||
buildDeps = makeDeps buildDependencies;
|
buildDeps = makeDeps buildDependencies;
|
||||||
authors = lib.concatStringsSep ":" crateAuthors;
|
authors = lib.concatStringsSep ":" crateAuthors;
|
||||||
optLevel = if release then 3 else 0;
|
optLevel = if release then 3 else 0;
|
||||||
|
|
|
@ -136,13 +136,13 @@ stdenv.mkDerivation (rec {
|
||||||
(crate.type or ["lib"]);
|
(crate.type or ["lib"]);
|
||||||
colors = lib.attrByPath [ "colors" ] "always" crate;
|
colors = lib.attrByPath [ "colors" ] "always" crate;
|
||||||
extraLinkFlags = builtins.concatStringsSep " " (crate.extraLinkFlags or []);
|
extraLinkFlags = builtins.concatStringsSep " " (crate.extraLinkFlags or []);
|
||||||
|
extraRustcOpts = (if crate ? extraRustcOpts then crate.extraRustcOpts else []) ++ extraRustcOpts_;
|
||||||
configurePhase = configureCrate {
|
configurePhase = configureCrate {
|
||||||
inherit crateName buildDependencies completeDeps completeBuildDeps
|
inherit crateName buildDependencies completeDeps completeBuildDeps
|
||||||
crateFeatures libName build workspace_member release libPath crateVersion
|
crateFeatures libName build workspace_member release libPath crateVersion
|
||||||
extraLinkFlags
|
extraLinkFlags extraRustcOpts
|
||||||
crateAuthors verbose colors target_os;
|
crateAuthors verbose colors target_os;
|
||||||
};
|
};
|
||||||
extraRustcOpts = (if crate ? extraRustcOpts then crate.extraRustcOpts else []) ++ extraRustcOpts_;
|
|
||||||
buildPhase = buildCrate {
|
buildPhase = buildCrate {
|
||||||
inherit crateName dependencies
|
inherit crateName dependencies
|
||||||
crateFeatures libName release libPath crateType
|
crateFeatures libName release libPath crateType
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue