Refactor the kernel update scripts.
The previous versions of the scripts did a lot of redundant changes
and were hard to follow.
I rewrote most of update_all.py so that it's clear about what's going on.
I updated clean_header.py to change the cleanupFile function so that
there is no magic about where the destination file is going to wind up.
Now the caller specifies the final location.
I updated utils.py so that if you are trying to do an update in one
location, but your lunch target is from another location, it causes
an error.
Bug: 35726570
Change-Id: Ic5a44d90c2774a627eecde34c0c403bc925a497c
Test: Ran the updater and verified it works properly.
Test: Verified that doing an update in one tree to another tree
Test: fails.
diff --git a/libc/kernel/tools/utils.py b/libc/kernel/tools/utils.py
index e2cc9ce..1b06b1b 100644
--- a/libc/kernel/tools/utils.py
+++ b/libc/kernel/tools/utils.py
@@ -31,8 +31,14 @@
def get_android_root():
if "ANDROID_BUILD_TOP" in os.environ:
+ # Verify that the current directory is in the root.
+ # If not, then print an error.
+ cwd = os.getcwd()
+ root = os.environ["ANDROID_BUILD_TOP"]
+ if len(cwd) < len(root) or not root == cwd[:len(root)]:
+ panic("Not in android tree pointed at by ANDROID_BUILD_TOP (%s)\n" % root)
return os.environ["ANDROID_BUILD_TOP"]
- panic("Unable to find root of tree, did you forget to lunch a target?")
+ panic("Unable to find root of tree, did you forget to lunch a target?\n")
class StringOutput: