diff options
author | Simon Sapin <simon.sapin@exyr.org> | 2018-06-28 16:21:09 +0200 |
---|---|---|
committer | Simon Sapin <simon.sapin@exyr.org> | 2018-07-02 13:25:44 +0200 |
commit | aa1c3cea2fbf8c0907bda54ac4183d7fc878b33e (patch) | |
tree | 827446156c1cc2294adf4455a6577deae208267e /python/servo | |
parent | 0e2e9cb019e73abcabe7907c4890c6bd96b9b607 (diff) | |
download | servo-aa1c3cea2fbf8c0907bda54ac4183d7fc878b33e.tar.gz servo-aa1c3cea2fbf8c0907bda54ac4183d7fc878b33e.zip |
bootstrap-android: use predictable paths for SDK and NDK
… independent of the version number
Diffstat (limited to 'python/servo')
-rw-r--r-- | python/servo/bootstrap_commands.py | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/python/servo/bootstrap_commands.py b/python/servo/bootstrap_commands.py index 950dc3f0213..da887830a98 100644 --- a/python/servo/bootstrap_commands.py +++ b/python/servo/bootstrap_commands.py @@ -77,8 +77,8 @@ class MachCommands(CommandBase): if not path.isdir(toolchains): os.makedirs(toolchains) - def download(name): - final = path.join(toolchains, name) + def download(name, target_dir, flatten=False): + final = path.join(toolchains, target_dir) if path.isdir(final): return final @@ -90,15 +90,23 @@ class MachCommands(CommandBase): if not path.isfile(archive): download_file(filename, url, archive) print("Extracting " + filename) - remove = True # Set to False to avoid repeated downloads while debugging this script - extract(archive, final, remove=remove) + remove = False # Set to False to avoid repeated downloads while debugging this script + if flatten: + extracted = final + "_" + extract(archive, extracted, remove=remove) + contents = os.listdir(extracted) + assert len(contents) == 1 + os.rename(path.join(extracted, contents[0]), final) + os.rmdir(extracted) + else: + extract(archive, final, remove=remove) return final system = platform.system().lower() machine = platform.machine().lower() arch = {"i386": "x86"}.get(machine, machine) - ndk_path = download(ndk.format(system=system, arch=arch)) - tools_path = download(tools.format(system=system)) + ndk_path = download(ndk.format(system=system, arch=arch), "ndk", flatten=True) + tools_path = download(tools.format(system=system), "sdk") if update or not path.isdir(path.join(tools_path, "platform-tools")): subprocess.check_call([ @@ -141,10 +149,6 @@ class MachCommands(CommandBase): with open(path.join(toolchains, "avd", avd_name, "config.ini"), "a") as f: f.write("disk.dataPartition.size=1G\n") - contents = os.listdir(ndk_path) - assert len(contents) == 1 - ndk_path = path.join(ndk_path, contents[0]) - print("") print("export ANDROID_SDK=\"%s\"" % tools_path) print("export ANDROID_NDK=\"%s\"" % ndk_path) |