Skip to content

Commit

Permalink
cxx-qt-build: use same builder for now for all qml modules
Browse files Browse the repository at this point in the history
  • Loading branch information
ahayzen-kdab committed Sep 10, 2024
1 parent d0e2a20 commit 7c6034e
Showing 1 changed file with 3 additions and 28 deletions.
31 changes: 3 additions & 28 deletions crates/cxx-qt-build/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,14 +302,6 @@ fn static_lib_name() -> String {
format!("{}-cxxqt-generated", crate_name())
}

fn qml_module_static_lib_name(module_uri: &str) -> String {
format!(
"{}-qml-module-{}-cxxqt-generated",
crate_name(),
module_name_from_uri(module_uri)
)
}

fn panic_duplicate_file_and_qml_module(
path: impl AsRef<Path>,
uri: &str,
Expand Down Expand Up @@ -783,14 +775,12 @@ impl CxxQtBuilder {
);
}

// Use a separate cc_builder per QML module so we don't have collisions
//
// TODO: for now we copy the global CxxQtBuilder cc_builder
// TODO: for now we use the global CxxQtBuilder cc_builder
// this means that any includes/files etc on these are in this builder
// but we cannot have separate builds until we can configure includes,
// qt modules, files, cc_builder options etc in the QmlModule itself
let mut cc_builder = self.cc_builder.clone();
qtbuild.cargo_link_libraries(&mut cc_builder);
let cc_builder = &mut self.cc_builder;
qtbuild.cargo_link_libraries(cc_builder);

let mut moc_include_paths = HashSet::new();
for files in generate_cxxqt_cpp_files(
Expand Down Expand Up @@ -882,21 +872,6 @@ impl CxxQtBuilder {
&qml_module_registration_files.plugin_init,
dir::module_target(&qml_module.uri).join("plugin_init.o"),
);

// Build the QML module as a library
if cc_builder.get_files().count() > 0 {
let qml_library_name = qml_module_static_lib_name(&qml_module.uri);

// The linker argument order matters!
// We need to link the object file first, then link the static library.
// Otherwise, the linker will be unable to find the symbols in the static library file.
// See also: https://stackoverflow.com/questions/45135/why-does-the-order-in-which-libraries-are-linked-sometimes-cause-errors-in-gcc
if !dir::is_exporting() {
println!("cargo::rustc-link-arg=-l{}", &qml_library_name);
}

cc_builder.compile(&qml_library_name);
}
}
}

Expand Down

0 comments on commit 7c6034e

Please sign in to comment.