use tauri_runtime::gtk::Version;
const COMPILED: Version = if cfg!(feature = "gtk4") {
Version::V4
} else {
Version::V3
};
pub(crate) fn check() -> crate::Result<()> {
match tauri_runtime::gtk::active_version() {
None => Ok(()),
Some(active) if active == COMPILED => Ok(()),
Some(active) => {
static REPORTED: std::sync::Once = std::sync::Once::new();
REPORTED.call_once(|| {
log::error!(
"the `tauri` crate was built for {COMPILED} but the active runtime uses {active}, so the \
GTK APIs and the Linux menu integration are unavailable. This happens when a single \
build enables both the `gtk3` and `gtk4` features, which cargo does whenever the \
dependency graph contains runtime crates that disagree on the GTK version. Link a \
single runtime crate on Linux - GTK 3 and GTK 4 cannot be initialized in the same \
process anyway."
);
});
Err(crate::Error::GtkVersionMismatch {
expected: COMPILED,
active,
})
}
}
}