Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable model version check on Windows #1374

Merged
merged 1 commit into from
Nov 21, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 31 additions & 39 deletions crates/fj-host/src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,49 +105,41 @@ impl Model {
let lib = libloading::Library::new(&self.lib_path)
.map_err(Error::LoadingLibrary)?;

if cfg!(target_os = "windows") {
warn!(
"Version check is disabled on Windows (see \
https://github.com/hannobraun/Fornjot/issues/1307)"
);
} else {
let version_pkg_host = fj::version::VERSION_PKG.to_string();

let version_pkg_model: libloading::Symbol<*const Version> =
lib.get(b"VERSION_PKG").map_err(Error::LoadingVersion)?;
let version_pkg_mode = (**version_pkg_model).to_string();

debug!(
"Comparing package versions (host: {}, model: {})",
version_pkg_host, version_pkg_mode
);
if version_pkg_host != version_pkg_mode {
let host =
String::from_utf8_lossy(version_pkg_host.as_bytes())
.into_owned();
let model = version_pkg_mode;

return Err(Error::VersionMismatch { host, model });
}
let version_pkg_host = fj::version::VERSION_PKG.to_string();

let version_pkg_model: libloading::Symbol<*const Version> =
lib.get(b"VERSION_PKG").map_err(Error::LoadingVersion)?;
let version_pkg_mode = (**version_pkg_model).to_string();

debug!(
"Comparing package versions (host: {}, model: {})",
version_pkg_host, version_pkg_mode
);
if version_pkg_host != version_pkg_mode {
let host = String::from_utf8_lossy(version_pkg_host.as_bytes())
.into_owned();
let model = version_pkg_mode;

return Err(Error::VersionMismatch { host, model });
}

let version_full_host = fj::version::VERSION_FULL.to_string();
let version_full_host = fj::version::VERSION_FULL.to_string();

let version_full_model: libloading::Symbol<*const Version> =
lib.get(b"VERSION_FULL").map_err(Error::LoadingVersion)?;
let version_full_model = (**version_full_model).to_string();
let version_full_model: libloading::Symbol<*const Version> =
lib.get(b"VERSION_FULL").map_err(Error::LoadingVersion)?;
let version_full_model = (**version_full_model).to_string();

debug!(
"Comparing full versions (host: {}, model: {})",
version_full_host, version_full_model
);
if version_full_host != version_full_model {
let host =
String::from_utf8_lossy(version_full_host.as_bytes())
.into_owned();
let model = version_full_model;
debug!(
"Comparing full versions (host: {}, model: {})",
version_full_host, version_full_model
);
if version_full_host != version_full_model {
let host =
String::from_utf8_lossy(version_full_host.as_bytes())
.into_owned();
let model = version_full_model;

warn!("{}", Error::VersionMismatch { host, model });
}
warn!("{}", Error::VersionMismatch { host, model });
}

let init: libloading::Symbol<abi::InitFunction> = lib
Expand Down