From e38d42fc7dc58318da91b1347124f937637e2451 Mon Sep 17 00:00:00 2001 From: Alexander Thomas Date: Wed, 28 Oct 2020 16:25:05 +0000 Subject: [PATCH] [android] Switch to Flutter Android tooling Flutter uses CIPD packages that are more reliable. Change-Id: Ic47b2fd9805709a3175376270df0fe52b82f16ad Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/169341 Commit-Queue: Alexander Thomas Reviewed-by: Daco Harkes Reviewed-by: Martin Kustermann --- DEPS | 63 ++++++++++++-- tools/android/VERSION_LINUX_NDK | 1 - tools/android/VERSION_LINUX_SDK | 1 - tools/android/VERSION_MACOSX_NDK | 1 - tools/android/VERSION_MACOSX_SDK | 1 - tools/android/download_android_tools.py | 107 ------------------------ 6 files changed, 58 insertions(+), 116 deletions(-) delete mode 100644 tools/android/VERSION_LINUX_NDK delete mode 100644 tools/android/VERSION_LINUX_SDK delete mode 100644 tools/android/VERSION_MACOSX_NDK delete mode 100644 tools/android/VERSION_MACOSX_SDK delete mode 100644 tools/android/download_android_tools.py diff --git a/DEPS b/DEPS index 7aa37fc7841..610a69f358a 100644 --- a/DEPS +++ b/DEPS @@ -51,6 +51,9 @@ vars = { "benchmarks_internal_rev": "354c978979c57e4a76f62e22cf644ed0804f4421", "checkout_benchmarks_internal": False, + # Checkout Android dependencies only on Mac and Linux. + "download_android_deps": 'host_os == "mac" or host_os == "linux"', + # As Flutter does, we use Fuchsia's GN and Clang toolchain. These revision # should be kept up to date with the revisions pulled by the Flutter engine. # The list of revisions for these tools comes from Fuchsia, here: @@ -491,6 +494,61 @@ deps = { "dep_type": "cipd", }, + Var("dart_root") + "/third_party/android_tools/ndk": { + "packages": [ + { + "package": "flutter/android/ndk/${{platform}}", + "version": "version:r21.0.6113669" + } + ], + "condition": "download_android_deps", + "dep_type": "cipd", + }, + + Var("dart_root") + "/third_party/android_tools/sdk/build-tools": { + "packages": [ + { + "package": "flutter/android/sdk/build-tools/${{platform}}", + "version": "version:30.0.1" + } + ], + "condition": "download_android_deps", + "dep_type": "cipd", + }, + + Var("dart_root") + "/third_party/android_tools/sdk/platform-tools": { + "packages": [ + { + "package": "flutter/android/sdk/platform-tools/${{platform}}", + "version": "version:29.0.2" + } + ], + "condition": "download_android_deps", + "dep_type": "cipd", + }, + + Var("dart_root") + "/third_party/android_tools/sdk/platforms": { + "packages": [ + { + "package": "flutter/android/sdk/platforms", + "version": "version:30r3" + } + ], + "condition": "download_android_deps", + "dep_type": "cipd", + }, + + Var("dart_root") + "/third_party/android_tools/sdk/tools": { + "packages": [ + { + "package": "flutter/android/sdk/tools/${{platform}}", + "version": "version:26.1.1" + } + ], + "condition": "download_android_deps", + "dep_type": "cipd", + }, + Var("dart_root") + "/buildtools/" + Var("host_os") + "-" + Var("host_cpu") + "/rust": { "packages": [ { @@ -639,11 +697,6 @@ hooks = [ 'action': ['python', 'sdk/build/linux/sysroot_scripts/install-sysroot.py', '--arch', 'arm64'], }, - { - 'name': 'download_android_tools', - 'pattern': '.', - 'action': ['python', 'sdk/tools/android/download_android_tools.py'], - }, { 'name': 'buildtools', 'pattern': '.', diff --git a/tools/android/VERSION_LINUX_NDK b/tools/android/VERSION_LINUX_NDK deleted file mode 100644 index 4fac77be7b6..00000000000 --- a/tools/android/VERSION_LINUX_NDK +++ /dev/null @@ -1 +0,0 @@ -e626c47cb82a7439b0eda03ac6e0e9e1e41c6093 diff --git a/tools/android/VERSION_LINUX_SDK b/tools/android/VERSION_LINUX_SDK deleted file mode 100644 index d24f5c1f6ea..00000000000 --- a/tools/android/VERSION_LINUX_SDK +++ /dev/null @@ -1 +0,0 @@ -0d320c50b0ed188c7e1182388e2beb623a1d307d diff --git a/tools/android/VERSION_MACOSX_NDK b/tools/android/VERSION_MACOSX_NDK deleted file mode 100644 index bd19b05e9b3..00000000000 --- a/tools/android/VERSION_MACOSX_NDK +++ /dev/null @@ -1 +0,0 @@ -e8b6ecb5d15c4c4018a62b52aabc13e41b17df8f diff --git a/tools/android/VERSION_MACOSX_SDK b/tools/android/VERSION_MACOSX_SDK deleted file mode 100644 index 2441d725226..00000000000 --- a/tools/android/VERSION_MACOSX_SDK +++ /dev/null @@ -1 +0,0 @@ -fa5ea0ca1e0c7c2e40914f3202c7545de4dbca9c diff --git a/tools/android/download_android_tools.py b/tools/android/download_android_tools.py deleted file mode 100644 index b264e58c8a3..00000000000 --- a/tools/android/download_android_tools.py +++ /dev/null @@ -1,107 +0,0 @@ -#!/usr/bin/env python -# Copyright 2017 The Dart project authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# Downloads trimmed-down Android Tools from Google Cloud Storage and extracts -# them to INSTALL_DIR, updating INSTALL_DIR/VERSION_* stamp files with current -# version. Does nothing if INSTALL_DIR/VERSION_* are already up to date. - -import os -import shutil -import subprocess -import sys -import tarfile - -# Path constants. (All of these should be absolute paths.) -THIS_DIR = os.path.abspath(os.path.dirname(__file__)) -DART_ROOT = os.path.abspath(os.path.join(THIS_DIR, '..', '..')) -# Should be the same as in upload.py. -INSTALL_DIR = os.path.join(DART_ROOT, 'third_party', 'android_tools') - -sys.path.insert(0, os.path.join(DART_ROOT, 'tools')) -import find_depot_tools - -DEPOT_PATH = find_depot_tools.add_depot_tools_to_path() -GSUTIL_PATH = os.path.join(DEPOT_PATH, 'gsutil.py') - - -def RunCommand(command): - """Run command and return success (True) or failure.""" - - print 'Running %s' % (str(command)) - if subprocess.call(command, shell=False) == 0: - return True - print 'Failed.' - return False - - -def GetInstalledVersion(version_stamp): - version_file = os.path.join(INSTALL_DIR, version_stamp) - if not os.path.exists(version_file): - return None - with open(version_file) as f: - return f.read().strip() - - -def VersionStampName(tools_name): - if sys.platform.startswith('linux'): - return 'VERSION_LINUX_' + tools_name.upper() - elif sys.platform == 'darwin': - return 'VERSION_MACOSX_' + tools_name.upper() - else: - print('NOTE: Will not download android tools. Unsupported platform: ' + - sys.platform) - sys.exit(0) - - -def UpdateTools(tools_name): - """Downloads zipped tools from Google Cloud Storage and extracts them, - stamping current version.""" - - # Read latest version. - version_stamp = VersionStampName(tools_name) - version = '' - with open(os.path.join(THIS_DIR, version_stamp)) as f: - version = f.read().strip() - # Return if installed binaries are up to date. - if version == GetInstalledVersion(version_stamp): - return - - # Remove the old install directory checked out from git. - if os.path.exists(os.path.join(INSTALL_DIR, '.git')): - shutil.rmtree(INSTALL_DIR) - # Make sure that the install directory exists. - if not os.path.exists(INSTALL_DIR): - os.mkdir(INSTALL_DIR) - # Remove current installation. - tools_root = os.path.join(INSTALL_DIR, tools_name) - if os.path.exists(tools_root): - shutil.rmtree(tools_root) - - # Download tools from GCS. - archive_path = os.path.join(INSTALL_DIR, tools_name + '.tar.gz') - download_cmd = [ - 'python', GSUTIL_PATH, 'cp', - 'gs://mojo/android/tool/%s.tar.gz' % version, archive_path - ] - if not RunCommand(download_cmd): - print('WARNING: Failed to download Android tools.') - return - - print "Extracting Android tools (" + tools_name + ")" - with tarfile.open(archive_path) as arch: - arch.extractall(INSTALL_DIR) - os.remove(archive_path) - # Write version as the last step. - with open(os.path.join(INSTALL_DIR, version_stamp), 'w+') as f: - f.write('%s\n' % version) - - -def main(): - UpdateTools('sdk') - UpdateTools('ndk') - - -if __name__ == '__main__': - sys.exit(main())