use std::collections::BTreeMap;
use std::env;
const PREFIX: &str = "DEP_OLIPHAUNT_ARTIFACT_";
const RELAY_PREFIX: &str = "DEP_OLIPHAUNT_ARTIFACT_RELAY_";
const SUFFIX: &str = "_MANIFEST";
fn main() {
let mut manifests = BTreeMap::new();
for (key, value) in env::vars() {
if value.is_empty() || key.starts_with(RELAY_PREFIX) {
continue;
}
let Some(stem) = key.strip_prefix(PREFIX).and_then(|value| value.strip_suffix(SUFFIX)) else {
continue;
};
if stem.is_empty() {
panic!("empty Oliphaunt artifact metadata stem");
}
if let Some(previous) = manifests.insert(stem.to_ascii_lowercase(), value.clone()) {
if previous != value {
panic!("conflicting Oliphaunt extension leaf manifests for {stem}");
}
}
println!("cargo::rerun-if-changed={value}");
}
if manifests.is_empty() && env::var_os("OLIPHAUNT_ARTIFACT_CRATE_REQUIRE_PAYLOAD").is_some() {
panic!("extension facade resolved no target-leaf artifact manifest");
}
for (stem, manifest) in manifests {
println!("cargo::metadata={stem}_manifest={manifest}");
}
}