aboutsummaryrefslogtreecommitdiff
path: root/checkbuild.py
diff options
context:
space:
mode:
authorDan Albert <danalbert@google.com>2018-11-09 12:13:23 -0800
committerDan Albert <danalbert@google.com>2018-11-09 14:03:19 -0800
commit7edf9e6c9673deb004899c66ac1c233b1e26453e (patch)
treee1d64bd773300f30076ff33f716b9ee6082f5117 /checkbuild.py
parentaa5bfe04d9a99a979c0cbd51206120b0e908c2f1 (diff)
downloadndk-7edf9e6c9673deb004899c66ac1c233b1e26453e.tar.gz
Bootstrap checkbuild.py with Python 3.
This allows us to implement checkbuild.py and its associated pieces exclusively in Python 3 even though it isn't available on the build servers. The version currently available in external/python/cpython3 is 3.6, so this gets us features even as new as type annotations and f-strings. On my P920 the bootstrapping step takes about a minute. When bootstrapping is complete a .bootstrapped file is placed in the out directory to avoid rebuilding Python every time. We can't go through our existing Python 2 as an intermediate step because we can't build the SSL (and therefore the hashlib) module for that version of Python because it's not compatible with whatever is on these machines (which might be BoringSSL?). Test: ./checkbuild.py Bug: None Change-Id: Ie01a586cdbfaf22da3025aabbc3ed931480b7742
Diffstat (limited to 'checkbuild.py')
-rwxr-xr-xcheckbuild.py31
1 files changed, 28 insertions, 3 deletions
diff --git a/checkbuild.py b/checkbuild.py
index a718f6b9b..d85a719e4 100755
--- a/checkbuild.py
+++ b/checkbuild.py
@@ -19,20 +19,45 @@
Differs from do_checkbuild.py because it launches a new Python interpreter,
allowing this script to bootstrap our build with a specific version of Python.
"""
+import argparse
+import logging
+import os
import subprocess
import sys
+import ndk.bootstrap
import ndk.paths
+def parse_args():
+ """Parses and returns command line arguments."""
+ parser = argparse.ArgumentParser()
+ parser.add_argument(
+ '-v',
+ '--verbose',
+ action='count',
+ dest='verbosity',
+ help='Increase logging verbosity.')
+ return parser.parse_known_args()
+
+
def main():
"""Program entry point.
Bootstraps the real checkbuild wrapper, do_checkbuild.py.
"""
- subprocess.check_call(
- ['/usr/bin/env', 'python',
- ndk.paths.ndk_path('do_checkbuild.py')] + sys.argv[1:])
+ args, _ = parse_args()
+
+ if args.verbosity >= 2:
+ logging.basicConfig(level=logging.DEBUG)
+ else:
+ logging.basicConfig(level=logging.INFO)
+
+ python_install = ndk.bootstrap.bootstrap()
+ subprocess.check_call([
+ os.path.join(python_install, 'bin/python3'),
+ ndk.paths.ndk_path('do_checkbuild.py')
+ ] + sys.argv[1:])
if __name__ == '__main__':