From 257550f098a95be6ec351d4943871165fc637f3a Mon Sep 17 00:00:00 2001 From: Zach Thompson Date: Wed, 2 Nov 2022 07:52:38 -0400 Subject: [PATCH] Warn on full version mismatch of host and model --- Cargo.lock | 1 + crates/fj-host/Cargo.toml | 1 + crates/fj-host/src/model.rs | 17 +++++++++++++++++ crates/fj/src/version.rs | 8 ++++++++ 4 files changed, 27 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 83b7443ac..97dab07e7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1170,6 +1170,7 @@ dependencies = [ "libloading", "notify", "thiserror", + "tracing", ] [[package]] diff --git a/crates/fj-host/Cargo.toml b/crates/fj-host/Cargo.toml index cda1c5260..316cec8c4 100644 --- a/crates/fj-host/Cargo.toml +++ b/crates/fj-host/Cargo.toml @@ -18,3 +18,4 @@ fj.workspace = true libloading = "0.7.2" notify = "5.0.0" thiserror = "1.0.35" +tracing = "0.1.37" diff --git a/crates/fj-host/src/model.rs b/crates/fj-host/src/model.rs index 02c17d40e..7431ff75a 100644 --- a/crates/fj-host/src/model.rs +++ b/crates/fj-host/src/model.rs @@ -6,6 +6,7 @@ use std::{ }; use fj::{abi, version::RawVersion}; +use tracing::warn; use crate::{platform::HostPlatform, Parameters}; @@ -120,6 +121,22 @@ impl Model { return Err(Error::VersionMismatch { host, model }); } + let version_full: libloading::Symbol RawVersion> = + lib.get(b"version_full").map_err(Error::LoadingVersion)?; + + let version_full = version_full(); + if fj::version::VERSION_FULL != version_full.as_str() { + let host = String::from_utf8_lossy( + fj::version::VERSION_FULL.as_bytes(), + ) + .into_owned(); + let model = + String::from_utf8_lossy(version_full.as_str().as_bytes()) + .into_owned(); + + warn!("{}", Error::VersionMismatch { host, model }); + } + let init: libloading::Symbol = lib .get(abi::INIT_FUNCTION_NAME.as_bytes()) .map_err(Error::LoadingInit)?; diff --git a/crates/fj/src/version.rs b/crates/fj/src/version.rs index 95ec209df..bc8d8372e 100644 --- a/crates/fj/src/version.rs +++ b/crates/fj/src/version.rs @@ -52,3 +52,11 @@ extern "C" fn version_pkg() -> RawVersion { len: VERSION_PKG.len(), } } + +#[no_mangle] +extern "C" fn version_full() -> RawVersion { + RawVersion { + ptr: VERSION_FULL.as_ptr(), + len: VERSION_FULL.len(), + } +}