rust: Add support for managing target JSON in Nix
This commit is contained in:
@@ -24,7 +24,8 @@
|
||||
if platform.isDarwin then "macos"
|
||||
else platform.parsed.kernel.name;
|
||||
|
||||
# Target triple. Rust has slightly different naming conventions than we use.
|
||||
# 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: with platform.parsed; let
|
||||
cpu_ = platform.rustc.arch or {
|
||||
"armv7a" = "armv7";
|
||||
@@ -34,6 +35,13 @@
|
||||
in platform.rustc.config
|
||||
or "${cpu_}-${vendor.name}-${kernel.name}${lib.optionalString (abi.name != "unknown") "-${abi.name}"}";
|
||||
|
||||
# Returns the name of the rust target if it is standard, or the json file
|
||||
# containing the custom target spec.
|
||||
toRustTargetSpec = platform:
|
||||
if (platform.rustc.arch or {}) ? custom
|
||||
then builtins.toFile (platform.rustc.config + ".json") (builtins.toJSON platform.rustc.arch.custom)
|
||||
else toRustTarget platform;
|
||||
|
||||
# This just contains tools for now. But it would conceivably contain
|
||||
# libraries too, say if we picked some default/recommended versions from
|
||||
# `cratesIO` to build by Hydra and/or try to prefer/bias in Cargo.lock for
|
||||
|
||||
Reference in New Issue
Block a user