use std::{env, path::PathBuf};

fn main() {
    let manifest_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
    let include_dir = PathBuf::from(&manifest_dir).join("include");

    println!("cargo:include={}", include_dir.display());
    // 同时也导出根目录，以备不时之需
    println!("cargo:root={}", manifest_dir);

    cxx_build::bridge("src/lib.rs")
        .include(&include_dir)
        .flag_if_supported("-std=c++20")
        .compile("roplat_cpp_msg");

    println!("cargo:rerun-if-changed=src/lib.rs");
    println!("cargo:rerun-if-changed=include/eigen_msg.h");
}
