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
39 39
40 directory_help = ('specify the output directory used for the kernel build '40 directory_help = ('specify the output directory used for the kernel build '
41 '(defaults to the working directory)')41 '(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)
43 44
44 output_help = ('The location to write compile_commands.json (defaults to '45 output_help = ('path to the output command database (defaults to ' +
45 'compile_commands.json in the search directory)')46 _DEFAULT_OUTPUT + ')')
46 parser.add_argument('-o', '--output', type=str, help=output_help)47 parser.add_argument('-o', '--output', type=str, default=_DEFAULT_OUTPUT,
48 help=output_help)
47 49
48 log_level_help = ('the level of log messages to produce (defaults to ' +50 log_level_help = ('the level of log messages to produce (defaults to ' +
49 _DEFAULT_LOG_LEVEL + ')')51 _DEFAULT_LOG_LEVEL + ')')
@@ -52,11 +54,9 @@ def parse_arguments(): · 2 unmodified lines
52 54
53 args = parser.parse_args()55 args = parser.parse_args()
54 56
55 directory = args.directory or os.getcwd()57 return (args.log_level,
56 output = args.output or os.path.join(directory, _DEFAULT_OUTPUT)58 os.path.abspath(args.directory),
57 directory = os.path.abspath(directory)59 args.output)
58
59 return args.log_level, directory, output
60 60
61 61
62def process_line(root_directory, command_prefix, file_path):62def process_line(root_directory, command_prefix, file_path):