New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add mach bootstrap-android and test-android-startup commands #21094
Merged
+292
−14
Merged
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
b9d5f11
Add `./mach bootstrap-android`
SimonSapin 510cf1a
boostrap: set executable bits when extracting zip files
SimonSapin 56df7f4
Install complete Android SDK (as much as on Buildbot CI)
SimonSapin 244a332
Use more recent Android tools
SimonSapin 1ee54ab
Create and Android virtual device
SimonSapin 8889742
mach bootstrap-android: configure and show how to start an emulator
SimonSapin fe24816
mach run --android: show PID
SimonSapin 4cbf3de
mach {package,install} --android: add --emulator and --usb
SimonSapin eab971c
Android cross-compiled command line hello world
SimonSapin 90ba22b
egl-configs: link to EGL and generate bindings
SimonSapin 89f6c6d
egl-configs: get the number of configs
SimonSapin 7e7316e
egl-configs: print all config attributes
SimonSapin 1f8d04b
egl-configs: print hex too
SimonSapin 6e68705
cargo run into Android/adb: configurable target device
SimonSapin 484eee8
Tidy
SimonSapin 3c992af
Remove debugging println from a year ago
SimonSapin 7d7f202
Fix copy/paste mistake
SimonSapin b7a8b81
egl-configs: add i686 support
SimonSapin f4d740f
Typo fixes
SimonSapin e54ad77
Do not prompt for Android emulator hardware profile
SimonSapin 0e2e9cb
Create emulator images for both ARM and x86
SimonSapin aa1c3ce
bootstrap-android: use predictable paths for SDK and NDK
SimonSapin 65122b1
bootstrap-android: always run sdkmanager
SimonSapin fc77db4
Use the bootstraped Android toolchains by default
SimonSapin b6b9fe0
Add "./mach android-emulator"
SimonSapin 9e544c2
Remove the egl-configs diagnostic program
SimonSapin 8293b29
bootstrap-android: check SHA1 hashes of downloaded archives
SimonSapin bee3fd0
mach android-emulator: avoid mach error messages for Python exceptions
SimonSapin eecbe83
Add ./mach test-android-startup
SimonSapin c0d1b8e
Android: increase emulator disk size, for debug builds
SimonSapin File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.
Use more recent Android tools
The older version seems to insist on updating itself when asked to install other components.
- Loading branch information
commit 244a33297639919d8e1aa016bc137242a1ca7146
| @@ -29,7 +29,7 @@ | ||
|
|
||
| import servo.bootstrap as bootstrap | ||
| from servo.command_base import CommandBase, cd, check_call | ||
| from servo.util import delete, download_bytes, download_file, check_hash, extract | ||
| from servo.util import delete, download_bytes, download_file, extract | ||
|
|
||
|
|
||
| @CommandProvider | ||
| @@ -58,63 +58,66 @@ def bootstrap(self, force=False): | ||
| @Command('bootstrap-android', | ||
| description='Install the Android SDK and NDK.', | ||
| category='bootstrap') | ||
| def bootstrap_android(self): | ||
| @CommandArgument('--update', | ||
| action='store_true', | ||
| help='Run "android sdk update" again') | ||
| def bootstrap_android(self, update=False): | ||
|
|
||
| ndk_version = "r12b" | ||
| ndk_sha512 = "2d85b476436ca50896e4b7c5d0f15547fd14a6ebec7e0081022b28f791709af7" \ | ||
| "8ea5ebddcdf4722b5e94daeac288d509bd5f240b0280167edef8e199da3d0501" | ||
| # Available filenames: see https://dl.google.com/android/repository/repository2-1.xml | ||
| ndk = "android-ndk-r12b-{system}-{arch}" | ||
| tools = "sdk-tools-{system}-4333796" | ||
|
|
||
| sdk_version = "r25.2.3" | ||
| sdk_sha512 = "dfc30ee3e2714cf8008ab1f99757deded002d21b23a8d2ab07952e1afd1c9312" \ | ||
| "4ddec06660babf6a46c54e5e7e135c8c0cb4cc512378a8509da074dbf7e253d7" | ||
| sdk_platform = "25" | ||
| api_level = "25" | ||
| sdk_build_tools = "25.0.2" | ||
| system_image = "google_apis;armeabi-v7a" | ||
|
|
||
|
|
||
| toolchains = path.join(self.context.topdir, "android-toolchains") | ||
| if not path.isdir(toolchains): | ||
| os.makedirs(toolchains) | ||
|
|
||
| def download(kind, name, sha512): | ||
| toolchains = path.join(self.context.topdir, "android-toolchains") | ||
| directory = path.join(toolchains, kind) | ||
| final = path.join(directory, name) | ||
| def download(name): | ||
| final = path.join(toolchains, name) | ||
| if path.isdir(final): | ||
| return final | ||
|
|
||
| base_url = "https://dl.google.com/android/repository/" | ||
| filename = name + ".zip" | ||
| url = base_url + filename | ||
| archive = path.join(directory, filename) | ||
| archive = path.join(toolchains, filename) | ||
|
|
||
| if not path.isdir(directory): | ||
| os.makedirs(directory) | ||
| if not path.isfile(archive): | ||
| download_file(filename, url, archive) | ||
|
||
| check_hash(archive, sha512, "sha512") | ||
| print("Extracting " + filename) | ||
| remove = True # Set to False to avoid repeated downloads while debugging this script | ||
| extract(archive, final, remove=remove) | ||
| return final | ||
|
|
||
| system = platform.system().lower() | ||
| machine = platform.machine().lower() | ||
| os_ = {"darwin": "macosx"}.get(system, system) | ||
| arch = {"i386": "x86"}.get(machine, machine) | ||
| ndk = download("ndk", "android-ndk-%s-%s-%s" % (ndk_version, system, arch), ndk_sha512) | ||
| sdk = download("sdk", "tools_%s-%s" % (sdk_version, os_), sdk_sha512) | ||
| ndk_path = download(ndk.format(system=system, arch=arch)) | ||
| tools_path = download(tools.format(system=system)) | ||
|
|
||
| if not path.isdir(path.join(sdk, "platform-tools")): | ||
| if update or not path.isdir(path.join(tools_path, "platform-tools")): | ||
| image = "system-images;android-%s;%s" % (api_level, system_image) | ||
| subprocess.check_call([ | ||
| path.join(sdk, "tools", "android"), | ||
| "update", "sdk", "--no-ui", "--all", "--filter", | ||
| "platform-tools,android-%s,build-tools-%s" % (sdk_platform, sdk_build_tools), | ||
| path.join(tools_path, "tools", "bin", "sdkmanager"), | ||
| "platform-tools", | ||
| "platforms;android-" + api_level, | ||
| "build-tools;" + sdk_build_tools, | ||
| "emulator", | ||
| image, | ||
| ]) | ||
paulrouget
Contributor
|
||
|
|
||
| contents = os.listdir(ndk) | ||
| contents = os.listdir(ndk_path) | ||
| assert len(contents) == 1 | ||
| ndk = path.join(ndk, contents[0]) | ||
| ndk_path = path.join(ndk_path, contents[0]) | ||
|
|
||
| print("") | ||
| print("export ANDROID_SDK=\"%s\"" % sdk) | ||
| print("export ANDROID_NDK=\"%s\"" % ndk) | ||
| print("export PATH=\"%s:$PATH\"" % path.join(sdk, "platform-tools")) | ||
| print("export ANDROID_SDK=\"%s\"" % tools_path) | ||
| print("export ANDROID_NDK=\"%s\"" % ndk_path) | ||
| print("export PATH=\"%s:$PATH\"" % path.join(tools_path, "platform-tools")) | ||
|
|
||
| @Command('update-hsts-preload', | ||
| description='Download the HSTS preload list', | ||
ProTip!
Use n and p to navigate between commits in a pull request.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
If the download gets interrupted, don't we need a way to force the download? Also, in the initial commit you were checking the md5 of the file. Can't we keep that?