Commit 6fca36f1 authored by Masahiro Yamada's avatar Masahiro Yamada

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().
Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
parent 0a7d376d
...@@ -39,11 +39,13 @@ def parse_arguments(): ...@@ -39,11 +39,13 @@ def parse_arguments():
directory_help = ('specify the output directory used for the kernel build ' directory_help = ('specify the output directory used for the kernel build '
'(defaults to the working directory)') '(defaults to the working directory)')
parser.add_argument('-d', '--directory', type=str, help=directory_help) parser.add_argument('-d', '--directory', type=str, default='.',
help=directory_help)
output_help = ('The location to write compile_commands.json (defaults to ' output_help = ('path to the output command database (defaults to ' +
'compile_commands.json in the search directory)') _DEFAULT_OUTPUT + ')')
parser.add_argument('-o', '--output', type=str, help=output_help) parser.add_argument('-o', '--output', type=str, default=_DEFAULT_OUTPUT,
help=output_help)
log_level_help = ('the level of log messages to produce (defaults to ' + log_level_help = ('the level of log messages to produce (defaults to ' +
_DEFAULT_LOG_LEVEL + ')') _DEFAULT_LOG_LEVEL + ')')
...@@ -52,11 +54,9 @@ def parse_arguments(): ...@@ -52,11 +54,9 @@ def parse_arguments():
args = parser.parse_args() args = parser.parse_args()
directory = args.directory or os.getcwd() return (args.log_level,
output = args.output or os.path.join(directory, _DEFAULT_OUTPUT) os.path.abspath(args.directory),
directory = os.path.abspath(directory) args.output)
return args.log_level, directory, output
def process_line(root_directory, command_prefix, file_path): def process_line(root_directory, command_prefix, file_path):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment