Skip to content

Open-source download manager & offline media toolbox for YouTube, music, social media, learning platforms & 1,800+ sites. Built with Tauri 2.0, Rust & Svelte.

1.0 KB
Raw Blame
use std::process::Command;

// Capture the exact rustc that compiles this crate. Rust has no stable ABI:
// trait-object vtables, fat-pointer calling conventions and std type layouts
// may all change between compiler releases, so a plugin dylib is only safe to
// load into a host built by the *same* rustc. The version string (including
// the commit hash) is embedded in BUILD_INFO and exchanged through the
// `libreget_plugin_build_info` handshake symbol at load time.
fn main() {
    // Cargo sets RUSTC to the compiler used for the build.
    let rustc = std::env::var("RUSTC").unwrap_or_else(|_| "rustc".to_string());
    let version = Command::new(&rustc)
        .arg("--version")
        .output()
        .ok()
        .filter(|o| o.status.success())
        .map(|o| String::from_utf8_lossy(&o.stdout).trim().to_string())
        .unwrap_or_else(|| "unknown".to_string());
    println!("cargo:rustc-env=LIBREGET_SDK_RUSTC_VERSION={version}");
    println!("cargo:rerun-if-env-changed=RUSTC");
    println!("cargo:rerun-if-env-changed=RUSTUP_TOOLCHAIN");
}