20NDK_VER =
"android-ndk-r26b"
22 "https://dl.google.com/android/repository/%s-darwin.dmg" % NDK_VER
24MOUNTED_NAME_START =
'/Volumes/Android NDK'
27 """Find the NDK within the mounted volume."""
28 for f
in os.listdir(volume):
29 if f.endswith(
'.app'):
30 return os.path.join(volume, f,
'Contents/NDK')
33 """Create the asset."""
34 if platform.system() !=
'Darwin':
35 print(
"This script can only be run on a Mac!")
38 subprocess.check_call([
"curl", NDK_URL,
"-o", DMG])
39 output = subprocess.check_output([
'hdiutil',
'attach', DMG])
42 lines = output.decode(
'utf-8').split(
'\n')
45 words = line.split(
'\t')
47 if words[2].startswith(MOUNTED_NAME_START):
52 if os.path.isdir(target_dir):
55 shutil.copytree(
find_ndk(words[2]), target_dir)
58 subprocess.check_call([
'hdiutil',
'detach', words[0].strip()])
60 subprocess.check_call([
"rm", DMG])
64 print(
"Could not find mount point! Output from hdiutil attach:")
70 parser = argparse.ArgumentParser()
71 parser.add_argument(
'--target_dir',
'-t', required=
True)
72 args = parser.parse_args()
76if __name__ ==
'__main__':
def create_asset(target_dir)
def print(*args, **kwargs)