Index: third_party/libadblockplus_android/prepare_build_tools.py |
diff --git a/third_party/libadblockplus_android/prepare_build_tools.py b/third_party/libadblockplus_android/prepare_build_tools.py |
index f3dacec733929505eb613c4469168209bdcbd8bf..e50de5a05f9a8d119439bcff0bd026451458fca0 100644 |
--- a/third_party/libadblockplus_android/prepare_build_tools.py |
+++ b/third_party/libadblockplus_android/prepare_build_tools.py |
@@ -3,12 +3,33 @@ import urllib |
import zipfile |
import sys |
import subprocess |
+import shutil |
+ |
+def get_dst_path(): |
+ cwd = os.getcwd() |
+ return os.path.join(cwd, 'src', 'third_party', 'libadblockplus_android', 'third_party', 'android_sdk') |
+ |
+def duplicate_sdk(): |
+ cwd = os.getcwd() |
+ sdk_src = os.path.join(cwd, 'src', 'third_party', 'android_tools', 'sdk') |
+ sdk_dst = get_dst_path() |
+ |
+ if os.path.exists(sdk_dst): |
+ print('Deleting %s' % sdk_dst) |
+ shutil.rmtree(sdk_dst) |
+ else: |
+ dst_parent = os.path.abspath(os.path.join(sdk_dst, os.pardir)) |
+ print('Creating %s' % dst_parent) |
+ os.makedirs(dst_parent) |
+ |
+ print('Copying Android SDK from %s to %s' % (sdk_src, sdk_dst)) |
+ shutil.copytree(sdk_src, sdk_dst) |
def install(title, package, version, verbose=False): |
print('Installing %s ...' % title) |
cwd = os.getcwd() |
- sdk_root = os.path.join(cwd, 'src', 'third_party', 'android_tools', 'sdk') |
+ sdk_root = get_dst_path() |
sdkmanager = os.path.join(sdk_root, 'tools', 'bin', 'sdkmanager') |
args = [ |
@@ -31,6 +52,8 @@ def install(title, package, version, verbose=False): |
return process.returncode |
def main(argv): |
+ duplicate_sdk() |
+ |
# TODO: update when different version of built-tools and platform are required |
bt25 = install("Build tools", "build-tools", "25.0.0", True) |
if bt25 != 0: |