Skip to content

Commit b0f57b4

Browse files
committed
cxx-qt-build: use moc() method to retrieve the tool not compile
1 parent 53f8739 commit b0f57b4

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ impl CxxQtBuilder {
699699
moc_arguments,
700700
} in &self.qobject_headers
701701
{
702-
let moc_products = qtbuild.moc(path, moc_arguments.clone());
702+
let moc_products = qtbuild.moc().compile(path, moc_arguments.clone());
703703
// Include the moc folder
704704
if let Some(dir) = moc_products.cpp.parent() {
705705
self.cc_builder.include(dir);
@@ -824,7 +824,7 @@ impl CxxQtBuilder {
824824
}
825825

826826
cc_builder.file(&qobject);
827-
let moc_products = qtbuild.moc(
827+
let moc_products = qtbuild.moc().compile(
828828
qobject_header,
829829
MocArguments::default().uri(qml_module.uri.clone()),
830830
);

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -187,13 +187,11 @@ impl QtBuild {
187187
self.qt_installation.version()
188188
}
189189

190-
/// Run moc on a C++ header file and save the output into [cargo's OUT_DIR](https://doc.rust-lang.org/cargo/reference/environment-variables.html).
191-
/// The return value contains the path to the generated C++ file, which can then be passed to [cc::Build::files](https://docs.rs/cc/latest/cc/struct.Build.html#method.file),
192-
/// as well as the path to the generated metatypes.json file, which can be passed to [register_qml_module](Self::register_qml_module).
193-
pub fn moc(&mut self, input_file: impl AsRef<Path>, arguments: MocArguments) -> MocProducts {
194-
// TODO: do we change this API to just be moc() -> QtToolMoc ?
190+
/// Create a [QtToolMoc] for this [QtBuild]
191+
///
192+
/// This allows for using [moc](https://doc.qt.io/qt-6/moc.html)
193+
pub fn moc(&mut self) -> QtToolMoc {
195194
QtToolMoc::new(self.qt_installation.as_ref(), &self.qt_modules)
196-
.compile(input_file, arguments)
197195
}
198196

199197
/// Generate C++ files to automatically register a QML module at build time using the JSON output from [moc](Self::moc).
@@ -380,7 +378,7 @@ public:
380378
)
381379
.expect("Failed to write plugin definition");
382380

383-
let moc_product = self.moc(
381+
let moc_product = self.moc().compile(
384382
&qml_plugin_cpp_path,
385383
MocArguments::default().uri(uri.to_owned()),
386384
);

0 commit comments

Comments
 (0)