Skip to content

Commit 26932b2

Browse files
committed
Support min_version field in objdiff.json
1 parent 192a06b commit 26932b2

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ ppc750cl = { git = "https://github.com/terorie/ppc750cl", rev = "9ae36eef34aa6d7
4343
rabbitizer = "1.7.4"
4444
rfd = { version = "0.11.4" } #, default-features = false, features = ['xdg-portal']
4545
ron = "0.8.0"
46+
semver = "1.0.17"
4647
serde = { version = "1", features = ["derive"] }
4748
serde_json = "1.0.104"
4849
serde_yaml = "0.9.25"

src/config.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@ use std::{
33
path::{Component, Path, PathBuf},
44
};
55

6-
use anyhow::{Context, Result};
6+
use anyhow::{bail, Context, Result};
77
use globset::{Glob, GlobSet, GlobSetBuilder};
88

99
use crate::{app::AppConfig, views::config::DEFAULT_WATCH_PATTERNS};
1010

1111
#[derive(Default, Clone, serde::Deserialize)]
1212
#[serde(default)]
1313
pub struct ProjectConfig {
14+
pub min_version: Option<String>,
1415
pub custom_make: Option<String>,
1516
pub target_dir: Option<PathBuf>,
1617
pub base_dir: Option<PathBuf>,
@@ -121,6 +122,14 @@ pub fn load_project_config(config: &mut AppConfig) -> Result<()> {
121122
};
122123
if let Some(result) = try_project_config(project_dir) {
123124
let project_config = result?;
125+
if let Some(min_version) = &project_config.min_version {
126+
let version_str = env!("CARGO_PKG_VERSION");
127+
let version = semver::Version::parse(version_str).unwrap();
128+
let version_req = semver::VersionReq::parse(&format!(">={min_version}"))?;
129+
if !version_req.matches(&version) {
130+
bail!("Project requires objdiff version {} or higher", min_version);
131+
}
132+
}
124133
config.custom_make = project_config.custom_make;
125134
config.target_obj_dir = project_config.target_dir.map(|p| project_dir.join(p));
126135
config.base_obj_dir = project_config.base_dir.map(|p| project_dir.join(p));

0 commit comments

Comments
 (0)