build-support/rust/lib: make arch and os functions respect target JSON
This commit is contained in:
parent
838618957b
commit
39811b1da9
1 changed files with 5 additions and 3 deletions
|
@ -3,12 +3,14 @@
|
||||||
rec {
|
rec {
|
||||||
# https://doc.rust-lang.org/reference/conditional-compilation.html#target_arch
|
# https://doc.rust-lang.org/reference/conditional-compilation.html#target_arch
|
||||||
toTargetArch = platform:
|
toTargetArch = platform:
|
||||||
if platform.isAarch32 then "arm"
|
/**/ if platform ? rustc.platform then platform.rustc.platform.arch
|
||||||
|
else if platform.isAarch32 then "arm"
|
||||||
else platform.parsed.cpu.name;
|
else platform.parsed.cpu.name;
|
||||||
|
|
||||||
# https://doc.rust-lang.org/reference/conditional-compilation.html#target_os
|
# https://doc.rust-lang.org/reference/conditional-compilation.html#target_os
|
||||||
toTargetOs = platform:
|
toTargetOs = platform:
|
||||||
if platform.isDarwin then "macos"
|
/**/ if platform ? rustc.platform then platform.rustc.platform.os or "none"
|
||||||
|
else if platform.isDarwin then "macos"
|
||||||
else platform.parsed.kernel.name;
|
else platform.parsed.kernel.name;
|
||||||
|
|
||||||
# Returns the name of the rust target, even if it is custom. Adjustments are
|
# Returns the name of the rust target, even if it is custom. Adjustments are
|
||||||
|
@ -31,7 +33,7 @@ rec {
|
||||||
# Returns the name of the rust target if it is standard, or the json file
|
# Returns the name of the rust target if it is standard, or the json file
|
||||||
# containing the custom target spec.
|
# containing the custom target spec.
|
||||||
toRustTargetSpec = platform:
|
toRustTargetSpec = platform:
|
||||||
if (platform.rustc or {}) ? platform
|
if platform ? rustc.platform
|
||||||
then builtins.toFile (toRustTarget platform + ".json") (builtins.toJSON platform.rustc.platform)
|
then builtins.toFile (toRustTarget platform + ".json") (builtins.toJSON platform.rustc.platform)
|
||||||
else toRustTarget platform;
|
else toRustTarget platform;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue