diff options
author | github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> | 2023-10-03 18:01:51 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-03 18:01:51 +0000 |
commit | c020c1ab3c4e4dc02aea8845ba8580eea06c74a2 (patch) | |
tree | 02d218a968c46aba41a0b85a8786bd411c74e818 /pkgs/build-support | |
parent | 6d01ee4328c6a55c56d4ff639489064f8a8c79cd (diff) | |
parent | 1cbe5c3e8ba7ad5701291acce3ac78dadf388231 (diff) | |
download | nixpkgs-c020c1ab3c4e4dc02aea8845ba8580eea06c74a2.tar nixpkgs-c020c1ab3c4e4dc02aea8845ba8580eea06c74a2.tar.gz nixpkgs-c020c1ab3c4e4dc02aea8845ba8580eea06c74a2.tar.bz2 nixpkgs-c020c1ab3c4e4dc02aea8845ba8580eea06c74a2.tar.lz nixpkgs-c020c1ab3c4e4dc02aea8845ba8580eea06c74a2.tar.xz nixpkgs-c020c1ab3c4e4dc02aea8845ba8580eea06c74a2.tar.zst nixpkgs-c020c1ab3c4e4dc02aea8845ba8580eea06c74a2.zip |
Merge staging-next into staging
Diffstat (limited to 'pkgs/build-support')
-rw-r--r-- | pkgs/build-support/rust/build-rust-package/default.nix | 9 | ||||
-rw-r--r-- | pkgs/build-support/rust/hooks/default.nix | 17 | ||||
-rw-r--r-- | pkgs/build-support/rust/lib/default.nix | 11 |
3 files changed, 16 insertions, 21 deletions
diff --git a/pkgs/build-support/rust/build-rust-package/default.nix b/pkgs/build-support/rust/build-rust-package/default.nix index cb83a7bc95c..da868861e2c 100644 --- a/pkgs/build-support/rust/build-rust-package/default.nix +++ b/pkgs/build-support/rust/build-rust-package/default.nix @@ -82,14 +82,9 @@ let targetIsJSON = lib.hasSuffix ".json" target; useSysroot = targetIsJSON && !__internal_dontAddSysroot; - # see https://github.com/rust-lang/cargo/blob/964a16a28e234a3d397b2a7031d4ab4a428b1391/src/cargo/core/compiler/compile_kind.rs#L151-L168 - # the "${}" is needed to transform the path into a /nix/store path before baseNameOf - shortTarget = if targetIsJSON then - (lib.removeSuffix ".json" (builtins.baseNameOf "${target}")) - else target; - sysroot = callPackage ./sysroot { } { - inherit target shortTarget; + inherit target; + shortTarget = rust.lib.toRustTargetSpecShort stdenv.hostPlatform; RUSTFLAGS = args.RUSTFLAGS or ""; originalCargoToml = src + /Cargo.toml; # profile info is later extracted }; diff --git a/pkgs/build-support/rust/hooks/default.nix b/pkgs/build-support/rust/hooks/default.nix index cf06300096f..c73ec30082d 100644 --- a/pkgs/build-support/rust/hooks/default.nix +++ b/pkgs/build-support/rust/hooks/default.nix @@ -12,20 +12,11 @@ # This confusingly-named parameter indicates the *subdirectory of # `target/` from which to copy the build artifacts. It is derived -# from a stdenv platform (or a JSON file; see below). -, target ? rust.toRustTargetSpec stdenv.hostPlatform +# from a stdenv platform (or a JSON file). +, target ? rust.lib.toRustTargetSpecShort stdenv.hostPlatform }: -let - targetIsJSON = lib.hasSuffix ".json" target; - - # see https://github.com/rust-lang/cargo/blob/964a16a28e234a3d397b2a7031d4ab4a428b1391/src/cargo/core/compiler/compile_kind.rs#L151-L168 - # the "${}" is needed to transform the path into a /nix/store path before baseNameOf - targetSubdirectory = if targetIsJSON then - (lib.removeSuffix ".json" (builtins.baseNameOf "${target}")) - else target; - -in { +{ cargoBuildHook = callPackage ({ }: makeSetupHook { name = "cargo-build-hook.sh"; @@ -49,7 +40,7 @@ in { name = "cargo-install-hook.sh"; propagatedBuildInputs = [ ]; substitutions = { - inherit targetSubdirectory; + targetSubdirectory = target; }; } ./cargo-install-hook.sh) {}; diff --git a/pkgs/build-support/rust/lib/default.nix b/pkgs/build-support/rust/lib/default.nix index 8ca3758e514..ceca7323176 100644 --- a/pkgs/build-support/rust/lib/default.nix +++ b/pkgs/build-support/rust/lib/default.nix @@ -63,6 +63,15 @@ rec { then builtins.toFile (toRustTarget platform + ".json") (builtins.toJSON platform.rustc.platform) else toRustTarget platform; + # Returns the name of the rust target if it is standard, or the + # basename of the file containing the custom target spec, without + # the .json extension. + # + # This is the name used by Cargo for target subdirectories. + toRustTargetSpecShort = platform: + lib.removeSuffix ".json" + (baseNameOf "${toRustTargetSpec platform}"); + # When used as part of an environment variable name, triples are # uppercased and have all hyphens replaced by underscores: # @@ -72,7 +81,7 @@ rec { toRustTargetForUseInEnvVars = platform: lib.strings.replaceStrings ["-"] ["_"] (lib.strings.toUpper - (toRustTarget platform)); + (toRustTargetSpecShort platform)); # Returns true if the target is no_std # https://github.com/rust-lang/rust/blob/2e44c17c12cec45b6a682b1e53a04ac5b5fcc9d2/src/bootstrap/config.rs#L415-L421 |