@@ -3,14 +3,15 @@ use std::{
3
3
path:: { Component , Path , PathBuf } ,
4
4
} ;
5
5
6
- use anyhow:: { Context , Result } ;
6
+ use anyhow:: { bail , Context , Result } ;
7
7
use globset:: { Glob , GlobSet , GlobSetBuilder } ;
8
8
9
9
use crate :: { app:: AppConfig , views:: config:: DEFAULT_WATCH_PATTERNS } ;
10
10
11
11
#[ derive( Default , Clone , serde:: Deserialize ) ]
12
12
#[ serde( default ) ]
13
13
pub struct ProjectConfig {
14
+ pub min_version : Option < String > ,
14
15
pub custom_make : Option < String > ,
15
16
pub target_dir : Option < PathBuf > ,
16
17
pub base_dir : Option < PathBuf > ,
@@ -121,6 +122,14 @@ pub fn load_project_config(config: &mut AppConfig) -> Result<()> {
121
122
} ;
122
123
if let Some ( result) = try_project_config ( project_dir) {
123
124
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
+ }
124
133
config. custom_make = project_config. custom_make ;
125
134
config. target_obj_dir = project_config. target_dir . map ( |p| project_dir. join ( p) ) ;
126
135
config. base_obj_dir = project_config. base_dir . map ( |p| project_dir. join ( p) ) ;
0 commit comments