History

gen_compile_commands: make -o option independent of -d option

Change the -o option independent of the -d option, which is I think clearer behavior. Some people may like to use -d to specify a separate output directory, but still output the compile_commands.py in the source directory (unless the source tree is read-only) because it is the default location Clang Tools search for the compilation database. Also, move the default parameter to the default= argument of the .add_argument().

Masahiro Yamada committed 6 years ago

Commit 6fca36f1 parent 0a7d3761 file · +9 −9Browse files

Unified · Split

scripts/gen_compile_commands.py+9−9
@@ -39,11 +39,13 @@ def parse_arguments(): · 38 unmodified lines
3939
4040 directory_help = ('specify the output directory used for the kernel build '
4141 '(defaults to the working directory)')
42− parser.add_argument('-d', '--directory', type=str, help=directory_help)
42+ parser.add_argument('-d', '--directory', type=str, default='.',
43+ help=directory_help)
4344
44− output_help = ('The location to write compile_commands.json (defaults to '
45− 'compile_commands.json in the search directory)')
46− parser.add_argument('-o', '--output', type=str, help=output_help)
45+ output_help = ('path to the output command database (defaults to ' +
46+ _DEFAULT_OUTPUT + ')')
47+ parser.add_argument('-o', '--output', type=str, default=_DEFAULT_OUTPUT,
48+ help=output_help)
4749
4850 log_level_help = ('the level of log messages to produce (defaults to ' +
4951 _DEFAULT_LOG_LEVEL + ')')
@@ -52,11 +54,9 @@ def parse_arguments(): · 2 unmodified lines
5254
5355 args = parser.parse_args()
5456
55− directory = args.directory or os.getcwd()
56− output = args.output or os.path.join(directory, _DEFAULT_OUTPUT)
57− directory = os.path.abspath(directory)
58−
59− return args.log_level, directory, output
57+ return (args.log_level,
58+ os.path.abspath(args.directory),
59+ args.output)
6060
6161
6262 def process_line(root_directory, command_prefix, file_path):