diff --git a/build.rs b/build.rs index 512c6ee828..93d3a53907 100644 --- a/build.rs +++ b/build.rs @@ -569,6 +569,15 @@ fn static_lib_url() -> String { let target = env::var("TARGET").unwrap(); let profile = prebuilt_profile(); let features = prebuilt_features_suffix(); + + if env::var("RUSTY_V8_MIRROR").is_err() + && !is_target_prebuilt(&target, profile) + { + panic!( + "The target '{target}' is not a first class target and no pre-built archive is provided. Compile v8 from source with V8_FROM_SOURCE=1" + ) + } + format!( "{base}/v{version}/{}.gz", static_lib_name(&format!("{features}_{profile}_{target}")), @@ -610,6 +619,26 @@ fn build_dir() -> PathBuf { .to_path_buf() } +/// Checks if the target is available as a pre-built archive from the rusty_v8 GitHub. +/// Should only be called when `RUSTY_V8_MIRROR` is unset. +fn is_target_prebuilt(target: &str, profile: &str) -> bool { + const PREBUILT_TARGETS: [&str; 6] = [ + "aarch64-apple-darwin", + "aarch64-pc-windows-msvc", + "aarch64-unknown-linux-gnu", + "x86_64-apple-darwin", + "x86_64-pc-windows-msvc", + "x86_64-unknown-linux-gnu", + ]; + + // No pre-built archives for Windows on debug builds. + if target.contains("windows") && profile != "release" { + return false; + } + + PREBUILT_TARGETS.contains(&target) +} + fn replace_non_alphanumeric(url: &str) -> String { url .chars()