Skip to content

Commit 1941008

Browse files
committed
build.rs simplify c file selection
1 parent a5b1e6d commit 1941008

1 file changed

Lines changed: 8 additions & 16 deletions

File tree

build.rs

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -256,22 +256,14 @@ fn compile_odbc_from_source() {
256256

257257
#[cfg(feature = "static")]
258258
fn add_c_files(build: &mut cc::Build, dir: &Path) {
259-
if !dir.exists() {
260-
return;
261-
}
262-
263-
let entries = match std::fs::read_dir(dir) {
264-
Ok(entries) => entries,
265-
Err(_) => return,
266-
};
267-
268-
let files: Vec<_> = entries
269-
.flatten()
270-
.map(|e| e.path())
271-
.filter(|p| p.extension().map_or(false, |ext| ext == "c"))
272-
.collect();
273-
274-
build.files(files);
259+
let entries = std::fs::read_dir(dir).expect("Failed to read source files from directory");
260+
build.files(entries.flatten().filter_map(|p| {
261+
let path = p.path();
262+
if path.extension().unwrap_or_default() == "c" {
263+
return Some(path);
264+
}
265+
None
266+
}));
275267
}
276268

277269
fn print_paths(paths: &str) {

0 commit comments

Comments
 (0)