Merge pull request #216555 from jordanisaacs/rust-vendor

build-support/rust/lib: Add `toTargetVendor`
This commit is contained in:
John Ericson
2023-02-16 09:33:06 -05:00
committed by GitHub
+9 -4
View File
@@ -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}"}";