rust: Add support for managing target JSON in Nix
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
++ [(mkRustcDepArgs dependencies crateRenames)]
|
||||
++ [(mkRustcFeatureArgs crateFeatures)]
|
||||
++ extraRustcOpts
|
||||
++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) "--target ${rust.toRustTarget stdenv.hostPlatform} -C linker=${stdenv.hostPlatform.config}-gcc"
|
||||
++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) "--target ${rust.toRustTargetSpec stdenv.hostPlatform} -C linker=${stdenv.hostPlatform.config}-gcc"
|
||||
# since rustc 1.42 the "proc_macro" crate is part of the default crate prelude
|
||||
# https://github.com/rust-lang/cargo/commit/4d64eb99a4#diff-7f98585dbf9d30aa100c8318e2c77e79R1021-R1022
|
||||
++ lib.optional (lib.elem "proc-macro" crateType) "--extern proc_macro"
|
||||
|
||||
@@ -135,8 +135,8 @@ in ''
|
||||
export CARGO_MANIFEST_DIR=$(pwd)
|
||||
export DEBUG="${toString (!release)}"
|
||||
export OPT_LEVEL="${toString optLevel}"
|
||||
export TARGET="${rust.toRustTarget stdenv.hostPlatform}"
|
||||
export HOST="${rust.toRustTarget stdenv.buildPlatform}"
|
||||
export TARGET="${rust.toRustTargetSpec stdenv.hostPlatform}"
|
||||
export HOST="${rust.toRustTargetSpec stdenv.buildPlatform}"
|
||||
export PROFILE=${if release then "release" else "debug"}
|
||||
export OUT_DIR=$(pwd)/target/build/${crateName}.out
|
||||
export CARGO_PKG_VERSION_MAJOR=${lib.elemAt version 0}
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
, cargoBuildFlags ? []
|
||||
, buildType ? "release"
|
||||
, meta ? {}
|
||||
, target ? rust.toRustTarget stdenv.hostPlatform
|
||||
, target ? rust.toRustTargetSpec stdenv.hostPlatform
|
||||
, cargoVendorDir ? null
|
||||
, checkType ? buildType
|
||||
, depsExtraArgs ? {}
|
||||
|
||||
@@ -41,7 +41,7 @@ in rustPlatform.buildRustPackage {
|
||||
done
|
||||
|
||||
export RUST_SYSROOT=$(rustc --print=sysroot)
|
||||
export HOST=${rust.toRustTarget stdenv.buildPlatform}
|
||||
cp -r $RUST_SYSROOT/lib/rustlib/$HOST $out
|
||||
host=${rust.toRustTarget stdenv.buildPlatform}
|
||||
cp -r $RUST_SYSROOT/lib/rustlib/$host $out
|
||||
'';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user