use std::env;

pub fn build() {
    let libk_so = env::var("MOD_LIBK_SO").expect("module-build: $MOD_LIBK_SO is not set");
    println!("cargo:rerun-if-changed={}", libk_so);
    println!("cargo:rerun-if-env-changed=MOD_LIBK_SO");
    println!("cargo:rerun-if-env-changed=MOD_DEPENDENCIES");

    if let Ok(deps) = env::var("MOD_DEPENDENCIES") {
        let deps = deps.trim();
        if !deps.is_empty() {
            let deps = deps.split(':');
            for dep in deps {
                let (_, path) = dep.split_once("=").unwrap();
                println!("cargo:rerun-if-changed={}", path);
            }
        }
    }
}
