Skip to content

Commit 2129638

Browse files
authored
Support libshaderc.so dylib case (#156)
1 parent 5fc4f78 commit 2129638

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

shaderc-sys/build/build.rs

+19-7
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ use std::fs;
2020
use std::path::{Path, PathBuf};
2121

2222
static SHADERC_STATIC_LIB: &str = "shaderc_combined";
23-
static SHADERC_SHARED_LIB: &str = "shaderc_shared";
23+
static SHADERC_SHARED_LIB0: &str = "shaderc";
24+
static SHADERC_SHARED_LIB1: &str = "shaderc_shared";
2425
static SHADERC_STATIC_LIB_FILE_UNIX: &str = "libshaderc_combined.a";
2526
static SHADERC_STATIC_LIB_FILE_WIN: &str = "shaderc_combined.lib";
2627
static MIN_VULKAN_SDK_VERSION: u32 = 182;
@@ -286,24 +287,35 @@ fn main() {
286287
SHADERC_STATIC_LIB_FILE_UNIX
287288
});
288289

289-
let dylib_name = format!(
290+
let dylib0_name = format!(
290291
"{}{}{}",
291292
consts::DLL_PREFIX,
292-
SHADERC_SHARED_LIB,
293+
SHADERC_SHARED_LIB0,
293294
consts::DLL_SUFFIX
294295
);
295-
let dylib_path = search_dir.join(dylib_name);
296+
let dylib1_name = format!(
297+
"{}{}{}",
298+
consts::DLL_PREFIX,
299+
SHADERC_SHARED_LIB1,
300+
consts::DLL_SUFFIX
301+
);
302+
let dylib0_path = search_dir.join(dylib0_name);
303+
let dylib1_path = search_dir.join(dylib1_name);
296304

297305
if let Some((lib_name, lib_kind)) = {
298306
match (
299-
dylib_path.exists(),
307+
dylib0_path.exists(),
308+
dylib1_path.exists(),
300309
static_lib_path.exists(),
301310
config_prefer_static_linking,
302311
) {
303312
// If dylib not exist OR prefer static lib and static lib exist, static.
304-
(false, true, _) | (_, true, true) => Some((SHADERC_STATIC_LIB, "static")),
313+
(false, false, true, _) | (_, _, true, true) => {
314+
Some((SHADERC_STATIC_LIB, "static"))
315+
}
305316
// Otherwise, if dylib exist, dynamic.
306-
(true, _, _) => Some((SHADERC_SHARED_LIB, "dylib")),
317+
(true, _, _, _) => Some((SHADERC_SHARED_LIB0, "dylib")),
318+
(_, true, _, _) => Some((SHADERC_SHARED_LIB1, "dylib")),
307319
// Neither dylib nor static lib exist.
308320
_ => None,
309321
}

0 commit comments

Comments
 (0)