Add support for manually modified kernel headers.
This changes the scripts so that if some kernel files exists
in external/kernel-headers/modified, that they will be preferred
over the same files found in original. This is to support the case
where the kernel headers cannot be taken without some small modifications.
Included with this change, is a general cleanup of the python scripts.
This also modifies the generate uapi headers script to indicate if the
source of the modified headers has changed.
Change-Id: Id13523b244ced52a2ecd9f1399c43996dd8296fa
diff --git a/libc/kernel/tools/utils.py b/libc/kernel/tools/utils.py
index e5a310e..e2cc9ce 100644
--- a/libc/kernel/tools/utils.py
+++ b/libc/kernel/tools/utils.py
@@ -13,8 +13,26 @@
sys.exit(1)
-def find_program_dir():
- return os.path.dirname(sys.argv[0])
+def get_kernel_headers_dir():
+ return os.path.join(get_android_root(), "external/kernel-headers")
+
+
+def get_kernel_headers_original_dir():
+ return os.path.join(get_kernel_headers_dir(), "original")
+
+
+def get_kernel_headers_modified_dir():
+ return os.path.join(get_kernel_headers_dir(), "modified")
+
+
+def get_kernel_dir():
+ return os.path.join(get_android_root(), "bionic/libc/kernel")
+
+
+def get_android_root():
+ if "ANDROID_BUILD_TOP" in os.environ:
+ return os.environ["ANDROID_BUILD_TOP"]
+ panic("Unable to find root of tree, did you forget to lunch a target?")
class StringOutput: