Skip to content

Commit

Permalink
Support min_version field in objdiff.json
Browse files Browse the repository at this point in the history
  • Loading branch information
encounter committed Sep 10, 2023
1 parent 192a06b commit 26932b2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ ppc750cl = { git = "https://github.com/terorie/ppc750cl", rev = "9ae36eef34aa6d7
rabbitizer = "1.7.4"
rfd = { version = "0.11.4" } #, default-features = false, features = ['xdg-portal']
ron = "0.8.0"
semver = "1.0.17"
serde = { version = "1", features = ["derive"] }
serde_json = "1.0.104"
serde_yaml = "0.9.25"
Expand Down
11 changes: 10 additions & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ use std::{
path::{Component, Path, PathBuf},
};

use anyhow::{Context, Result};
use anyhow::{bail, Context, Result};
use globset::{Glob, GlobSet, GlobSetBuilder};

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

#[derive(Default, Clone, serde::Deserialize)]
#[serde(default)]
pub struct ProjectConfig {
pub min_version: Option<String>,
pub custom_make: Option<String>,
pub target_dir: Option<PathBuf>,
pub base_dir: Option<PathBuf>,
Expand Down Expand Up @@ -121,6 +122,14 @@ pub fn load_project_config(config: &mut AppConfig) -> Result<()> {
};
if let Some(result) = try_project_config(project_dir) {
let project_config = result?;
if let Some(min_version) = &project_config.min_version {
let version_str = env!("CARGO_PKG_VERSION");
let version = semver::Version::parse(version_str).unwrap();
let version_req = semver::VersionReq::parse(&format!(">={min_version}"))?;
if !version_req.matches(&version) {
bail!("Project requires objdiff version {} or higher", min_version);
}
}
config.custom_make = project_config.custom_make;
config.target_obj_dir = project_config.target_dir.map(|p| project_dir.join(p));
config.base_obj_dir = project_config.base_dir.map(|p| project_dir.join(p));
Expand Down

0 comments on commit 26932b2

Please sign in to comment.