slang-compiler-sys/build.rs

25 lines
1.0 KiB
Rust
Raw Permalink Normal View History

2024-12-28 23:24:57 -05:00
fn main() {
println!("cargo:rerun-if-changed=build.rs");
println!("cargo:rerun-if-changed=src/lib.rs");
println!("cargo:rerun-if-changed=src/lib.cpp");
// Build libslang.so for use with the Rust/C++ bridge
let cmake_output = cmake::Config::new("./slang")
// https://github.com/shader-slang/slang/issues/5832#issuecomment-2533324982
.define("CMAKE_SKIP_INSTALL_RULES", "ON")
.build_target("slang")
.build();
// Build the C++ bridge
cxx_build::bridge("src/lib.rs")
.include(format!("{}/build/Debug/include", cmake_output.display()))
.include(format!("{}/build/Release/include", cmake_output.display()))
.include("src")
.file("src/lib.cpp")
.compile("slang-compiler");
// Link the C++ bridge
println!("cargo:rustc-link-search=native={}/build/Debug/lib", cmake_output.display());
println!("cargo:rustc-link-search=native={}/build/Release/lib", cmake_output.display());
println!("cargo:rustc-link-lib=dylib=slang");
}