forked from 1b-agent/opencadstudio-upstream
fix(plugins): enforce rustc compatibility
BREAKING CHANGE: API v4+ plugin packages must declare the exact rustc version used to build the binary. Refs #901
This commit is contained in:
1 parent
4668042df5
commit
466ab99c63
9 files changed
+23
-40
No files matched your search
@@ -100,9 +100,6 @@ impl ExternalPlugin {
|
||||
if !ocs_plugin_api::version_info::uses_acadrust_gate(self.api_version) {
|
||||
return true;
|
||||
}
|
||||
if !self.rustc_declared {
|
||||
return true;
|
||||
}
|
||||
match self.rustc_version.as_deref() {
|
||||
None | Some("") => false,
|
||||
Some(version) => ocs_plugin_api::version_info::rustc_versions_compatible(
|
||||
@@ -534,7 +531,7 @@ xdata_apps = ["MYPLUGIN_RECORD"]
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn undeclared_rustc_falls_back_to_api_gate() {
|
||||
fn undeclared_rustc_is_incompatible() {
|
||||
let toml = r#"
|
||||
[plugin]
|
||||
id = "opencad.test"
|
||||
@@ -545,7 +542,8 @@ api_version = 4
|
||||
let p = parse_plugin_toml(toml).expect("parsed");
|
||||
assert!(!p.rustc_declared);
|
||||
assert!(p.rustc_version.is_none());
|
||||
assert!(p.rustc_compatible(), "undeclared rustc is treated as compatible");
|
||||
assert!(!p.rustc_compatible());
|
||||
assert!(!p.loadable());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -242,8 +242,6 @@ pub fn fetch_release_info(repo: &str) -> Result<Vec<ReleaseInfo>, String> {
|
||||
manifest.api_version,
|
||||
) {
|
||||
true
|
||||
} else if !rustc_declared {
|
||||
true
|
||||
} else {
|
||||
match rustc_version.as_deref() {
|
||||
None | Some("") => false,
|
||||
@@ -281,17 +279,6 @@ pub fn fetch_release_info(repo: &str) -> Result<Vec<ReleaseInfo>, String> {
|
||||
}
|
||||
}
|
||||
}
|
||||
let any_rustc_declared = info.iter().any(|r| r.rustc_declared);
|
||||
if any_rustc_declared {
|
||||
for r in &mut info {
|
||||
if !r.rustc_declared
|
||||
&& ocs_plugin_api::version_info::uses_acadrust_gate(r.api_version)
|
||||
{
|
||||
r.rustc_compatible = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if info.is_empty() {
|
||||
Err(last_error.unwrap_or_else(|| "no installable releases found".to_string()))
|
||||
} else {
|
||||
@@ -391,18 +378,12 @@ pub fn install(release: &Release, repository: &str) -> Result<String, String> {
|
||||
}
|
||||
}
|
||||
|
||||
if ocs_plugin_api::version_info::uses_acadrust_gate(manifest.api_version)
|
||||
&& manifest.rustc_declared
|
||||
{
|
||||
if ocs_plugin_api::version_info::uses_acadrust_gate(manifest.api_version) {
|
||||
let Some(version) = manifest.rustc_version.as_deref() else {
|
||||
return Err(
|
||||
"Release declares rustc metadata but has no version; cannot verify ABI compatibility".to_string(),
|
||||
);
|
||||
return Err("Release has no rustc version; cannot verify ABI compatibility".to_string());
|
||||
};
|
||||
if version.is_empty() {
|
||||
return Err(
|
||||
"Release declares rustc metadata but has no version; cannot verify ABI compatibility".to_string(),
|
||||
);
|
||||
return Err("Release has no rustc version; cannot verify ABI compatibility".to_string());
|
||||
}
|
||||
if !ocs_plugin_api::version_info::rustc_versions_compatible(
|
||||
version,
|
||||
|
||||
Reference in new issue
Block a user