From 2d9d7377c8e21cedd49cd5a6810f0dcb42bf9b0e Mon Sep 17 00:00:00 2001 From: Antonius Naumann Date: Sun, 4 Aug 2024 16:48:38 +0200 Subject: [PATCH] Build stdlib for tier 3 targets --- src/targets.rs | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/targets.rs b/src/targets.rs index 95ff0fa..9ccf287 100644 --- a/src/targets.rs +++ b/src/targets.rs @@ -9,6 +9,10 @@ use crate::package::FeatureOptions; pub trait TargetInfo { fn target(&self) -> Target; + /// Marks whether a pre-built std-lib is provided for this target (Tier 1 and Tier 2) via rustup or target needs to + /// be build (Tier 3) + /// See: https://doc.rust-lang.org/nightly/rustc/platform-support.html + fn is_tier_3(&self) -> bool; } #[derive(Debug, Clone)] @@ -46,7 +50,8 @@ impl Target { self.architectures() .into_iter() .map(|arch| { - let mut cmd = command("cargo build"); + // FIXME: Remove nightly for Tier 3 targets here once build-std is stabilized + let mut cmd = if self.is_tier_3() { command("cargo +nightly build -Z build-std") } else { command("cargo build") }; cmd.arg("--target").arg(arch); match mode { @@ -66,8 +71,6 @@ impl Target { cmd.arg("--no-default-features"); } - // TODO: Add build-std here for experimental targets (= tier 3 targets) - cmd }) .collect() @@ -176,6 +179,10 @@ impl Target { library_file_name(lib_name, lib_type) ) } + + fn is_tier_3(&self) -> bool { + self.platform().is_tier_3() + } } pub fn library_file_name(lib_name: &str, lib_type: LibType) -> String { @@ -256,4 +263,14 @@ impl TargetInfo for ApplePlatform { }, } } + + fn is_tier_3(&self) -> bool { + match self { + ApplePlatform::IOS | ApplePlatform::IOSSimulator => false, + ApplePlatform::MacOS => false, + ApplePlatform::TvOS | ApplePlatform::TvOSSimulator => true, + ApplePlatform::WatchOS | ApplePlatform::WatchOSSimulator => true, + ApplePlatform::VisionOS | ApplePlatform::VisionOSSimulator => true, + } + } }