From f1900c22f91ac2750dd75e656964f2dda24720db Mon Sep 17 00:00:00 2001 From: Johan Andersson Date: Fri, 13 Oct 2023 18:02:16 +0200 Subject: [PATCH] Remove `glob` build-time dependency 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`. --- CHANGELOG.md | 1 + Cargo.lock | 1 - fsr-sys/Cargo.toml | 2 -- fsr-sys/build/build.rs | 20 ++++++++++++++------ 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d1d37f4..6db0cd4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] - ReleaseDate +- Remove `glob` build time dependency ## [0.1.0] - 2023-03-02 ### Added - Initial Fsr2 bindings for vulkan. diff --git a/Cargo.lock b/Cargo.lock index 3ff3e46..9a51692 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -99,7 +99,6 @@ version = "0.1.6" dependencies = [ "bindgen", "cc", - "glob", "widestring", ] diff --git a/fsr-sys/Cargo.toml b/fsr-sys/Cargo.toml index 7046d43..9808202 100644 --- a/fsr-sys/Cargo.toml +++ b/fsr-sys/Cargo.toml @@ -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"] - diff --git a/fsr-sys/build/build.rs b/fsr-sys/build/build.rs index 6bf3cca..8a520bc 100644 --- a/fsr-sys/build/build.rs +++ b/fsr-sys/build/build.rs @@ -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::>(); // 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");