diff --git a/Cargo.lock b/Cargo.lock index fd33148f2f6..349fd29505b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -616,10 +616,12 @@ dependencies = [ name = "diplomat-coverage" version = "0.0.0" dependencies = [ + "basic-toml", "diplomat_core", "elsa", "lazy_static", "rustdoc-types", + "serde", "serde_json", "syn-inline-mod", ] diff --git a/tools/make/diplomat-coverage/Cargo.toml b/tools/make/diplomat-coverage/Cargo.toml index 96c67f7762a..37c95fa67a2 100644 --- a/tools/make/diplomat-coverage/Cargo.toml +++ b/tools/make/diplomat-coverage/Cargo.toml @@ -16,3 +16,6 @@ rustdoc-types = "0.22" serde_json = { workspace = true } syn-inline-mod = "0.6.0" +[build-dependencies] +basic-toml = "0.1" +serde = { version = "1", features = ["derive"] } diff --git a/tools/make/diplomat-coverage/build.rs b/tools/make/diplomat-coverage/build.rs new file mode 100644 index 00000000000..e088e7a3842 --- /dev/null +++ b/tools/make/diplomat-coverage/build.rs @@ -0,0 +1,27 @@ +// This file is part of ICU4X. For terms of use, please see the file +// called LICENSE at the top level of the ICU4X source tree +// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). + +const TOML_STR: &str = include_str!("../../../Makefile.toml"); + +#[derive(serde::Deserialize)] +struct Outer { + env: Middle +} + +#[derive(serde::Deserialize)] +struct Middle { + #[serde(rename = "PINNED_CI_NIGHTLY")] + pinned_ci_nightly: Inner, +} + +#[derive(serde::Deserialize)] +struct Inner { + value: String, +} + +fn main() { + let deserialized = basic_toml::from_str::(TOML_STR).unwrap(); + let nightly = deserialized.env.pinned_ci_nightly.value; + println!("cargo::rustc-env=ICU4X_DIPLOMAT_COVERAGE_NIGHTLY={nightly}"); +} diff --git a/tools/make/diplomat-coverage/src/main.rs b/tools/make/diplomat-coverage/src/main.rs index 76fda3992d2..238b85123c1 100644 --- a/tools/make/diplomat-coverage/src/main.rs +++ b/tools/make/diplomat-coverage/src/main.rs @@ -99,13 +99,13 @@ fn collect_public_types(krate: &str) -> impl Iterator, ast:: if CRATES.get(krate).is_none() { eprintln!("Parsing crate {krate}"); std::process::Command::new("rustup") - .args(["install", "nightly-2023-08-08"]) + .args(["install", std::env!("ICU4X_DIPLOMAT_COVERAGE_NIGHTLY")]) .output() .expect("failed to install nightly"); let output = std::process::Command::new("rustup") .args([ "run", - "nightly-2023-08-08", + std::env!("ICU4X_DIPLOMAT_COVERAGE_NIGHTLY"), "cargo", "rustdoc", "-Zsparse-registry",