use std::process::Command;
fn main() {
#[cfg(feature = "llvm")]
{
let cxxflags = Command::new("llvm-config")
.args(["--cxxflags"])
.output()
.expect("could not execute llvm-config");
let cxxflags = String::from_utf8(cxxflags.stdout).unwrap();
let mut build = cc::Build::new();
build.file("src/linker/linker.cpp").cpp(true);
if !cfg!(target_os = "windows") {
build.flag("-Wno-unused-parameter");
}
for flag in cxxflags.split_whitespace() {
build.flag(flag);
}
build.compile("liblinker.a");
let libdir = Command::new("llvm-config")
.args(["--libdir"])
.output()
.unwrap();
let libdir = String::from_utf8(libdir.stdout).unwrap();
println!("cargo:libdir={}", libdir);
for lib in &["lldELF", "lldCommon", "lldWasm"] {
println!("cargo:rustc-link-lib=static={}", lib);
}
println!("cargo:rustc-link-lib=static=lldMachO");
}
let output = Command::new("git")
.args(["describe", "--tags", "--always"])
.output()
.unwrap();
let solang_version = if output.stdout.is_empty() {
format!("v{}", env!("CARGO_PKG_VERSION"))
} else {
String::from_utf8(output.stdout).unwrap()
};
println!("cargo:rustc-env=SOLANG_VERSION={}", solang_version);
#[cfg(windows)]
println!("cargo:rustc-link-arg=/STACK:8388608");
}