Skip to content

Commit

Permalink
Build stdlib for tier 3 targets
Browse files Browse the repository at this point in the history
  • Loading branch information
antoniusnaumann committed Aug 4, 2024
1 parent f60921c commit 2d9d737
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions src/targets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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 {
Expand All @@ -66,8 +71,6 @@ impl Target {
cmd.arg("--no-default-features");
}

// TODO: Add build-std here for experimental targets (= tier 3 targets)

cmd
})
.collect()
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
}
}
}

0 comments on commit 2d9d737

Please sign in to comment.