Skip to content

Commit

Permalink
Remove glob build-time dependency
Browse files Browse the repository at this point in the history
As it just lists 6 source files that doesn't change. And we generally prefer to not use dependencies that interact with the file system beyond `cap-std`.
  • Loading branch information
repi committed Oct 13, 2023
1 parent 37273b3 commit f1900c2
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
<!-- next-header -->
## [Unreleased] - ReleaseDate

- Remove `glob` build time dependency
## [0.1.0] - 2023-03-02
### Added
- Initial Fsr2 bindings for vulkan.
Expand Down
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions fsr-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@ widestring = "1.0"
[build-dependencies]
bindgen = { version = "0.68", optional = true }
cc = "1.0"
glob = "0.3"

[features]
vulkan = []
d3d12 = []
generate-bindings = ["dep:bindgen"]

20 changes: 14 additions & 6 deletions fsr-sys/build/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,27 @@
mod bindgen;

fn build_fsr(api_dir: &str, _vk_include_dir: &str) {
let sources = glob::glob(&format!("{}/**/*.cpp", api_dir)).expect("Failed to find sources");
let sources = [
"ffx_assert.cpp",
"dx12/shaders/ffx_fsr2_shaders_dx12.cpp",
"dx12/ffx_fsr2_dx12.cpp",
"ffx_fsr2.cpp",
"vk/shaders/ffx_fsr2_shaders_vk.cpp",
"vk/ffx_fsr2_vk.cpp",
]
.into_iter()
.map(|p| format!("{api_dir}/{p}"))
.collect::<Vec<_>>();

// Compile d3d12 / vulkan backend into the lib
#[cfg(not(feature = "d3d12"))]
let sources = sources.filter(|p| !p.as_ref().unwrap().to_str().unwrap().contains("dx12"));
let sources = sources.into_iter().filter(|p| !p.contains("dx12"));
#[cfg(not(feature = "vulkan"))]
let sources = sources.filter(|p| !p.as_ref().unwrap().to_str().unwrap().contains("vk"));

let sources: Vec<_> = sources.map(|p| p.unwrap()).collect();
let sources = sources.into_iter().filter(|p| !p.contains("vk"));

let mut build = cc::Build::new();
build
.files(sources.iter())
.files(sources)
.cpp(true)
.define("DYNAMIC_LINK_VULKAN", "1");

Expand Down

0 comments on commit f1900c2

Please sign in to comment.