MCPcopy Create free account
hub / github.com/LunarG/VulkanTools / main

Function main

scripts/android.py:47–127  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

45 subprocess.check_call(cmd_list, cwd=start_dir, env=env)
46
47def main():
48 configs = ['Release', 'Debug']
49
50 parser = argparse.ArgumentParser()
51 parser.add_argument('--config', type=str, choices=configs, default=configs[0])
52 parser.add_argument('--app-abi', dest='android_abi', type=str, default="arm64-v8a")
53 parser.add_argument('--tests', action='store_true', help='Build tests.')
54 parser.add_argument('--clean', action='store_true', help='Cleans CMake build artifacts')
55 args = parser.parse_args()
56
57 cmake_config = args.config
58 android_abis = args.android_abi.split(" ")
59 build_tests = args.tests
60 clean = args.clean
61
62 if "ANDROID_NDK_HOME" not in os.environ:
63 print("Cannot find ANDROID_NDK_HOME!")
64 sys.exit(1)
65
66 android_ndk_home = os.environ.get('ANDROID_NDK_HOME')
67 android_toolchain = f'{android_ndk_home}/build/cmake/android.toolchain.cmake'
68
69 # The only tool we require for building is CMake/Ninja
70 required_cli_tools = ['cmake', 'ninja']
71
72 print(f"ANDROID_NDK_HOME = {android_ndk_home}")
73 print(f"Build configured for {cmake_config} | {android_abis}")
74
75 if not os.path.isfile(android_toolchain):
76 print(f'Unable to find android.toolchain.cmake at {android_toolchain}')
77 exit(-1)
78
79 for tool in required_cli_tools:
80 path = shutil.which(tool)
81 if path is None:
82 print(f"Unable to find {tool}!")
83 exit(-1)
84
85 print(f"Using {tool} : {path}")
86
87 cmake_install_dir = RepoRelative('build-android/libs')
88
89 # Delete install directory since it could contain files from old runs
90 if os.path.isdir(cmake_install_dir):
91 print("Cleaning CMake install")
92 shutil.rmtree(cmake_install_dir)
93
94 for abi in android_abis:
95 build_dir = RepoRelative(f'build-android/cmake/{abi}')
96 lib_dir = f'lib/{abi}'
97
98 if clean:
99 print("Deleting CMakeCache.txt")
100
101 # Delete CMakeCache.txt to ensure clean builds
102 # NOTE: CMake 3.24 has --fresh which would be better to use in the future.
103 cmake_cache = f'{build_dir}/CMakeCache.txt'
104 if os.path.isfile(cmake_cache):

Callers 1

android.pyFile · 0.70

Calls 2

RepoRelativeFunction · 0.70
RunShellCmdFunction · 0.70

Tested by

no test coverage detected