Created
May 24, 2019 14:52
-
-
Save lixiaoyi/8096570c0d0970ea6a86fa689259abc1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
Get the toolchains path | |
""" | |
import argparse | |
import atexit | |
import inspect | |
import os | |
import shutil | |
import stat | |
import sys | |
import textwrap | |
def get_host_tag_or_die(): | |
"""Return the host tag for this platform. Die if not supported.""" | |
if sys.platform.startswith('linux'): | |
return 'linux-x86_64' | |
elif sys.platform == 'darwin': | |
return 'darwin-x86_64' | |
elif sys.platform == 'win32' or sys.platform == 'cygwin': | |
host_tag = 'windows-x86_64' | |
if not os.path.exists(os.path.join(NDK_DIR, 'prebuilt', host_tag)): | |
host_tag = 'windows' | |
return host_tag | |
sys.exit('Unsupported platform: ' + sys.platform) | |
def get_toolchain_path_or_die(ndk, host_tag): | |
"""Return the toolchain path or die.""" | |
toolchain_path = os.path.join(ndk, 'toolchains/llvm/prebuilt', | |
host_tag) | |
if not os.path.exists(toolchain_path): | |
sys.exit('Could not find toolchain: {}'.format(toolchain_path)) | |
return toolchain_path | |
def main(): | |
"""Program entry point.""" | |
parser = argparse.ArgumentParser(description='Optional app description') | |
parser.add_argument('--ndk', required=True, | |
help='The NDK Home directory') | |
args = parser.parse_args() | |
host_tag = get_host_tag_or_die() | |
toolchain_path = get_toolchain_path_or_die(args.ndk, host_tag) | |
print toolchain_path | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for the script.
but "NDK_DIR is not defind". I guess you forgot to pass args.ndk as argument to get_host_tag_or_die(ndk). Or make NDK_DIR global variable.