Beispiel #1
0
def load_android_clang_common_settings(conf):
    """
    Setup all compiler and linker settings shared over all android clang configurations
    !!! But not the actual compiler, since the compiler depends on the host !!!
    """

    env = conf.env
    ndk_root = env['ANDROID_NDK_HOME']
    is_ndk_19_plus = env['ANDROID_IS_NDK_19_PLUS']

    common_flags = []
    cxx_flags = []

    if not is_ndk_19_plus:
        stl_root = os.path.join(ndk_root, 'sources', 'cxx-stl', 'llvm-libc++')

        env['INCLUDES'] += [
            os.path.join(stl_root, 'include'),
            os.path.join(
                ndk_root, 'sources', 'android', 'support',
                'include')  # the support includes must be after the stl ones
        ]

        env['LIBPATH'] += [
            os.path.join(stl_root, 'libs', env['ANDROID_ARCH']),
        ]

        env['LIB'] += [
            'c++_shared',  # shared library of llvm stl
        ]

        # required 3rd party libs that need to be included in the apk
        env['EXT_LIBS'] += [
            conf.add_to_android_cache(
                os.path.join(stl_root, 'libs', env['ANDROID_ARCH'],
                             'libc++_shared.so'))
        ]

    env['CFLAGS'] += common_flags[:]
    env['CXXFLAGS'] += common_flags[:] + cxx_flags[:]

    # these aren't defined in the common clang settings
    env['SHLIB_MARKER'] = '-Wl,-Bdynamic'
    env['STLIB_MARKER'] = '-Wl,-Bstatic'

    # not used on android
    env['ARCH_ST'] = []

    # disable support for the following build options
    env['COMPILER_FLAGS_DisableOptimization'] = []
    env['COMPILER_FLAGS_DebugSymbols'] = []
def load_profile_android_armv8_settings(conf):
    """
    Setup all compiler and linker settings shared over all android armv8 configurations
    for the "profile" configuration
    """
    conf.load_android_armv8_common_settings()

    # required 3rd party libs that need to be included in the apk
    # Note: gdbserver is only required for debuggable builds
    conf.env['EXT_LIBS'] += [
        conf.add_to_android_cache(
            os.path.join(conf.env['ANDROID_NDK_HOME'], 'prebuilt',
                         'android-arm64', 'gdbserver', 'gdbserver'))
    ]
Beispiel #3
0
def load_android_gcc_common_settings(conf):
    """
    Setup all compiler and linker settings shared over all android gcc configurations
    !!! But not the actual compiler, since the compiler depends on the host !!!
    """

    # additional gcc build settings for android
    env = conf.env
    ndk_root = env['ANDROID_NDK_HOME']

    stl_root = os.path.join(ndk_root, 'sources', 'cxx-stl', 'gnu-libstdc++',
                            '4.9')
    env['INCLUDES'] += [
        os.path.join(stl_root, 'include'),
        os.path.join(stl_root, 'libs', env['ANDROID_ARCH'], 'include'),
    ]

    common_flags = [
        # Enabled Warnings
        '-Wsequence-point',  # undefined semantics warning
        '-Wmissing-braces',  # missing brackets in union initializers
        '-Wreturn-type',  # no return value
        '-Winit-self',  # un-initialized vars used to init themselves
        '-Winvalid-pch',  # cant use found pre-compiled header

        # Disabled Warnings
        '-Wno-error=pragmas',  # Bad pragmas wont cause compile errors, just warnings
        '-Wno-deprecated',  # allow deprecated features of the compiler, not the deprecated attribute

        # Other
        '-fms-extensions',  # allow some non standard constructs
        '-MP',  # add PHONY targets to each dependency
        '-MMD',  # use file name as object file name
    ]

    env['CFLAGS'] += common_flags[:]

    env['CXXFLAGS'] += common_flags[:]
    env['CXXFLAGS'] += [
        '-std=gnu++1y',  # set the c++ standard to GNU C++14
        '-fpermissive',  # allow some non-conformant code
    ]

    env['LIB'] += [
        'gnustl_shared',  # shared library of gnu stl
    ]

    env['LIBPATH'] += [
        os.path.join(stl_root, 'libs', env['ANDROID_ARCH']),
    ]

    # required 3rd party libs that need to be included in the apk
    env['EXT_LIBS'] += [
        conf.add_to_android_cache(
            os.path.join(stl_root, 'libs', env['ANDROID_ARCH'],
                         'libgnustl_shared.so'))
    ]

    # disable support for the following build options
    env['COMPILER_FLAGS_DisableOptimization'] = []
    env['COMPILER_FLAGS_DebugSymbols'] = []
Beispiel #4
0
def load_android_clang_common_settings(conf):
    """
    Setup all compiler and linker settings shared over all android clang configurations
    !!! But not the actual compiler, since the compiler depends on the host !!!
    """

    env = conf.env
    ndk_root = env['ANDROID_NDK_HOME']
    ndk_rev = env['ANDROID_NDK_REV_MAJOR']

    is_ndk_19_plus = (ndk_rev >= 19)

    common_flags = [
        '-femulated-tls',  # All accesses to TLS variables are converted to calls to __emutls_get_address in the runtime library
    ]
    cxx_flags = [
        '-fms-extensions',  # Allow MSVC language extensions
    ]

    if is_ndk_19_plus:
        libcpp = ['-stdlib=libc++']

        cxx_flags += libcpp[:]
        env['LINKFLAGS'] += libcpp[:]

    else:
        stl_root = os.path.join(ndk_root, 'sources', 'cxx-stl', 'llvm-libc++')

        env['INCLUDES'] += [
            os.path.join(stl_root, 'include'),
            os.path.join(
                ndk_root, 'sources', 'android', 'support',
                'include')  # the support includes must be after the stl ones
        ]

        env['LIBPATH'] += [
            os.path.join(stl_root, 'libs', env['ANDROID_ARCH']),
        ]

        env['LIB'] += [
            'c++_shared',  # shared library of llvm stl
        ]

        # required 3rd party libs that need to be included in the apk
        env['EXT_LIBS'] += [
            conf.add_to_android_cache(
                os.path.join(stl_root, 'libs', env['ANDROID_ARCH'],
                             'libc++_shared.so'))
        ]

    env['CFLAGS'] += common_flags[:]
    env['CXXFLAGS'] += common_flags[:] + cxx_flags[:]

    # these aren't defined in the common clang settings
    env['SHLIB_MARKER'] = '-Wl,-Bdynamic'
    env['STLIB_MARKER'] = '-Wl,-Bstatic'

    # not used on android
    env['ARCH_ST'] = []

    # disable support for the following build options
    env['COMPILER_FLAGS_DisableOptimization'] = []
    env['COMPILER_FLAGS_DebugSymbols'] = []
def load_android_clang_common_settings(conf):
    """
    Setup all compiler and linker settings shared over all android clang configurations
    !!! But not the actual compiler, since the compiler depends on the host !!!
    """

    env = conf.env
    ndk_root = env['ANDROID_NDK_HOME']

    # in ndk r13, they removed the 'libcxx' sub-dir, leaving 'include' in the root of the folder
    stl_root = os.path.join(ndk_root, 'sources', 'cxx-stl', 'llvm-libc++')
    if env['ANDROID_NDK_REV_MAJOR'] >= 13:
        stl_includes = os.path.join(stl_root, 'include')
    else:
        stl_includes = os.path.join(stl_root, 'libcxx', 'include')

    env['INCLUDES'] += [
        stl_includes,
        os.path.join(
            ndk_root, 'sources', 'android', 'support',
            'include')  # the support includes must be after the stl ones
    ]

    common_flags = [
        '-femulated-tls',  # All accesses to TLS variables are converted to calls to __emutls_get_address in the runtime library
        '-Wno-unused-lambda-capture',

        # This was originally disabled only when building Android Clang on MacOS, but it seems the updated toolchain in NDK r15 has
        # become even more aggressive in "nonportable" include paths, meaning it's nearly impossible to fix the casing the compiler
        # thinks the path should be.
        # ORIGINAL COMMENT: Unless specified, OSX is generally case-preserving but case-insensitive.  Windows is the same way, however
        # OSX seems to behave differently when it comes to casing at the OS level where a file can be showing as upper-case in Finder
        # and Terminal, the OS can see it as lower-case.
        '-Wno-nonportable-include-path',
    ]

    env['CFLAGS'] += common_flags[:]

    env['CXXFLAGS'] += common_flags[:]
    env['CXXFLAGS'] += [
        '-fms-extensions',  # Allow MSVC language extensions
    ]

    env['LIB'] += [
        'c++_shared',  # shared library of llvm stl
    ]

    env['LIBPATH'] += [
        os.path.join(stl_root, 'libs', env['ANDROID_ARCH']),
    ]

    env['LINKFLAGS'] += [
        '-Wl,--gc-sections,--icf=safe',  # --gc-sections will discard unused sections. --icf=safe will remove duplicate code
    ]

    # these aren't defined in the common clang settings
    env['SHLIB_MARKER'] = '-Wl,-Bdynamic'
    env['STLIB_MARKER'] = '-Wl,-Bstatic'

    # required 3rd party libs that need to be included in the apk
    env['EXT_LIBS'] += [
        conf.add_to_android_cache(
            os.path.join(stl_root, 'libs', env['ANDROID_ARCH'],
                         'libc++_shared.so'))
    ]

    # not used on android
    env['ARCH_ST'] = []

    # disable support for the following build options
    env['COMPILER_FLAGS_DisableOptimization'] = []
    env['COMPILER_FLAGS_DebugSymbols'] = []