p≡p for Java
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.4 KiB

  1. #!/usr/bin/env python
  2. """
  3. Get the toolchains path
  4. """
  5. import argparse
  6. import atexit
  7. import inspect
  8. import os
  9. import shutil
  10. import stat
  11. import sys
  12. import textwrap
  13. def get_host_tag_or_die():
  14. """Return the host tag for this platform. Die if not supported."""
  15. if sys.platform.startswith('linux'):
  16. return 'linux-x86_64'
  17. elif sys.platform == 'darwin':
  18. return 'darwin-x86_64'
  19. elif sys.platform == 'win32' or sys.platform == 'cygwin':
  20. host_tag = 'windows-x86_64'
  21. if not os.path.exists(os.path.join(NDK_DIR, 'prebuilt', host_tag)):
  22. host_tag = 'windows'
  23. return host_tag
  24. sys.exit('Unsupported platform: ' + sys.platform)
  25. def get_toolchain_path_or_die(ndk, host_tag):
  26. """Return the toolchain path or die."""
  27. toolchain_path = os.path.join(ndk, 'toolchains/llvm/prebuilt',
  28. host_tag)
  29. if not os.path.exists(toolchain_path):
  30. sys.exit('Could not find toolchain: {}'.format(toolchain_path))
  31. return toolchain_path
  32. def main():
  33. """Program entry point."""
  34. parser = argparse.ArgumentParser(description='Optional app description')
  35. parser.add_argument('--ndk', required=True,
  36. help='The NDK Home directory')
  37. args = parser.parse_args()
  38. host_tag = get_host_tag_or_die()
  39. toolchain_path = get_toolchain_path_or_die(args.ndk, host_tag)
  40. print toolchain_path
  41. if __name__ == '__main__':
  42. main()