diff --git a/libc/kernel/tools/clean_header.py b/libc/kernel/tools/clean_header.py index 88b2ae008..92a213920 100755 --- a/libc/kernel/tools/clean_header.py +++ b/libc/kernel/tools/clean_header.py @@ -152,8 +152,8 @@ if __name__ == "__main__": usage() no_update = True - dst_dir = get_kernel_dir() - src_dir = get_kernel_headers_original_dir() + dst_dir = None + src_dir = None for opt, arg in optlist: if opt == '-u': no_update = False @@ -163,6 +163,15 @@ if __name__ == "__main__": src_dir = arg elif opt == '-d': dst_dir = arg + # get_kernel_dir() and get_kernel_headers_original_dir() require the current + # working directory to be a direct or indirect subdirectory of + # ANDROID_BUILD_TOP. Otherwise, these functions print an error message and + # exit. Let's allow the user to run this program from an unrelated + # directory, if they specify src_dir and dst_dir on the command line. + if dst_dir is None: + dst_dir = get_kernel_dir() + if src_dir is None: + src_dir = get_kernel_headers_original_dir() if len(args) == 0: usage()