mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-22 06:53:01 +00:00
build-support/rust/lib: Add toTargetFamily
Taken from https://github.com/kolloch/crate2nix/pull/255/files, it belongs in Nixpkgs not crate2nix. I have been using that P.R. for a few months without incident.
This commit is contained in:
parent
550202ecdf
commit
e94d54dd86
@ -15,6 +15,21 @@ rec {
|
||||
else if platform.isDarwin then "macos"
|
||||
else platform.parsed.kernel.name;
|
||||
|
||||
# https://doc.rust-lang.org/reference/conditional-compilation.html#target_family
|
||||
toTargetFamily = platform:
|
||||
if platform ? rustc.platform.target-family
|
||||
then
|
||||
(
|
||||
# Since https://github.com/rust-lang/rust/pull/84072
|
||||
# `target-family` is a list instead of single value.
|
||||
let
|
||||
f = platform.rustc.platform.target-family;
|
||||
in
|
||||
if builtins.isList f then f else [ f ]
|
||||
)
|
||||
else lib.optional platform.isUnix "unix"
|
||||
++ lib.optional platform.isWindows "windows";
|
||||
|
||||
# Returns the name of the rust target, even if it is custom. Adjustments are
|
||||
# because rust has slightly different naming conventions than we do.
|
||||
toRustTarget = platform: let
|
||||
|
Loading…
Reference in New Issue
Block a user