clean_header: Run outside of $ANDROID_BUILD_TOP

Enable the use case where we run clean_header.py from outside of
$ANDROID_BUILD_TOP. Previously, this script required the current working
directory to be under $ANDROID_BUILD_TOP. Running it from a different
directory resulted in the following error message:

 clean_header.py: error: Not in android tree pointed at by ANDROID_BUILD_TOP (....)

Change-Id: I48210ea1a0033228a9aaa4124d28247b07cee6d4
This commit is contained in:
Daniel Mentz 2019-04-15 15:19:31 -07:00
parent 6d6b4cedd1
commit d12d6f67bc

View file

@ -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()