Skip to content

Commit b9211d8

Browse files
author
Quentin Weber
committed
Clear header directory before overwriting it
Before writing the new header files, the header directory is now cleared. This change helps to avoid potential conflicts.
1 parent e30646e commit b9211d8

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

crates/cxx-qt-lib/build.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,21 @@ fn write_headers_in(subfolder: &str) {
4646
}
4747
}
4848

49+
fn clear_include_directory() {
50+
if !header_dir().exists() {
51+
return;
52+
}
53+
for entry in std::fs::read_dir(header_dir().as_path()).expect("Failed to read header directory")
54+
{
55+
let path = entry.expect("Failed to read path").path();
56+
if path.is_dir() {
57+
std::fs::remove_dir_all(path).expect("Failed to delete directory");
58+
} else {
59+
std::fs::remove_file(path).expect("Failed to delete file");
60+
}
61+
}
62+
}
63+
4964
fn write_definitions_header() {
5065
// We cannot ensure that downstream dependencies set the same compile-time definitions.
5166
// So we generate a header file that adds those definitions, which will be passed along
@@ -102,6 +117,7 @@ fn main() {
102117
let qtbuild = qt_build_utils::QtBuild::new(vec!["Core".to_owned()])
103118
.expect("Could not find Qt installation");
104119

120+
clear_include_directory();
105121
write_headers();
106122

107123
let emscripten_targeted = match std::env::var("CARGO_CFG_TARGET_OS") {

0 commit comments

Comments
 (0)