Skip to content

Commit b0cbf15

Browse files
ahayzen-kdabLeonMatthesKDAB
authored andcommitted
cxx-qt-lib: use CxxQtBuildersOpts for build options too
1 parent 16f49b9 commit b0cbf15

File tree

1 file changed

+1
-41
lines changed

1 file changed

+1
-41
lines changed

crates/cxx-qt-lib/build.rs

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
use cxx_qt_build::CxxQtBuilder;
77
use qt_build_utils::QtBuild;
8-
use std::{fs::File, io::Write};
98

109
fn main() {
1110
let feature_qt_gui_enabled = std::env::var("CARGO_FEATURE_QT_GUI").is_ok();
@@ -16,14 +15,6 @@ fn main() {
1615
};
1716

1817
let mut builder = CxxQtBuilder::new();
19-
// Not strictly required to enable modules as the feature should do this
20-
// build lets be explicit for now.
21-
if feature_qt_gui_enabled {
22-
builder = builder.qt_module("Gui");
23-
}
24-
if feature_qt_qml_enabled {
25-
builder = builder.qt_module("Qml");
26-
}
2718

2819
// Find the Qt version and tell the Rust compiler
2920
// this allows us to have conditional Rust code
@@ -260,36 +251,5 @@ fn main() {
260251
});
261252
println!("cargo:rerun-if-changed=src/assertion_utils.h");
262253

263-
// Write this library's manually written C++ headers to files and add them to include paths
264-
let header_root = format!("{}/include", std::env::var("OUT_DIR").unwrap());
265-
for (file_contents, dir_name, file_name) in cxx_qt_lib_headers::build_opts().headers {
266-
let directory = if dir_name.is_empty() {
267-
header_root.clone()
268-
} else {
269-
format!("{header_root}/{dir_name}")
270-
};
271-
std::fs::create_dir_all(directory.clone())
272-
.expect("Could not create {directory} header directory");
273-
274-
let h_path = format!("{directory}/{file_name}");
275-
let mut header = File::create(h_path).expect("Could not create header: {h_path}");
276-
write!(header, "{file_contents}").expect("Could not write header: {h_path}");
277-
}
278-
279-
builder = builder.cc_builder(|cc| {
280-
// Load the include path
281-
cc.include(&header_root);
282-
283-
// Enable Qt Gui in C++ if the feature is enabled
284-
if feature_qt_gui_enabled {
285-
cc.define("CXX_QT_GUI_FEATURE", None);
286-
}
287-
288-
// Enable Qt Qml in C++ if the feature is enabled
289-
if feature_qt_gui_enabled {
290-
cc.define("CXX_QT_QML_FEATURE", None);
291-
}
292-
});
293-
294-
builder.build();
254+
builder.with_opts(cxx_qt_lib_headers::build_opts()).build();
295255
}

0 commit comments

Comments
 (0)