use cxx_qt_build::{CxxQtBuilder, PluginType, QmlModule}; fn main() { // Rust cdylib uses a version script that hides everything not declared // `#[no_mangle] pub extern "C"`. cxx-qt's QQmlEngineExtensionPlugin entry // points (qt_plugin_instance, qt_plugin_query_metadata_v2) come from // compiled C++ and would otherwise be stripped to local visibility, so Qt's // plugin loader finds nothing exported. --export-dynamic re-exposes them. println!("cargo:rustc-link-arg=-Wl,--export-dynamic"); // Crane's deps-only build stubs out lib.rs and removes our bridge sources to // build a dummy crate that only compiles dependencies. Skip cxx-qt codegen in // that case - we just want cxx-qt-lib (the heavy dep) cached, not our own glue. let bridge_files = ["src/system_stats.rs", "src/cpu_service.rs"]; if !bridge_files.iter().all(|p| std::path::Path::new(p).exists()) { return; } CxxQtBuilder::new_qml_module(QmlModule::new("NovaStats").plugin_type(PluginType::Dynamic)) .files(bridge_files) .build(); }