Blame scripts/toolchains_path.py

Packit Service 5a9772
#!/usr/bin/env python3
Packit Service 5a9772
"""
Packit Service 5a9772
    Get the toolchains path
Packit Service 5a9772
    https://proandroiddev.com/tutorial-compile-openssl-to-1-1-1-for-android-application-87137968fee
Packit Service 5a9772
"""
Packit Service 5a9772
import argparse
Packit Service 5a9772
import atexit
Packit Service 5a9772
import inspect
Packit Service 5a9772
import os
Packit Service 5a9772
import shutil
Packit Service 5a9772
import stat
Packit Service 5a9772
import sys
Packit Service 5a9772
import textwrap
Packit Service 5a9772
Packit Service 5a9772
def get_host_tag_or_die():
Packit Service 5a9772
    """Return the host tag for this platform. Die if not supported."""
Packit Service 5a9772
    if sys.platform.startswith('linux'):
Packit Service 5a9772
        return 'linux-x86_64'
Packit Service 5a9772
    elif sys.platform == 'darwin':
Packit Service 5a9772
        return 'darwin-x86_64'
Packit Service 5a9772
    elif sys.platform == 'win32' or sys.platform == 'cygwin':
Packit Service 5a9772
        host_tag = 'windows-x86_64'
Packit Service 5a9772
        if not os.path.exists(os.path.join(NDK_DIR, 'prebuilt', host_tag)):
Packit Service 5a9772
            host_tag = 'windows'
Packit Service 5a9772
        return host_tag
Packit Service 5a9772
    sys.exit('Unsupported platform: ' + sys.platform)
Packit Service 5a9772
Packit Service 5a9772
Packit Service 5a9772
def get_toolchain_path_or_die(ndk, host_tag):
Packit Service 5a9772
    """Return the toolchain path or die."""
Packit Service 5a9772
    toolchain_path = os.path.join(ndk, 'toolchains/llvm/prebuilt',
Packit Service 5a9772
                                  host_tag, 'bin')
Packit Service 5a9772
    if not os.path.exists(toolchain_path):
Packit Service 5a9772
        sys.exit('Could not find toolchain: {}'.format(toolchain_path))
Packit Service 5a9772
    return toolchain_path
Packit Service 5a9772
Packit Service 5a9772
def main():
Packit Service 5a9772
    """Program entry point."""
Packit Service 5a9772
    parser = argparse.ArgumentParser(description='Optional app description')
Packit Service 5a9772
    parser.add_argument('--ndk', required=True,
Packit Service 5a9772
                    help='The NDK Home directory')
Packit Service 5a9772
    args = parser.parse_args()
Packit Service 5a9772
Packit Service 5a9772
    host_tag = get_host_tag_or_die()
Packit Service 5a9772
    toolchain_path = get_toolchain_path_or_die(args.ndk, host_tag)
Packit Service 5a9772
    print(toolchain_path)
Packit Service 5a9772
Packit Service 5a9772
if __name__ == '__main__':
Packit Service 5a9772
    main()