mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-11-20 08:59:32 +03:00
Merge pull request #55972 from andir/rust-editions
buildRustCrate support editions
This commit is contained in:
commit
8b20328230
@ -8,11 +8,11 @@
|
||||
let
|
||||
|
||||
deps = makeDeps dependencies;
|
||||
rustcOpts =
|
||||
lib.lists.foldl' (opts: opt: opts + " " + opt)
|
||||
(if release then "-C opt-level=3" else "-C debuginfo=2")
|
||||
(["-C codegen-units=1"] ++ extraRustcOpts);
|
||||
rustcMeta = "-C metadata=${metadata} -C extra-filename=-${metadata}";
|
||||
rustcOpts =
|
||||
lib.lists.foldl' (opts: opt: opts + " " + opt)
|
||||
(if release then "-C opt-level=3" else "-C debuginfo=2")
|
||||
(["-C codegen-units=1"] ++ extraRustcOpts);
|
||||
rustcMeta = "-C metadata=${metadata} -C extra-filename=-${metadata}";
|
||||
|
||||
# Some platforms have different names for rustc.
|
||||
rustPlatform =
|
||||
|
@ -1,9 +1,27 @@
|
||||
{ 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;
|
||||
versionPre = if lib.tail version_ == [] then "" else builtins.elemAt version_ 1;
|
||||
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;
|
||||
authors = lib.concatStringsSep ":" crateAuthors;
|
||||
optLevel = if release then 3 else 0;
|
||||
|
@ -71,7 +71,7 @@ let crate = crate_ // (lib.attrByPath [ crate_.crateName ] (attr: {}) crateOverr
|
||||
processedAttrs = [
|
||||
"src" "buildInputs" "crateBin" "crateLib" "libName" "libPath"
|
||||
"buildDependencies" "dependencies" "features"
|
||||
"crateName" "version" "build" "authors" "colors"
|
||||
"crateName" "version" "build" "authors" "colors" "edition"
|
||||
];
|
||||
extraDerivationAttrs = lib.filterAttrs (n: v: ! lib.elem n processedAttrs) crate;
|
||||
buildInputs_ = buildInputs;
|
||||
@ -136,13 +136,15 @@ stdenv.mkDerivation (rec {
|
||||
(crate.type or ["lib"]);
|
||||
colors = lib.attrByPath [ "colors" ] "always" crate;
|
||||
extraLinkFlags = builtins.concatStringsSep " " (crate.extraLinkFlags or []);
|
||||
edition = crate.edition or null;
|
||||
extraRustcOpts = (if crate ? extraRustcOpts then crate.extraRustcOpts else []) ++ extraRustcOpts_ ++ (lib.optional (edition != null) "--edition ${edition}");
|
||||
|
||||
configurePhase = configureCrate {
|
||||
inherit crateName buildDependencies completeDeps completeBuildDeps
|
||||
crateFeatures libName build workspace_member release libPath crateVersion
|
||||
extraLinkFlags
|
||||
extraLinkFlags extraRustcOpts
|
||||
crateAuthors verbose colors target_os;
|
||||
};
|
||||
extraRustcOpts = (if crate ? extraRustcOpts then crate.extraRustcOpts else []) ++ extraRustcOpts_;
|
||||
buildPhase = buildCrate {
|
||||
inherit crateName dependencies
|
||||
crateFeatures libName release libPath crateType
|
||||
|
Loading…
Reference in New Issue
Block a user