@@ -17,7 +17,7 @@ use tracing::{info, warn};
17
17
use typed_path:: { Utf8PlatformPath , Utf8PlatformPathBuf } ;
18
18
19
19
use crate :: {
20
- cmd:: diff:: ObjectConfig ,
20
+ cmd:: { apply_config_args , diff:: ObjectConfig } ,
21
21
util:: output:: { OutputFormat , write_output} ,
22
22
} ;
23
23
@@ -52,6 +52,9 @@ pub struct GenerateArgs {
52
52
#[ argp( option, short = 'f' ) ]
53
53
/// Output format (json, json-pretty, proto) (default: json)
54
54
format : Option < String > ,
55
+ #[ argp( option, short = 'c' ) ]
56
+ /// Configuration property (key=value)
57
+ config : Vec < String > ,
55
58
}
56
59
57
60
#[ derive( FromArgs , PartialEq , Debug ) ]
@@ -80,6 +83,12 @@ pub fn run(args: Args) -> Result<()> {
80
83
}
81
84
82
85
fn 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
+
83
92
let output_format = OutputFormat :: from_option ( args. format . as_deref ( ) ) ?;
84
93
let project_dir = args. project . as_deref ( ) . unwrap_or_else ( || Utf8PlatformPath :: new ( "." ) ) ;
85
94
info ! ( "Loading project {}" , project_dir) ;
@@ -114,14 +123,15 @@ fn generate(args: GenerateArgs) -> Result<()> {
114
123
if args. deduplicate {
115
124
// If deduplicating, we need to run single-threaded
116
125
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
+ {
118
128
units. push ( unit) ;
119
129
}
120
130
}
121
131
} else {
122
132
let vec = objects
123
133
. par_iter ( )
124
- . map ( |object| report_object ( object, None ) )
134
+ . map ( |object| report_object ( object, & diff_config , None ) )
125
135
. collect :: < Result < Vec < Option < ReportUnit > > > > ( ) ?;
126
136
units = vec. into_iter ( ) . flatten ( ) . collect ( ) ;
127
137
}
@@ -145,6 +155,7 @@ fn generate(args: GenerateArgs) -> Result<()> {
145
155
146
156
fn report_object (
147
157
object : & ObjectConfig ,
158
+ diff_config : & diff:: DiffObjConfig ,
148
159
mut existing_functions : Option < & mut HashSet < String > > ,
149
160
) -> Result < Option < ReportUnit > > {
150
161
match ( & object. target_path , & object. base_path ) {
@@ -158,29 +169,25 @@ fn report_object(
158
169
}
159
170
_ => { }
160
171
}
161
- let diff_config = diff:: DiffObjConfig {
162
- function_reloc_diffs : diff:: FunctionRelocDiffs :: None ,
163
- ..Default :: default ( )
164
- } ;
165
172
let mapping_config = diff:: MappingConfig :: default ( ) ;
166
173
let target = object
167
174
. target_path
168
175
. as_ref ( )
169
176
. map ( |p| {
170
- obj:: read:: read ( p. as_ref ( ) , & diff_config)
177
+ obj:: read:: read ( p. as_ref ( ) , diff_config)
171
178
. with_context ( || format ! ( "Failed to open {}" , p) )
172
179
} )
173
180
. transpose ( ) ?;
174
181
let base = object
175
182
. base_path
176
183
. as_ref ( )
177
184
. map ( |p| {
178
- obj:: read:: read ( p. as_ref ( ) , & diff_config)
185
+ obj:: read:: read ( p. as_ref ( ) , diff_config)
179
186
. with_context ( || format ! ( "Failed to open {}" , p) )
180
187
} )
181
188
. transpose ( ) ?;
182
189
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) ?;
184
191
185
192
let metadata = ReportUnitMetadata {
186
193
complete : object. metadata . complete ,
0 commit comments