Skip to content

Commit b612f71

Browse files
ahayzen-kdabBe-ing
authored andcommitted
qt-build-utils: if files in the qrc file change rerun cargo
Closes #469
1 parent 9b31426 commit b612f71

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1818

1919
- `QDateTime` API to use `current_date_time` rather than `current_date`
2020

21+
### Fixed
22+
23+
- `qrc` resources added to `CxxQtBuilder` or `QtBuild` now trigger `cargo:rerun-if-changed` for file entries
24+
2125
## [0.5.0](https://github.com/KDAB/cxx-qt/compare/v0.4.1...v0.5.0) - 2023-03-08
2226

2327
## Added

crates/qt-build-utils/src/lib.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,27 @@ Q_IMPORT_PLUGIN({plugin_class_name});
630630
);
631631
}
632632

633+
// Add the qrc file contents to the cargo rerun list
634+
let cmd_list = Command::new(self.rcc_executable.as_ref().unwrap())
635+
.args(["--list", input_path.to_str().unwrap()])
636+
.output()
637+
.unwrap_or_else(|_| panic!("rcc --list failed for {}", input_path.display()));
638+
639+
if !cmd_list.status.success() {
640+
panic!(
641+
"rcc --list failed for {}:\n{}",
642+
input_path.display(),
643+
String::from_utf8_lossy(&cmd.stderr)
644+
);
645+
}
646+
647+
for path in String::from_utf8_lossy(&cmd_list.stdout)
648+
.split('\n')
649+
.map(PathBuf::from)
650+
{
651+
println!("cargo:rerun-if-changed={}", path.display());
652+
}
653+
633654
output_path
634655
}
635656
}

0 commit comments

Comments
 (0)