Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Windows MSVC support for the SHADERC_LIB_DIR option #55

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion shaderc-sys/build/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use std::path::{Path, PathBuf};

static COMBINED_LIB: &str = "shaderc_combined";
static COMBINED_LIB_FILE: &str = "libshaderc_combined.a";
static COMBINED_LIB_FILE_MSVC: &str = "shaderc_combined.lib";
static SPIRV_LIB_FILE: &str = "libSPIRV.a";

fn build_shaderc(shaderc_dir: &PathBuf, use_ninja: bool) -> PathBuf {
Expand Down Expand Up @@ -139,7 +140,11 @@ fn main() {

if let Some(search_dir) = search_dir {
let search_dir_str = search_dir.to_string_lossy();
let combined_lib_path = search_dir.join(COMBINED_LIB_FILE);
let combined_lib_name = match target_env.as_str() {
"msvc" => COMBINED_LIB_FILE_MSVC,
_ => COMBINED_LIB_FILE,
};
let combined_lib_path = search_dir.join(combined_lib_name.clone());
let dylib_name = format!("{}shaderc{}", consts::DLL_PREFIX, consts::DLL_SUFFIX);
let dylib_path = search_dir.join(dylib_name.clone());

Expand Down Expand Up @@ -186,6 +191,16 @@ fn main() {
println!("cargo:rustc-link-lib=dylib=stdc++");
return;
}
("windows", "msvc") => {
println!(
"cargo:warning=Windows msvc static builds \
experimental"
);
println!("cargo:rustc-link-search=native={}", lib_dir);
println!("cargo:rustc-link-lib=static={}", lib_name);
// It seems msvc automatically links stdc++
return;
}
("macos", _) => {
println!("cargo:warning=MacOS static builds experimental");
println!("cargo:rustc-link-search=native={}", lib_dir);
Expand Down