Exemple #1
0
def setup_android_cross_template(env: dict, opts: AndroidOpts, target: str,
                                 host_arch: str):
    def get_host_triple():
        if sys.platform == 'darwin':
            return '%s-apple-darwin11' % host_arch
        elif sys.platform in ['linux', 'linux2']:
            return '%s-linux-gnu' % host_arch
        assert False

    target_arch = AndroidCrossTable.target_archs[target]
    device_target = AndroidCrossTable.device_targets[target]
    offsets_dumper_abi = AndroidCrossTable.offsets_dumper_abis[target]
    host_triple = get_host_triple()
    target_triple = '%s-linux-android' % target_arch

    android_libclang = get_android_libclang_path(opts)

    env['_android-%s_OFFSETS_DUMPER_ARGS' % target] = [
        '--libclang=%s' % android_libclang,
        '--sysroot=%s/sysroot' % opts.android_ndk_root
    ]

    env['_android-%s_AR' % target] = 'ar'
    env['_android-%s_AS' % target] = 'as'
    env['_android-%s_CC' % target] = 'cc'
    env['_android-%s_CXX' % target] = 'c++'
    env['_android-%s_CXXCPP' % target] = 'cpp'
    env['_android-%s_LD' % target] = 'ld'
    env['_android-%s_RANLIB' % target] = 'ranlib'
    env['_android-%s_STRIP' % target] = 'strip'

    is_darwin = sys.platform == 'darwin'

    CFLAGS = []
    CFLAGS += ['-DDEBUG_CROSS'] if not opts.release else []
    CFLAGS += ['-mmacosx-version-min=10.9'] if is_darwin else []

    env['_android-%s_CFLAGS' % target] = CFLAGS

    CXXFLAGS = []
    CXXFLAGS += ['-DDEBUG_CROSS'] if not opts.release else []
    CXXFLAGS += ['-mmacosx-version-min=10.9', '-stdlib=libc++'
                 ] if is_darwin else []

    env['_android-%s_CXXFLAGS' % target] = CXXFLAGS

    env['_android-%s_CONFIGURE_FLAGS' % target] = [
        '--disable-boehm', '--disable-mcs-build', '--disable-nls',
        '--enable-maintainer-mode', '--with-tls=pthread'
    ]

    # Runtime cross template
    runtime.setup_runtime_cross_template(env, opts, 'android', target,
                                         host_triple, target_triple,
                                         device_target, 'llvm64',
                                         offsets_dumper_abi)
Exemple #2
0
def setup_ios_cross_template(env: dict, opts: iOSOpts, target: str,
                             host_arch: str):

    target_triple = iOSCrossTable.target_triples[target]
    device_target = iOSCrossTable.device_targets[target]
    offsets_dumper_abi = iOSCrossTable.offsets_dumper_abis[target]
    host_triple = '%s-apple-darwin11' % host_arch

    is_sim = device_target in sim_targets

    ios_sysroot_path = opts.ios_sdk_path

    if not ios_sysroot_path and sys.platform == 'darwin':
        # Auto-detect on macOS
        ios_sysroot_path = xcrun_find_sdk(
            'iphonesimulator' if is_sim else 'iphoneos')

    if not ios_sysroot_path:
        raise RuntimeError(
            'Cannot find iOS SDK; specify one manually with \'--ios-sdk\'.')

    osx_sysroot_path = opts.osx_sdk_path

    if not osx_sysroot_path and sys.platform == 'darwin':
        # Auto-detect on macOS
        osx_sysroot_path = xcrun_find_sdk('macosx')

    if not osx_sysroot_path:
        raise RuntimeError(
            'Cannot find MacOSX SDK; specify one manually with \'--osx-sdk\'.')

    if sys.platform != 'darwin':
        osxcross_root = opts.osx_toolchain_path
        osxcross_bin = path_join(osxcross_root, 'bin')

        env['_ios-%s_PATH' % target] = osxcross_bin

        wrapper_path = create_osxcross_wrapper(opts, 'ios', target,
                                               opts.osx_toolchain_path)
        name_fmt = path_join(
            osxcross_bin, host_arch + '-apple-' + opts.osx_triple_abi + '-%s')
        name_fmt = "%s %s" % (wrapper_path, name_fmt)
    else:
        tools_path = path_join(opts.osx_toolchain_path, 'usr', 'bin')
        name_fmt = path_join(tools_path, '%s')

    env['_ios-%s_AR' % target] = name_fmt % 'ar'
    env['_ios-%s_AS' % target] = name_fmt % 'as'
    env['_ios-%s_CC' % target] = name_fmt % 'clang'
    env['_ios-%s_CXX' % target] = name_fmt % 'clang++'
    env['_ios-%s_LD' % target] = name_fmt % 'ld'
    env['_ios-%s_RANLIB' % target] = name_fmt % 'ranlib'
    env['_ios-%s_STRIP' % target] = name_fmt % 'strip'

    libclang = os.environ.get('LIBCLANG_PATH', '')
    if libclang and not os.path.isfile(libclang):
        raise RuntimeError('Specified libclang file not found: \'%s\'' %
                           libclang)

    if not libclang:
        libclang = try_find_libclang(toolchain_path=opts.ios_toolchain_path)

    if not libclang:
        raise RuntimeError(
            'Cannot find libclang shared library; specify a path manually with the \'LIBCLANG_PATH\' environment variable.'
        )

    offsets_dumper_args = [
        '--libclang=%s' % libclang,
        '--sysroot=%s' % ios_sysroot_path
    ]

    if sys.platform != 'darwin':
        # Needed in order to locate the iOS toolchain's clang to use with offsets-tool
        setup_ios_device_template(env, opts, device_target)
        ios_clang = env['_ios-%s_CC' % device_target]

        # Extra CFLAGS needed in order to make offsets-tool work with OSXCross.
        offsets_dumper_args += [
            '--extra-cflag=' + cflag for cflag in [
                '-target', 'aarch64-apple-darwin', '-resource-dir',
                get_clang_resource_dir(ios_clang)
            ]
        ]

    env['_ios-%s_OFFSETS_DUMPER_ARGS' % target] = offsets_dumper_args

    AC_VARS = ['ac_cv_func_shm_open_working_with_mmap=no']

    CFLAGS = [
        '-isysroot', osx_sysroot_path, '-mmacosx-version-min=10.9',
        '-Qunused-arguments'
    ]
    CXXFLAGS = [
        '-isysroot', osx_sysroot_path, '-mmacosx-version-min=10.9',
        '-Qunused-arguments', '-stdlib=libc++'
    ]
    CPPFLAGS = ['-DMONOTOUCH=1']
    LDFLAGS = ['-stdlib=libc++']

    CONFIGURE_FLAGS = [
        '--disable-boehm', '--disable-btls', '--disable-iconv',
        '--disable-libraries', '--disable-mcs-build', '--disable-nls',
        '--enable-dtrace=no', '--enable-icall-symbol-map',
        '--enable-minimal=com,remoting', '--enable-monotouch',
        '--disable-crash-reporting'
    ]

    env['_ios-%s_AC_VARS' % target] = AC_VARS
    env['_ios-%s_CFLAGS' % target] = CFLAGS
    env['_ios-%s_CXXFLAGS' % target] = CXXFLAGS
    env['_ios-%s_CPPFLAGS' % target] = CPPFLAGS
    env['_ios-%s_LDFLAGS' % target] = LDFLAGS
    env['_ios-%s_CONFIGURE_FLAGS' % target] = CONFIGURE_FLAGS

    # Runtime cross template
    runtime.setup_runtime_cross_template(env, opts, 'ios', target, host_triple,
                                         target_triple, device_target,
                                         'llvm64', offsets_dumper_abi)
Exemple #3
0
def setup_android_cross_mxe_template(env: dict, opts: AndroidOpts, target: str, host_arch: str):
    table_target = cross_targets[cross_mxe_targets.index(target)] # Re-use the non-mxe table

    target_arch = AndroidCrossTable.target_archs[table_target]
    device_target = AndroidCrossTable.device_targets[table_target]
    offsets_dumper_abi = AndroidCrossTable.offsets_dumper_abis[table_target]
    host_triple = '%s-w64-mingw32' % host_arch
    target_triple = '%s-linux-android' % target_arch

    android_libclang = get_android_libclang_path(opts)

    env['_android-%s_OFFSETS_DUMPER_ARGS' % target] = [
        '--libclang=%s' % android_libclang,
        '--sysroot=%s/sysroot' % opts.android_ndk_root
    ]

    mxe_bin = path_join(opts.mxe_prefix, 'bin')

    env['_android-%s_PATH' % target] = mxe_bin

    name_fmt = host_arch + '-w64-mingw32-%s'

    env['_android-%s_AR' % target] = path_join(mxe_bin, name_fmt % 'ar')
    env['_android-%s_AS' % target] = path_join(mxe_bin, name_fmt % 'as')
    env['_android-%s_CC' % target] = path_join(mxe_bin, name_fmt % 'gcc')
    env['_android-%s_CXX' % target] = path_join(mxe_bin, name_fmt % 'g++')
    env['_android-%s_DLLTOOL' % target] = path_join(mxe_bin, name_fmt % 'dlltool')
    env['_android-%s_LD' % target] = path_join(mxe_bin, name_fmt % 'ld')
    env['_android-%s_OBJDUMP' % target] = path_join(mxe_bin, name_fmt % 'objdump')
    env['_android-%s_RANLIB' % target] = path_join(mxe_bin, name_fmt % 'ranlib')
    env['_android-%s_STRIP' % target] = path_join(mxe_bin, name_fmt % 'strip')

    mingw_zlib_prefix = '%s/opt/mingw-zlib/usr' % opts.mxe_prefix
    if not os.path.isdir(mingw_zlib_prefix):
        mingw_zlib_prefix = opts.mxe_prefix

    CFLAGS = []
    CFLAGS += ['-DDEBUG_CROSS'] if not opts.release else []
    CFLAGS += ['-I%s/%s-w64-mingw32/include' % (mingw_zlib_prefix, host_arch)]

    env['_android-%s_CFLAGS' % target] = CFLAGS

    CXXFLAGS = []
    CXXFLAGS += ['-DDEBUG_CROSS'] if not opts.release else []
    CXXFLAGS += ['-I%s/%s-w64-mingw32/include' % (mingw_zlib_prefix, host_arch)]

    env['_android-%s_CXXFLAGS' % target] = CXXFLAGS

    env['_android-%s_LDFLAGS' % target] = []

    CONFIGURE_FLAGS = [
        '--disable-boehm',
        '--disable-mcs-build',
        '--disable-nls',
        '--enable-static-gcc-libs',
        '--enable-maintainer-mode',
        '--with-tls=pthread'
    ]

    CONFIGURE_FLAGS += ['--with-static-zlib=%s/%s-w64-mingw32/lib/libz.a' % (mingw_zlib_prefix, host_arch)]

    env['_android-%s_CONFIGURE_FLAGS' % target] = CONFIGURE_FLAGS

    # Runtime cross template
    runtime.setup_runtime_cross_template(env, opts, 'android', target, host_triple, target_triple, device_target, 'llvmwin64', offsets_dumper_abi)