std-rs 0.30.1

Rust port of EPICS std module (epid, throttle, timestamp records)
Documentation
//! Derives this crate's own copy of the `exec_backend` / `tokio_backend` cfg,
//! the way `epics-libcom-rs` (the original), `epics-base-rs`, `epics-ca-rs`
//! and `epics-pva-rs` derive theirs.
//!
//! The std integration tests drive epid/throttle/timestamp through a real CA
//! server's put gate and its monitor path, which need the reactor.
//!
//! A cfg set by a dependency's build script is not visible here, so every
//! crate that gates on the pair derives it again from the same two inputs:
//! `EPICS_RS_BUILD_EXEC_BACKEND` and the target OS. Reading the variable alone
//! would be wrong on exactly the case the workspace predicate exists for: on
//! RTEMS and VxWorks it is unset while `exec_backend` is ON.
fn main() {
    println!("cargo::rustc-check-cfg=cfg(exec_backend)");
    println!("cargo::rustc-check-cfg=cfg(tokio_backend)");
    println!("cargo::rustc-check-cfg=cfg(epics_embedded_target)");

    let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap_or_default();
    let embedded_target = matches!(target_os.as_str(), "rtems" | "vxworks");
    if embedded_target {
        println!("cargo::rustc-cfg=epics_embedded_target");
    }

    // Build-time backend selection, from the environment rather than from a
    // cargo feature: a feature that flips a backend is not additive, so
    // `--all-features` turned the reactor off and no single invocation meant
    // "everything on". `epics-libcom-rs`'s module docs carry the reasoning;
    // `tools/rtems-exec-gate` holds every copy of this block against that
    // crate's, so 23 derivations of one rule cannot drift apart.
    println!("cargo::rerun-if-env-changed=EPICS_RS_BUILD_EXEC_BACKEND");
    let requested = std::env::var_os("EPICS_RS_BUILD_EXEC_BACKEND").unwrap_or_default();
    let host_exec_backend = match requested.to_string_lossy().as_ref() {
        "thread" => true,
        "" | "tokio" => false,
        bad => panic!(
            "EPICS_RS_BUILD_EXEC_BACKEND={bad}: the exec backend is `thread` \
             (reactor-free std threads) or `tokio` (the host default, which an \
             unset or empty variable also selects)"
        ),
    };
    if embedded_target || host_exec_backend {
        println!("cargo::rustc-cfg=exec_backend");
    } else {
        println!("cargo::rustc-cfg=tokio_backend");
    }
}