@@ -17,7 +17,7 @@ use tracing::{info, warn};
1717use typed_path:: { Utf8PlatformPath , Utf8PlatformPathBuf } ;
1818
1919use crate :: {
20- cmd:: diff:: ObjectConfig ,
20+ cmd:: { apply_config_args , diff:: ObjectConfig } ,
2121 util:: output:: { OutputFormat , write_output} ,
2222} ;
2323
@@ -52,6 +52,9 @@ pub struct GenerateArgs {
5252 #[ argp( option, short = 'f' ) ]
5353 /// Output format (json, json-pretty, proto) (default: json)
5454 format : Option < String > ,
55+ #[ argp( option, short = 'c' ) ]
56+ /// Configuration property (key=value)
57+ config : Vec < String > ,
5558}
5659
5760#[ derive( FromArgs , PartialEq , Debug ) ]
@@ -80,6 +83,12 @@ pub fn run(args: Args) -> Result<()> {
8083}
8184
8285fn generate ( args : GenerateArgs ) -> Result < ( ) > {
86+ let mut diff_config = diff:: DiffObjConfig {
87+ function_reloc_diffs : diff:: FunctionRelocDiffs :: None ,
88+ ..Default :: default ( )
89+ } ;
90+ apply_config_args ( & mut diff_config, & args. config ) ?;
91+
8392 let output_format = OutputFormat :: from_option ( args. format . as_deref ( ) ) ?;
8493 let project_dir = args. project . as_deref ( ) . unwrap_or_else ( || Utf8PlatformPath :: new ( "." ) ) ;
8594 info ! ( "Loading project {}" , project_dir) ;
@@ -114,14 +123,15 @@ fn generate(args: GenerateArgs) -> Result<()> {
114123 if args. deduplicate {
115124 // If deduplicating, we need to run single-threaded
116125 for object in & objects {
117- if let Some ( unit) = report_object ( object, Some ( & mut existing_functions) ) ? {
126+ if let Some ( unit) = report_object ( object, & diff_config, Some ( & mut existing_functions) ) ?
127+ {
118128 units. push ( unit) ;
119129 }
120130 }
121131 } else {
122132 let vec = objects
123133 . par_iter ( )
124- . map ( |object| report_object ( object, None ) )
134+ . map ( |object| report_object ( object, & diff_config , None ) )
125135 . collect :: < Result < Vec < Option < ReportUnit > > > > ( ) ?;
126136 units = vec. into_iter ( ) . flatten ( ) . collect ( ) ;
127137 }
@@ -145,6 +155,7 @@ fn generate(args: GenerateArgs) -> Result<()> {
145155
146156fn report_object (
147157 object : & ObjectConfig ,
158+ diff_config : & diff:: DiffObjConfig ,
148159 mut existing_functions : Option < & mut HashSet < String > > ,
149160) -> Result < Option < ReportUnit > > {
150161 match ( & object. target_path , & object. base_path ) {
@@ -158,29 +169,25 @@ fn report_object(
158169 }
159170 _ => { }
160171 }
161- let diff_config = diff:: DiffObjConfig {
162- function_reloc_diffs : diff:: FunctionRelocDiffs :: None ,
163- ..Default :: default ( )
164- } ;
165172 let mapping_config = diff:: MappingConfig :: default ( ) ;
166173 let target = object
167174 . target_path
168175 . as_ref ( )
169176 . map ( |p| {
170- obj:: read:: read ( p. as_ref ( ) , & diff_config)
177+ obj:: read:: read ( p. as_ref ( ) , diff_config)
171178 . with_context ( || format ! ( "Failed to open {}" , p) )
172179 } )
173180 . transpose ( ) ?;
174181 let base = object
175182 . base_path
176183 . as_ref ( )
177184 . map ( |p| {
178- obj:: read:: read ( p. as_ref ( ) , & diff_config)
185+ obj:: read:: read ( p. as_ref ( ) , diff_config)
179186 . with_context ( || format ! ( "Failed to open {}" , p) )
180187 } )
181188 . transpose ( ) ?;
182189 let result =
183- diff:: diff_objs ( target. as_ref ( ) , base. as_ref ( ) , None , & diff_config, & mapping_config) ?;
190+ diff:: diff_objs ( target. as_ref ( ) , base. as_ref ( ) , None , diff_config, & mapping_config) ?;
184191
185192 let metadata = ReportUnitMetadata {
186193 complete : object. metadata . complete ,
0 commit comments