@@ -90,8 +90,8 @@ def make_absolute(f, directory):
90
90
91
91
def get_tidy_invocation (f , clang_tidy_binary , checks , tmpdir , build_path ,
92
92
header_filter , allow_enabling_alpha_checkers ,
93
- extra_arg , extra_arg_before , quiet , config ,
94
- line_filter , use_color ):
93
+ extra_arg , extra_arg_before , quiet , config_path ,
94
+ config , line_filter , use_color ):
95
95
"""Gets a command line for clang-tidy."""
96
96
start = [clang_tidy_binary ]
97
97
if allow_enabling_alpha_checkers :
@@ -121,7 +121,9 @@ def get_tidy_invocation(f, clang_tidy_binary, checks, tmpdir, build_path,
121
121
start .append ('-p=' + build_path )
122
122
if quiet :
123
123
start .append ('-quiet' )
124
- if config :
124
+ if config_path :
125
+ start .append ('--config-file=' + config_path )
126
+ elif config :
125
127
start .append ('-config=' + config )
126
128
start .append (f )
127
129
return start
@@ -192,8 +194,8 @@ def run_tidy(args, clang_tidy_binary, tmpdir, build_path, queue, lock,
192
194
tmpdir , build_path , args .header_filter ,
193
195
args .allow_enabling_alpha_checkers ,
194
196
args .extra_arg , args .extra_arg_before ,
195
- args .quiet , args .config , args .line_filter ,
196
- args .use_color )
197
+ args .quiet , args .config_path , args .config ,
198
+ args .line_filter , args . use_color )
197
199
198
200
proc = subprocess .Popen (invocation , stdout = subprocess .PIPE , stderr = subprocess .PIPE )
199
201
output , err = proc .communicate ()
@@ -225,14 +227,21 @@ def main():
225
227
parser .add_argument ('-checks' , default = None ,
226
228
help = 'checks filter, when not specified, use clang-tidy '
227
229
'default' )
228
- parser .add_argument ('-config' , default = None ,
230
+ config_group = parser .add_mutually_exclusive_group ()
231
+ config_group .add_argument ('-config' , default = None ,
229
232
help = 'Specifies a configuration in YAML/JSON format: '
230
233
' -config="{Checks: \' *\' , '
231
234
' CheckOptions: [{key: x, '
232
235
' value: y}]}" '
233
236
'When the value is empty, clang-tidy will '
234
237
'attempt to find a file named .clang-tidy for '
235
238
'each source file in its parent directories.' )
239
+ config_group .add_argument ('-config-file' , default = None ,
240
+ help = 'Specify the path of .clang-tidy or custom config '
241
+ 'file: e.g. -config-file=/some/path/myTidyConfigFile. '
242
+ 'This option internally works exactly the same way as '
243
+ '-config option after reading specified config file. '
244
+ 'Use either -config-file or -config, not both.' )
236
245
parser .add_argument ('-header-filter' , default = None ,
237
246
help = 'regular expression matching the names of the '
238
247
'headers to output diagnostics from. Diagnostics from '
@@ -295,8 +304,8 @@ def main():
295
304
None , build_path , args .header_filter ,
296
305
args .allow_enabling_alpha_checkers ,
297
306
args .extra_arg , args .extra_arg_before ,
298
- args .quiet , args .config , args .line_filter ,
299
- args .use_color )
307
+ args .quiet , args .config_path , args .config ,
308
+ args .line_filter , args . use_color )
300
309
invocation .append ('-list-checks' )
301
310
invocation .append ('-' )
302
311
if args .quiet :
0 commit comments