Update bots' NDK to r23

Bug: skia:12273
Bug: skia:10754

The latest version (r23) includes APIs from Android 12. It also allows
referencing enums and structs even if __ANDROID_API__ is not set to the
level that included them. This allows code to reference them and use
dlsym to access the methods. This will ultimately allow Skia (or client
- in this case Flutter) to use a single build to use the NDK APIs if
present and fail gracefully if not.

With r23, the Mac version of the NDK is now in a DMG, so rewrite its
script to properly download, mount, and eject it.

Also update the path to asan_device_setup. (See
Iae6515b7e78c7660b4fb9fe32fd969ba563c4517.)

Change-Id: I4b2eb4f49a1d45a3c18d2399f6b8006668c310ea
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/439336
Reviewed-by: Eric Boren <borenet@google.com>
Reviewed-by: Derek Sollenberger <djsollen@google.com>
Commit-Queue: Leon Scroggins <scroggo@google.com>
This commit is contained in:
Leon Scroggins III 2021-08-13 11:54:26 -04:00 committed by SkCQ
parent c26565755d
commit 3bce5d1397
10 changed files with 83 additions and 47 deletions

View File

@ -1 +1 @@
10 11

View File

@ -10,25 +10,61 @@
import argparse import argparse
import glob import os
import os.path import platform
import shutil import shutil
import subprocess import subprocess
import sys
NDK_VER = "android-ndk-r21d" NDK_VER = "android-ndk-r23"
NDK_URL = \ NDK_URL = \
"https://dl.google.com/android/repository/%s-darwin-x86_64.zip" % NDK_VER "https://dl.google.com/android/repository/%s-darwin.dmg" % NDK_VER
DMG = "ndk.dmg"
MOUNTED_NAME_START = '/Volumes/Android NDK'
def find_ndk(volume):
"""Find the NDK within the mounted volume."""
for f in os.listdir(volume):
if f.endswith('.app'):
return os.path.join(volume, f, 'Contents/NDK')
def create_asset(target_dir): def create_asset(target_dir):
"""Create the asset.""" """Create the asset."""
subprocess.check_call(["curl", NDK_URL, "-o", "ndk.zip"]) if platform.system() != 'Darwin':
subprocess.check_call(["unzip", "ndk.zip", "-d", target_dir]) print("This script can only be run on a Mac!")
for f in glob.glob(os.path.join(target_dir, NDK_VER, "*")): sys.exit(1)
shutil.move(f, target_dir)
subprocess.check_call(["rm", "ndk.zip"])
subprocess.check_call(["curl", NDK_URL, "-o", DMG])
output = subprocess.check_output(['hdiutil', 'attach', DMG])
# hdiutil mounted the DMG somewhere - find where it was mounted.
lines = output.decode('utf-8').split('\n')
found = False
for line in lines:
words = line.split('\t')
if len(words) == 3:
if words[2].startswith(MOUNTED_NAME_START):
found = True
# copytree (in python2, and by default in python3) requires that the
# dst does not exist. Remove it so that is the case.
if os.path.isdir(target_dir):
os.rmdir(target_dir)
shutil.copytree(find_ndk(words[2]), target_dir)
# Unmount the volume, now that we're done with it.
subprocess.check_call(['hdiutil', 'detach', words[0].strip()])
subprocess.check_call(["rm", DMG])
break
if not found:
print("Could not find mount point! Output from hdiutil attach:")
for line in lines:
print(line)
sys.exit(2)
def main(): def main():
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()

View File

@ -1 +1 @@
16 17

View File

@ -16,9 +16,9 @@ import shutil
import subprocess import subprocess
NDK_VER = "android-ndk-r21d" NDK_VER = "android-ndk-r23"
NDK_URL = \ NDK_URL = \
"https://dl.google.com/android/repository/%s-linux-x86_64.zip" % NDK_VER "https://dl.google.com/android/repository/%s-linux.zip" % NDK_VER
def create_asset(target_dir): def create_asset(target_dir):

View File

@ -1 +1 @@
11 12

View File

@ -16,9 +16,9 @@ import shutil
import subprocess import subprocess
NDK_VER = "android-ndk-r21d" NDK_VER = "android-ndk-r23"
NDK_URL = \ NDK_URL = \
"https://dl.google.com/android/repository/%s-windows-x86_64.zip" % NDK_VER "https://dl.google.com/android/repository/%s-windows.zip" % NDK_VER
def create_asset(target_dir): def create_asset(target_dir):

View File

@ -351,7 +351,7 @@ if actual_freq != str(freq):
def _asan_setup_path(self): def _asan_setup_path(self):
return self.m.vars.workdir.join( return self.m.vars.workdir.join(
'android_ndk_linux', 'toolchains', 'llvm', 'prebuilt', 'linux-x86_64', 'android_ndk_linux', 'toolchains', 'llvm', 'prebuilt', 'linux-x86_64',
'lib64', 'clang', '9.0.8', 'bin', 'asan_device_setup') 'lib64', 'clang', '12.0.5', 'bin', 'asan_device_setup')
def install(self): def install(self):

View File

@ -200,7 +200,7 @@
"-u", "-u",
"\nimport os\nimport subprocess\nimport sys\nimport time\nADB = sys.argv[1]\nASAN_SETUP = sys.argv[2]\n\ndef wait_for_device():\n while True:\n time.sleep(5)\n print 'Waiting for device'\n subprocess.check_output([ADB, 'wait-for-device'])\n bit1 = subprocess.check_output([ADB, 'shell', 'getprop',\n 'dev.bootcomplete'])\n bit2 = subprocess.check_output([ADB, 'shell', 'getprop',\n 'sys.boot_completed'])\n if '1' in bit1 and '1' in bit2:\n print 'Device detected'\n break\n\nlog = subprocess.check_output([ADB, 'root'])\n# check for message like 'adbd cannot run as root in production builds'\nprint log\nif 'cannot' in log:\n raise Exception('adb root failed')\n\noutput = subprocess.check_output([ADB, 'disable-verity'])\nprint output\n\nif 'already disabled' not in output:\n print 'Rebooting device'\n subprocess.check_output([ADB, 'reboot'])\n wait_for_device()\n\ndef installASAN(revert=False):\n # ASAN setup script is idempotent, either it installs it or\n # says it's installed. Returns True on success, false otherwise.\n out = subprocess.check_output([ADB, 'wait-for-device'])\n print out\n cmd = [ASAN_SETUP]\n if revert:\n cmd = [ASAN_SETUP, '--revert']\n process = subprocess.Popen(cmd, env={'ADB': ADB},\n stdout=subprocess.PIPE, stderr=subprocess.PIPE)\n\n # this also blocks until command finishes\n (stdout, stderr) = process.communicate()\n print stdout\n print 'Stderr: %s' % stderr\n return process.returncode == 0\n\nif not installASAN():\n print 'Trying to revert the ASAN install and then re-install'\n # ASAN script sometimes has issues if it was interrupted or partially applied\n # Try reverting it, then re-enabling it\n if not installASAN(revert=True):\n raise Exception('reverting ASAN install failed')\n\n # Sleep because device does not reboot instantly\n time.sleep(10)\n\n if not installASAN():\n raise Exception('Tried twice to setup ASAN and failed.')\n\n# Sleep because device does not reboot instantly\ntime.sleep(10)\nwait_for_device()\n# Sleep again to hopefully avoid error \"secure_mkdirs failed: No such file or\n# directory\" when pushing resources to the device.\ntime.sleep(60)\n", "\nimport os\nimport subprocess\nimport sys\nimport time\nADB = sys.argv[1]\nASAN_SETUP = sys.argv[2]\n\ndef wait_for_device():\n while True:\n time.sleep(5)\n print 'Waiting for device'\n subprocess.check_output([ADB, 'wait-for-device'])\n bit1 = subprocess.check_output([ADB, 'shell', 'getprop',\n 'dev.bootcomplete'])\n bit2 = subprocess.check_output([ADB, 'shell', 'getprop',\n 'sys.boot_completed'])\n if '1' in bit1 and '1' in bit2:\n print 'Device detected'\n break\n\nlog = subprocess.check_output([ADB, 'root'])\n# check for message like 'adbd cannot run as root in production builds'\nprint log\nif 'cannot' in log:\n raise Exception('adb root failed')\n\noutput = subprocess.check_output([ADB, 'disable-verity'])\nprint output\n\nif 'already disabled' not in output:\n print 'Rebooting device'\n subprocess.check_output([ADB, 'reboot'])\n wait_for_device()\n\ndef installASAN(revert=False):\n # ASAN setup script is idempotent, either it installs it or\n # says it's installed. Returns True on success, false otherwise.\n out = subprocess.check_output([ADB, 'wait-for-device'])\n print out\n cmd = [ASAN_SETUP]\n if revert:\n cmd = [ASAN_SETUP, '--revert']\n process = subprocess.Popen(cmd, env={'ADB': ADB},\n stdout=subprocess.PIPE, stderr=subprocess.PIPE)\n\n # this also blocks until command finishes\n (stdout, stderr) = process.communicate()\n print stdout\n print 'Stderr: %s' % stderr\n return process.returncode == 0\n\nif not installASAN():\n print 'Trying to revert the ASAN install and then re-install'\n # ASAN script sometimes has issues if it was interrupted or partially applied\n # Try reverting it, then re-enabling it\n if not installASAN(revert=True):\n raise Exception('reverting ASAN install failed')\n\n # Sleep because device does not reboot instantly\n time.sleep(10)\n\n if not installASAN():\n raise Exception('Tried twice to setup ASAN and failed.')\n\n# Sleep because device does not reboot instantly\ntime.sleep(10)\nwait_for_device()\n# Sleep again to hopefully avoid error \"secure_mkdirs failed: No such file or\n# directory\" when pushing resources to the device.\ntime.sleep(60)\n",
"/opt/infra-android/tools/adb", "/opt/infra-android/tools/adb",
"[START_DIR]/android_ndk_linux/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/9.0.8/bin/asan_device_setup" "[START_DIR]/android_ndk_linux/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/12.0.5/bin/asan_device_setup"
], ],
"env": { "env": {
"CHROME_HEADLESS": "1", "CHROME_HEADLESS": "1",
@ -1413,7 +1413,7 @@
}, },
{ {
"cmd": [ "cmd": [
"[START_DIR]/android_ndk_linux/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/9.0.8/bin/asan_device_setup", "[START_DIR]/android_ndk_linux/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/12.0.5/bin/asan_device_setup",
"--revert" "--revert"
], ],
"env": { "env": {

View File

@ -50,7 +50,7 @@
"-u", "-u",
"\nimport os\nimport subprocess\nimport sys\nimport time\nADB = sys.argv[1]\nASAN_SETUP = sys.argv[2]\n\ndef wait_for_device():\n while True:\n time.sleep(5)\n print 'Waiting for device'\n subprocess.check_output([ADB, 'wait-for-device'])\n bit1 = subprocess.check_output([ADB, 'shell', 'getprop',\n 'dev.bootcomplete'])\n bit2 = subprocess.check_output([ADB, 'shell', 'getprop',\n 'sys.boot_completed'])\n if '1' in bit1 and '1' in bit2:\n print 'Device detected'\n break\n\nlog = subprocess.check_output([ADB, 'root'])\n# check for message like 'adbd cannot run as root in production builds'\nprint log\nif 'cannot' in log:\n raise Exception('adb root failed')\n\noutput = subprocess.check_output([ADB, 'disable-verity'])\nprint output\n\nif 'already disabled' not in output:\n print 'Rebooting device'\n subprocess.check_output([ADB, 'reboot'])\n wait_for_device()\n\ndef installASAN(revert=False):\n # ASAN setup script is idempotent, either it installs it or\n # says it's installed. Returns True on success, false otherwise.\n out = subprocess.check_output([ADB, 'wait-for-device'])\n print out\n cmd = [ASAN_SETUP]\n if revert:\n cmd = [ASAN_SETUP, '--revert']\n process = subprocess.Popen(cmd, env={'ADB': ADB},\n stdout=subprocess.PIPE, stderr=subprocess.PIPE)\n\n # this also blocks until command finishes\n (stdout, stderr) = process.communicate()\n print stdout\n print 'Stderr: %s' % stderr\n return process.returncode == 0\n\nif not installASAN():\n print 'Trying to revert the ASAN install and then re-install'\n # ASAN script sometimes has issues if it was interrupted or partially applied\n # Try reverting it, then re-enabling it\n if not installASAN(revert=True):\n raise Exception('reverting ASAN install failed')\n\n # Sleep because device does not reboot instantly\n time.sleep(10)\n\n if not installASAN():\n raise Exception('Tried twice to setup ASAN and failed.')\n\n# Sleep because device does not reboot instantly\ntime.sleep(10)\nwait_for_device()\n# Sleep again to hopefully avoid error \"secure_mkdirs failed: No such file or\n# directory\" when pushing resources to the device.\ntime.sleep(60)\n", "\nimport os\nimport subprocess\nimport sys\nimport time\nADB = sys.argv[1]\nASAN_SETUP = sys.argv[2]\n\ndef wait_for_device():\n while True:\n time.sleep(5)\n print 'Waiting for device'\n subprocess.check_output([ADB, 'wait-for-device'])\n bit1 = subprocess.check_output([ADB, 'shell', 'getprop',\n 'dev.bootcomplete'])\n bit2 = subprocess.check_output([ADB, 'shell', 'getprop',\n 'sys.boot_completed'])\n if '1' in bit1 and '1' in bit2:\n print 'Device detected'\n break\n\nlog = subprocess.check_output([ADB, 'root'])\n# check for message like 'adbd cannot run as root in production builds'\nprint log\nif 'cannot' in log:\n raise Exception('adb root failed')\n\noutput = subprocess.check_output([ADB, 'disable-verity'])\nprint output\n\nif 'already disabled' not in output:\n print 'Rebooting device'\n subprocess.check_output([ADB, 'reboot'])\n wait_for_device()\n\ndef installASAN(revert=False):\n # ASAN setup script is idempotent, either it installs it or\n # says it's installed. Returns True on success, false otherwise.\n out = subprocess.check_output([ADB, 'wait-for-device'])\n print out\n cmd = [ASAN_SETUP]\n if revert:\n cmd = [ASAN_SETUP, '--revert']\n process = subprocess.Popen(cmd, env={'ADB': ADB},\n stdout=subprocess.PIPE, stderr=subprocess.PIPE)\n\n # this also blocks until command finishes\n (stdout, stderr) = process.communicate()\n print stdout\n print 'Stderr: %s' % stderr\n return process.returncode == 0\n\nif not installASAN():\n print 'Trying to revert the ASAN install and then re-install'\n # ASAN script sometimes has issues if it was interrupted or partially applied\n # Try reverting it, then re-enabling it\n if not installASAN(revert=True):\n raise Exception('reverting ASAN install failed')\n\n # Sleep because device does not reboot instantly\n time.sleep(10)\n\n if not installASAN():\n raise Exception('Tried twice to setup ASAN and failed.')\n\n# Sleep because device does not reboot instantly\ntime.sleep(10)\nwait_for_device()\n# Sleep again to hopefully avoid error \"secure_mkdirs failed: No such file or\n# directory\" when pushing resources to the device.\ntime.sleep(60)\n",
"/usr/bin/adb.1.0.35", "/usr/bin/adb.1.0.35",
"[START_DIR]/android_ndk_linux/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/9.0.8/bin/asan_device_setup" "[START_DIR]/android_ndk_linux/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/12.0.5/bin/asan_device_setup"
], ],
"env": { "env": {
"CHROME_HEADLESS": "1", "CHROME_HEADLESS": "1",
@ -1207,7 +1207,7 @@
}, },
{ {
"cmd": [ "cmd": [
"[START_DIR]/android_ndk_linux/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/9.0.8/bin/asan_device_setup", "[START_DIR]/android_ndk_linux/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/12.0.5/bin/asan_device_setup",
"--revert" "--revert"
], ],
"env": { "env": {

View File

@ -3126,7 +3126,7 @@
{ {
"name": "skia/bots/android_ndk_linux", "name": "skia/bots/android_ndk_linux",
"path": "android_ndk_linux", "path": "android_ndk_linux",
"version": "version:16" "version": "version:17"
} }
], ],
"command": [ "command": [
@ -3218,7 +3218,7 @@
{ {
"name": "skia/bots/android_ndk_linux", "name": "skia/bots/android_ndk_linux",
"path": "android_ndk_linux", "path": "android_ndk_linux",
"version": "version:16" "version": "version:17"
} }
], ],
"command": [ "command": [
@ -3310,7 +3310,7 @@
{ {
"name": "skia/bots/android_ndk_linux", "name": "skia/bots/android_ndk_linux",
"path": "android_ndk_linux", "path": "android_ndk_linux",
"version": "version:16" "version": "version:17"
} }
], ],
"command": [ "command": [
@ -3402,7 +3402,7 @@
{ {
"name": "skia/bots/android_ndk_linux", "name": "skia/bots/android_ndk_linux",
"path": "android_ndk_linux", "path": "android_ndk_linux",
"version": "version:16" "version": "version:17"
} }
], ],
"command": [ "command": [
@ -3596,7 +3596,7 @@
{ {
"name": "skia/bots/android_ndk_linux", "name": "skia/bots/android_ndk_linux",
"path": "android_ndk_linux", "path": "android_ndk_linux",
"version": "version:16" "version": "version:17"
} }
], ],
"command": [ "command": [
@ -3688,7 +3688,7 @@
{ {
"name": "skia/bots/android_ndk_linux", "name": "skia/bots/android_ndk_linux",
"path": "android_ndk_linux", "path": "android_ndk_linux",
"version": "version:16" "version": "version:17"
} }
], ],
"command": [ "command": [
@ -3780,7 +3780,7 @@
{ {
"name": "skia/bots/android_ndk_linux", "name": "skia/bots/android_ndk_linux",
"path": "android_ndk_linux", "path": "android_ndk_linux",
"version": "version:16" "version": "version:17"
} }
], ],
"command": [ "command": [
@ -3974,7 +3974,7 @@
{ {
"name": "skia/bots/android_ndk_linux", "name": "skia/bots/android_ndk_linux",
"path": "android_ndk_linux", "path": "android_ndk_linux",
"version": "version:16" "version": "version:17"
} }
], ],
"command": [ "command": [
@ -4066,7 +4066,7 @@
{ {
"name": "skia/bots/android_ndk_linux", "name": "skia/bots/android_ndk_linux",
"path": "android_ndk_linux", "path": "android_ndk_linux",
"version": "version:16" "version": "version:17"
} }
], ],
"command": [ "command": [
@ -4158,7 +4158,7 @@
{ {
"name": "skia/bots/android_ndk_linux", "name": "skia/bots/android_ndk_linux",
"path": "android_ndk_linux", "path": "android_ndk_linux",
"version": "version:16" "version": "version:17"
} }
], ],
"command": [ "command": [
@ -4250,7 +4250,7 @@
{ {
"name": "skia/bots/android_ndk_linux", "name": "skia/bots/android_ndk_linux",
"path": "android_ndk_linux", "path": "android_ndk_linux",
"version": "version:16" "version": "version:17"
} }
], ],
"command": [ "command": [
@ -4342,7 +4342,7 @@
{ {
"name": "skia/bots/android_ndk_linux", "name": "skia/bots/android_ndk_linux",
"path": "android_ndk_linux", "path": "android_ndk_linux",
"version": "version:16" "version": "version:17"
} }
], ],
"command": [ "command": [
@ -4434,7 +4434,7 @@
{ {
"name": "skia/bots/android_ndk_linux", "name": "skia/bots/android_ndk_linux",
"path": "android_ndk_linux", "path": "android_ndk_linux",
"version": "version:16" "version": "version:17"
} }
], ],
"command": [ "command": [
@ -4526,7 +4526,7 @@
{ {
"name": "skia/bots/android_ndk_linux", "name": "skia/bots/android_ndk_linux",
"path": "android_ndk_linux", "path": "android_ndk_linux",
"version": "version:16" "version": "version:17"
} }
], ],
"command": [ "command": [
@ -4618,7 +4618,7 @@
{ {
"name": "skia/bots/android_ndk_linux", "name": "skia/bots/android_ndk_linux",
"path": "android_ndk_linux", "path": "android_ndk_linux",
"version": "version:16" "version": "version:17"
} }
], ],
"command": [ "command": [
@ -4710,7 +4710,7 @@
{ {
"name": "skia/bots/android_ndk_linux", "name": "skia/bots/android_ndk_linux",
"path": "android_ndk_linux", "path": "android_ndk_linux",
"version": "version:16" "version": "version:17"
} }
], ],
"command": [ "command": [
@ -4802,7 +4802,7 @@
{ {
"name": "skia/bots/android_ndk_linux", "name": "skia/bots/android_ndk_linux",
"path": "android_ndk_linux", "path": "android_ndk_linux",
"version": "version:16" "version": "version:17"
} }
], ],
"command": [ "command": [
@ -4894,7 +4894,7 @@
{ {
"name": "skia/bots/android_ndk_linux", "name": "skia/bots/android_ndk_linux",
"path": "android_ndk_linux", "path": "android_ndk_linux",
"version": "version:16" "version": "version:17"
} }
], ],
"command": [ "command": [
@ -5087,7 +5087,7 @@
{ {
"name": "skia/bots/android_ndk_linux", "name": "skia/bots/android_ndk_linux",
"path": "android_ndk_linux", "path": "android_ndk_linux",
"version": "version:16" "version": "version:17"
} }
], ],
"command": [ "command": [
@ -5179,7 +5179,7 @@
{ {
"name": "skia/bots/android_ndk_linux", "name": "skia/bots/android_ndk_linux",
"path": "android_ndk_linux", "path": "android_ndk_linux",
"version": "version:16" "version": "version:17"
} }
], ],
"command": [ "command": [
@ -5271,7 +5271,7 @@
{ {
"name": "skia/bots/android_ndk_linux", "name": "skia/bots/android_ndk_linux",
"path": "android_ndk_linux", "path": "android_ndk_linux",
"version": "version:16" "version": "version:17"
} }
], ],
"command": [ "command": [
@ -5363,7 +5363,7 @@
{ {
"name": "skia/bots/android_ndk_linux", "name": "skia/bots/android_ndk_linux",
"path": "android_ndk_linux", "path": "android_ndk_linux",
"version": "version:16" "version": "version:17"
} }
], ],
"command": [ "command": [
@ -10545,7 +10545,7 @@
{ {
"name": "skia/bots/android_ndk_linux", "name": "skia/bots/android_ndk_linux",
"path": "android_ndk_linux", "path": "android_ndk_linux",
"version": "version:16" "version": "version:17"
} }
], ],
"command": [ "command": [
@ -10742,7 +10742,7 @@
{ {
"name": "skia/bots/android_ndk_darwin", "name": "skia/bots/android_ndk_darwin",
"path": "android_ndk_darwin", "path": "android_ndk_darwin",
"version": "version:10" "version": "version:11"
} }
], ],
"command": [ "command": [
@ -13612,7 +13612,7 @@
{ {
"name": "skia/bots/android_ndk_windows", "name": "skia/bots/android_ndk_windows",
"path": "n", "path": "n",
"version": "version:11" "version": "version:12"
} }
], ],
"command": [ "command": [
@ -19314,7 +19314,7 @@
{ {
"name": "skia/bots/android_ndk_linux", "name": "skia/bots/android_ndk_linux",
"path": "android_ndk_linux", "path": "android_ndk_linux",
"version": "version:16" "version": "version:17"
} }
], ],
"command": [ "command": [