Skip to content

Commit

Permalink
Add support for searching Vulkan SDK library path
Browse files Browse the repository at this point in the history
  • Loading branch information
antiagainst committed Nov 8, 2020
1 parent 6c78f13 commit 9c1cfb6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,14 @@ attempts to obtain native shaderc can be controlled by several options, which
are passed through to shaderc-sys when building shaderc-rs:

1. Building from source, if option `--features build-from-source` is specified.
2. If the `SHADERC_LIB_DIR` environment variable is set to
1. If the `SHADERC_LIB_DIR` environment variable is set to
`/path/to/shaderc/libs/`, that path will be searched for native dynamic or
static shaderc library.
3. On Linux, system library paths like `/usr/lib/` will additionally be searched
1. If the `VULKAN_SDK` environment variable is set, then `$VULKAN_SDK/lib` will
be searched for native dynamicd or static shaderc library.
1. On Linux, system library paths like `/usr/lib/` will additionally be searched
for native dynamic or shaderc library, if the `SHADERC_LIB_DIR` is not set.
4. Building from source, if the native shaderc library is not found via the
1. Building from source, if the native shaderc library is not found via the
above steps.

For each library directory, the build script will try to fine and link to the
Expand Down
13 changes: 13 additions & 0 deletions shaderc-sys/build/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,19 @@ fn main() {
None
};

// Try to find native shaderc library from Vulkan SDK if possible.
if search_dir.is_none() {
search_dir = if let Ok(sdk_dir) = env::var("VULKAN_SDK") {
println!(
"cargo:warning=shaderc: searching native shaderc libraries in Vulkan SDK '{}/lib'",
sdk_dir
);
Some(format!("{}/lib/", sdk_dir))
} else {
None
};
}

// If no explicit path is set and no explicit request is made to build from
// source, check known system locations before falling back to build from source.
// This set `search_dir` for later usage.
Expand Down

0 comments on commit 9c1cfb6

Please sign in to comment.