melinoe 0.10.0

Zero-sized, branded, multi-token phantom capabilities for compile-time data-access and thread-synchronization proofs (a generalized evolution of GhostCell) for the Mnemosyne memory ecosystem.
Documentation
//! Build script to dynamically detect toolchain capabilities for the Melinoe crate.
//!
//! Specifically, this detects whether we are on a nightly toolchain or docs.rs
//! to determine if we should enable unstable features like `doc_cfg`.

use std::{env, process::Command};

/// Main entry point of the build script.
fn main() {
    println!("cargo:rustc-check-cfg=cfg(doc_cfg_active)");
    println!("cargo:rustc-check-cfg=cfg(nightly_tls_active)");
    println!("cargo:rerun-if-changed=build.rs");

    let is_nightly_feature = env::var_os("CARGO_FEATURE_NIGHTLY").is_some();
    let is_docsrs = env::var_os("CARGO_CFG_DOCSRS").is_some();

    let rustc = env::var_os("RUSTC").unwrap_or_else(|| "rustc".into());
    let Ok(output) = Command::new(rustc).arg("-vV").output() else {
        return;
    };
    if !output.status.success() {
        return;
    }

    let version = String::from_utf8_lossy(&output.stdout);
    let is_nightly_compiler = version
        .lines()
        .any(|line| match line.strip_prefix("release: ") {
            Some(release) => release.contains("nightly"),
            None => false,
        });

    if (is_nightly_compiler && is_nightly_feature) || is_docsrs {
        println!("cargo:rustc-cfg=doc_cfg_active");
    }
    if is_nightly_compiler {
        println!("cargo:rustc-cfg=nightly_tls_active");
    }
}