Skip to content

Commit

Permalink
fix build failure with empty qml bridges (closes #1033)
Browse files Browse the repository at this point in the history
  • Loading branch information
aambrosano committed Sep 13, 2024
1 parent 64d84f3 commit 74a2c90
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
27 changes: 21 additions & 6 deletions crates/qt-build-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,26 @@ prefer :/qt/qml/{qml_uri_dirs}/
// Run qmltyperegistrar
let qmltyperegistrar_output_path =
qml_plugin_dir.join(format!("{qml_uri_underscores}_qmltyperegistration.cpp"));
{

// Filter out empty jsons
let metatypes_json: Vec<_> = metatypes_json
.iter()
.filter(|f| {
std::fs::metadata(&f)
.unwrap_or_else(|_| {
panic!(
"couldn't open json file {}",
f.as_ref().to_string_lossy()
)
})
.len()
> 0
})
.map(|f| f.as_ref().to_string_lossy().to_string())
.collect();

// Only run qmltyperegistrar if we have valid json files left out
if metatypes_json.len() > 0 {
let mut args = vec![
"--generate-qmltypes".to_string(),
qmltypes_path.to_string_lossy().to_string(),
Expand All @@ -862,11 +881,7 @@ prefer :/qt/qml/{qml_uri_dirs}/
"-o".to_string(),
qmltyperegistrar_output_path.to_string_lossy().to_string(),
];
args.extend(
metatypes_json
.iter()
.map(|f| f.as_ref().to_string_lossy().to_string()),
);
args.extend(metatypes_json.into_iter());
let cmd = Command::new(self.qmltyperegistrar_executable.as_ref().unwrap())
.args(args)
.output()
Expand Down
1 change: 1 addition & 0 deletions examples/qml_features/rust/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ fn main() {
"src/containers.rs",
"src/custom_base_class.rs",
"src/custom_parent_class.rs",
"src/empty_bridge.rs",
"src/externcxxqt.rs",
"src/invokables.rs",
"src/multiple_qobjects.rs",
Expand Down
3 changes: 3 additions & 0 deletions examples/qml_features/rust/src/empty_bridge.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#[cxx_qt::bridge]
pub mod qobject {
}

0 comments on commit 74a2c90

Please sign in to comment.