27 lines
1.4 KiB
Rust
27 lines
1.4 KiB
Rust
use cxx_qt_build::{CxxQtBuilder, PluginType, QmlModule};
|
|
|
|
fn main() {
|
|
// cc-rs compiles with -ffunction-sections, Rust's cdylib link runs --gc-sections,
|
|
// and nothing internal references qt_plugin_instance/qt_plugin_query_metadata_v2
|
|
// - moc generates them as Qt's plugin entry points for dlopen, not for in-binary
|
|
// calls. So the linker drops them entirely (verified: `nm libNovaStats.so | grep
|
|
// qt_plugin_instance` returns nothing, only the static const inside the dropped
|
|
// function survives). --undefined anchors them past --gc-sections, then
|
|
// --export-dynamic-symbol exposes them for Qt's dlsym lookup.
|
|
for sym in ["qt_plugin_instance", "qt_plugin_query_metadata_v2"] {
|
|
println!("cargo:rustc-link-arg=-Wl,--undefined={sym}");
|
|
println!("cargo:rustc-link-arg=-Wl,--export-dynamic-symbol={sym}");
|
|
}
|
|
|
|
// 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();
|
|
}
|