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().
Showing the changes to scripts (1 of 1 file). Show all
Unified · Split
| @@ -39,11 +39,13 @@ def parse_arguments(): · 38 unmodified lines | ||
| 39 | 39 | |
| 40 | 40 | directory_help = ('specify the output directory used for the kernel build ' |
| 41 | 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 | − '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) | |
| 47 | 49 | |
| 48 | 50 | log_level_help = ('the level of log messages to produce (defaults to ' + |
| 49 | 51 | _DEFAULT_LOG_LEVEL + ')') |
| @@ -52,11 +54,9 @@ def parse_arguments(): · 2 unmodified lines | ||
| 52 | 54 | |
| 53 | 55 | args = parser.parse_args() |
| 54 | 56 | |
| 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) | |
| 60 | 60 | |
| 61 | 61 | |
| 62 | 62 | def process_line(root_directory, command_prefix, file_path): |