forked from mirrors/nixpkgs
build-support/rust/lib: Add toTargetVendor
Used in cases where you need to get the vendor of a target. Such as when you need to perform dependency resolution outside of Cargo (eg in Kolloch's crate2nix).
This commit is contained in:
parent
73a87e9c04
commit
66dccd88b8
|
@ -30,10 +30,17 @@ rec {
|
|||
else lib.optional platform.isUnix "unix"
|
||||
++ lib.optional platform.isWindows "windows";
|
||||
|
||||
# https://doc.rust-lang.org/reference/conditional-compilation.html#target_vendor
|
||||
toTargetVendor = platform: let
|
||||
inherit (platform.parsed) vendor;
|
||||
in platform.rustc.platform.vendor or {
|
||||
"w64" = "pc";
|
||||
}.${vendor.name} or vendor.name;
|
||||
|
||||
# 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
|
||||
inherit (platform.parsed) cpu vendor kernel abi;
|
||||
inherit (platform.parsed) cpu kernel abi;
|
||||
cpu_ = platform.rustc.platform.arch or {
|
||||
"armv7a" = "armv7";
|
||||
"armv7l" = "armv7";
|
||||
|
@ -41,9 +48,7 @@ rec {
|
|||
"armv5tel" = "armv5te";
|
||||
"riscv64" = "riscv64gc";
|
||||
}.${cpu.name} or cpu.name;
|
||||
vendor_ = platform.rustc.platform.vendor or {
|
||||
"w64" = "pc";
|
||||
}.${vendor.name} or vendor.name;
|
||||
vendor_ = toTargetVendor platform;
|
||||
in platform.rustc.config
|
||||
or "${cpu_}-${vendor_}-${kernel.name}${lib.optionalString (abi.name != "unknown") "-${abi.name}"}";
|
||||
|
||||
|
|
Loading…
Reference in a new issue