5
5
6
6
use cxx_qt_build:: CxxQtBuilder ;
7
7
use qt_build_utils:: QtBuild ;
8
- use std:: { fs:: File , io:: Write } ;
9
8
10
9
fn main ( ) {
11
10
let feature_qt_gui_enabled = std:: env:: var ( "CARGO_FEATURE_QT_GUI" ) . is_ok ( ) ;
@@ -16,14 +15,6 @@ fn main() {
16
15
} ;
17
16
18
17
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
- }
27
18
28
19
// Find the Qt version and tell the Rust compiler
29
20
// this allows us to have conditional Rust code
@@ -260,36 +251,5 @@ fn main() {
260
251
} ) ;
261
252
println ! ( "cargo:rerun-if-changed=src/assertion_utils.h" ) ;
262
253
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 ( ) ;
295
255
}
0 commit comments