Example #1
0
def get_prebuilt_gcc(host, arch):
    tag = build_support.host_to_tag(host)
    system_subdir = 'prebuilts/ndk/current/toolchains/{}'.format(tag)
    system_path = build_support.android_path(system_subdir)
    toolchain = build_support.arch_to_toolchain(arch)
    toolchain_dir = toolchain + '-4.9'
    return os.path.join(system_path, toolchain_dir)
def get_rs_prebuilt_path(host):
    rel_prebuilt_path = 'prebuilts/renderscript/host/{}'.format(host)
    prebuilt_path = os.path.join(build_support.android_path(),
                                 rel_prebuilt_path)
    if not os.path.isdir(prebuilt_path):
        sys.exit('Could not find prebuilt RenderScript at {}'.format(prebuilt_path))
    return prebuilt_path
Example #3
0
def get_gcc_prebuilt_path(host):
    rel_prebuilt_path = 'prebuilts/ndk/current/toolchains/{}'.format(host)
    prebuilt_path = os.path.join(build_support.android_path(),
                                 rel_prebuilt_path)
    if not os.path.isdir(prebuilt_path):
        sys.exit('Could not find prebuilt GCC at {}'.format(prebuilt_path))
    return prebuilt_path
Example #4
0
def get_gcc_prebuilt_path(host):
    rel_prebuilt_path = 'prebuilts/ndk/current/toolchains/{}'.format(host)
    prebuilt_path = os.path.join(build_support.android_path(),
                                 rel_prebuilt_path)
    if not os.path.isdir(prebuilt_path):
        sys.exit('Could not find prebuilt GCC at {}'.format(prebuilt_path))
    return prebuilt_path
Example #5
0
def get_rs_prebuilt_path(host_tag: str) -> str:
    rel_prebuilt_path = f'prebuilts/renderscript/host/{host_tag}'
    prebuilt_path = os.path.join(build_support.android_path(),
                                 rel_prebuilt_path)
    if not os.path.isdir(prebuilt_path):
        sys.exit(f'Could not find prebuilt RenderScript at {prebuilt_path}')
    return prebuilt_path
Example #6
0
def get_llvm_prebuilt_path(host):
    rel_prebuilt_path = 'prebuilts/clang/host/{}'.format(host)
    prebuilt_path = os.path.join(build_support.android_path(),
                                 rel_prebuilt_path)
    if not os.path.isdir(prebuilt_path):
        sys.exit('Could not find prebuilt LLVM at {}'.format(prebuilt_path))
    return prebuilt_path
def get_rs_prebuilt_path(host):
    rel_prebuilt_path = 'prebuilts/renderscript/host/{}'.format(host)
    prebuilt_path = os.path.join(build_support.android_path(),
                                 rel_prebuilt_path)
    if not os.path.isdir(prebuilt_path):
        sys.exit(
            'Could not find prebuilt RenderScript at {}'.format(prebuilt_path))
    return prebuilt_path
def build_python_packages(_, dist_dir, __):
    # Stage the files in a temporary directory to make things easier.
    temp_dir = tempfile.mkdtemp()
    try:
        path = os.path.join(temp_dir, 'python-packages')
        shutil.copytree(
            build_support.android_path('development/python-packages'), path)
        build_support.make_package('python-packages', path, dist_dir)
    finally:
        shutil.rmtree(temp_dir)
def build_python_packages(_, dist_dir, __):
    # Stage the files in a temporary directory to make things easier.
    temp_dir = tempfile.mkdtemp()
    try:
        path = os.path.join(temp_dir, 'python-packages')
        shutil.copytree(
            build_support.android_path('development/python-packages'), path)
        build_support.make_package('python-packages', path, dist_dir)
    finally:
        shutil.rmtree(temp_dir)
Example #10
0
def package_host_tools(out_dir, dist_dir, host):
    packages = [
        'gdb-multiarch-7.11',
        'ndk-awk',
        'ndk-depends',
        'ndk-make',
        'ndk-python',
        'ndk-stack',
        'ndk-yasm',
    ]

    files = [
        'ndk-gdb',
        'ndk-gdb.py',
        'ndk-which',
    ]

    if host in ('windows', 'windows64'):
        packages.append('toolbox')
        files.append('ndk-gdb.cmd')

    host_tag = build_support.host_to_tag(host)

    package_names = [p + '-' + host_tag + '.tar.bz2' for p in packages]
    for package_name in package_names:
        package_path = os.path.join(out_dir, package_name)
        subprocess.check_call(['tar', 'xf', package_path, '-C', out_dir])

    for f in files:
        shutil.copy2(f, os.path.join(out_dir, 'host-tools/bin'))

    build_support.merge_license_files(
        os.path.join(out_dir, 'host-tools/NOTICE'), [
            build_support.android_path('toolchain/gdb/gdb-7.11/COPYING'),
            build_support.ndk_path('sources/host-tools/nawk-20071023/NOTICE'),
            build_support.ndk_path('sources/host-tools/ndk-depends/NOTICE'),
            build_support.ndk_path('sources/host-tools/make-3.81/COPYING'),
            build_support.android_path(
                'toolchain/python/Python-2.7.5/LICENSE'),
            build_support.ndk_path('sources/host-tools/ndk-stack/NOTICE'),
            build_support.ndk_path('sources/host-tools/toolbox/NOTICE'),
            build_support.android_path('toolchain/yasm/COPYING'),
            build_support.android_path('toolchain/yasm/BSD.txt'),
            build_support.android_path('toolchain/yasm/Artistic.txt'),
            build_support.android_path('toolchain/yasm/GNU_GPL-2.0'),
            build_support.android_path('toolchain/yasm/GNU_LGPL-2.0'),
        ])

    package_name = 'host-tools-' + host_tag
    path = os.path.join(out_dir, 'host-tools')
    build_support.make_package(package_name, path, dist_dir)
def package_host_tools(out_dir, dist_dir, host):
    packages = [
        'gdb-multiarch-7.11',
        'ndk-awk',
        'ndk-depends',
        'ndk-make',
        'ndk-python',
        'ndk-stack',
        'ndk-yasm',
    ]

    files = [
        'ndk-gdb',
        'ndk-gdb.py',
        'ndk-which',
    ]

    if host in ('windows', 'windows64'):
        packages.append('toolbox')
        files.append('ndk-gdb.cmd')

    host_tag = build_support.host_to_tag(host)

    package_names = [p + '-' + host_tag + '.tar.bz2' for p in packages]
    for package_name in package_names:
        package_path = os.path.join(out_dir, package_name)
        subprocess.check_call(['tar', 'xf', package_path, '-C', out_dir])

    for f in files:
        shutil.copy2(f, os.path.join(out_dir, 'host-tools/bin'))

    build_support.merge_license_files(
        os.path.join(out_dir, 'host-tools/NOTICE'), [
            build_support.android_path('toolchain/gdb/gdb-7.11/COPYING'),
            build_support.ndk_path('sources/host-tools/nawk-20071023/NOTICE'),
            build_support.ndk_path('sources/host-tools/ndk-depends/NOTICE'),
            build_support.ndk_path('sources/host-tools/make-3.81/COPYING'),
            build_support.android_path(
                'toolchain/python/Python-2.7.5/LICENSE'),
            build_support.ndk_path('sources/host-tools/ndk-stack/NOTICE'),
            build_support.ndk_path('sources/host-tools/toolbox/NOTICE'),
            build_support.android_path('toolchain/yasm/COPYING'),
            build_support.android_path('toolchain/yasm/BSD.txt'),
            build_support.android_path('toolchain/yasm/Artistic.txt'),
            build_support.android_path('toolchain/yasm/GNU_GPL-2.0'),
            build_support.android_path('toolchain/yasm/GNU_LGPL-2.0'),
        ])

    package_name = 'host-tools-' + host_tag
    path = os.path.join(out_dir, 'host-tools')
    build_support.make_package(package_name, path, dist_dir)
Example #12
0
def get_all_packages(host, arches):
    packages = [
        ('cpufeatures', 'sources/android/cpufeatures'),
        ('gabixx', 'sources/cxx-stl/gabi++'),
        ('gcc-{toolchain}-{host}',
         'toolchains/{toolchain}-4.9/prebuilt/{host}'),
        ('gdbserver-{arch}', 'prebuilt/android-{arch}/gdbserver'),
        ('shader-tools-{host}', 'shader-tools/{host}'),
        ('gnustl-4.9', 'sources/cxx-stl/gnu-libstdc++/4.9'),
        ('gtest', 'sources/third_party/googletest'),
        ('host-tools-{host}', 'prebuilt/{host}'),
        ('libandroid_support', 'sources/android/support'),
        ('libcxx', 'sources/cxx-stl/llvm-libc++'),
        ('libcxxabi', 'sources/cxx-stl/llvm-libc++abi'),
        ('llvm-{host}', 'toolchains/llvm/prebuilt/{host}'),
        ('native_app_glue', 'sources/android/native_app_glue'),
        ('ndk-build', 'build'),
        ('ndk_helper', 'sources/android/ndk_helper'),
        ('python-packages', 'python-packages'),
        ('shaderc', 'sources/third_party/shaderc'),
        ('simpleperf', 'simpleperf'),
        ('stlport', 'sources/cxx-stl/stlport'),
        ('system-stl', 'sources/cxx-stl/system'),
        ('vulkan', 'sources/third_party/vulkan'),
    ]

    platforms_path = 'development/ndk/platforms'
    for platform_dir in os.listdir(build_support.android_path(platforms_path)):
        if not platform_dir.startswith('android-'):
            continue
        _, platform_str = platform_dir.split('-')

        # Anything before Ginger Bread is unsupported, so don't ship them.
        if int(platform_str) < 9:
            continue

        package_name = 'platform-' + platform_str
        install_path = 'platforms/android-' + platform_str
        packages.append((package_name, install_path))

    expanded = []
    for package, extract_path in packages:
        package_names = expand_packages(package, host, arches)
        extract_paths = expand_packages(extract_path, host, arches)
        expanded.extend(zip(package_names, extract_paths))
    return expanded
Example #13
0
def get_all_packages(host, arches):
    packages = [
        ('build', 'build'),
        ('cpufeatures', 'sources/android/cpufeatures'),
        ('gabixx', 'sources/cxx-stl/gabi++'),
        ('gcc-{arch}-{host}', 'toolchains/{toolchain}-4.9/prebuilt/{host}'),
        ('gdbserver-{arch}', 'prebuilt/android-{arch}/gdbserver'),
        ('shader-tools-{host}', 'shader-tools/{host}'),
        ('gnustl-4.9', 'sources/cxx-stl/gnu-libstdc++/4.9'),
        ('gtest', 'sources/third_party/googletest'),
        ('host-tools-{host}', 'prebuilt/{host}'),
        ('libandroid_support', 'sources/android/support'),
        ('libcxx', 'sources/cxx-stl/llvm-libc++'),
        ('libcxxabi', 'sources/cxx-stl/llvm-libc++abi'),
        ('llvm-{host}', 'toolchains/llvm/prebuilt/{host}'),
        ('native_app_glue', 'sources/android/native_app_glue'),
        ('ndk_helper', 'sources/android/ndk_helper'),
        ('python-packages', 'python-packages'),
        ('shaderc', 'sources/third_party/shaderc'),
        ('stlport', 'sources/cxx-stl/stlport'),
        ('system-stl', 'sources/cxx-stl/system'),
        ('vulkan', 'sources/third_party/vulkan'),
    ]

    platforms_path = 'development/ndk/platforms'
    for platform_dir in os.listdir(build_support.android_path(platforms_path)):
        if not platform_dir.startswith('android-'):
            continue
        _, platform_str = platform_dir.split('-')

        # Anything before Ginger Bread is unsupported, so don't ship them.
        if int(platform_str) < 9:
            continue

        package_name = 'platform-' + platform_str
        install_path = 'platforms/android-' + platform_str
        packages.append((package_name, install_path))

    expanded = []
    for package, extract_path in packages:
        package_names = expand_packages(package, host, arches)
        extract_paths = expand_packages(extract_path, host, arches)
        expanded.extend(zip(package_names, extract_paths))
    return expanded
Example #14
0
def build_binutils(out_dir, dist_dir, args):
    print('Extracting binutils package from GCC...')

    arches = build_support.ALL_ARCHITECTURES
    if args.arch is not None:
        arches = [args.arch]

    host_tag = build_support.host_to_tag(args.system)

    for arch in arches:
        toolchain = build_support.arch_to_toolchain(arch)
        toolchain_path = get_prebuilt_gcc(args.system, arch)

        triple = fixup_toolchain_triple(toolchain)

        install_dir = os.path.join(out_dir, 'binutils', triple)
        if os.path.exists(install_dir):
            shutil.rmtree(install_dir)
        os.makedirs(install_dir)

        has_gold = True
        if host_tag == 'windows':
            # Note: 64-bit Windows is fine.
            has_gold = False
        if arch in ('mips', 'mips64'):
            has_gold = False

        is_windows = host_tag.startswith('windows')
        for file_name in get_binutils_files(triple, has_gold, is_windows):
            install_file(file_name, toolchain_path, install_dir)

        license_path = build_support.android_path(
            'toolchain/binutils/binutils-2.25/COPYING')
        shutil.copy2(license_path, os.path.join(install_dir, 'NOTICE'))

        pack_binutils(arch, host_tag, dist_dir, install_dir)
Example #15
0
def invoke_external_build(script, args=None):
    _invoke_build(build_support.android_path(script), args)
def main(args):
    host_tag = build_support.host_to_tag(args.host)
    build_host_tag = build_support.get_default_host() + "-x86"

    package_dir = args.dist_dir

    # TODO(danalbert): use ndk/sources/third_party/googletest/googletest
    # after it has been updated to a version with CMakeLists
    gtest_dir = os.path.join(build_support.android_path(), 'external',
                             'googletest')

    obj_out = os.path.join(args.out_dir, 'shader_tools/obj')
    install_dir = os.path.join(args.out_dir, 'shader_tools/install')

    package_src = '-'.join(
        [os.path.join(args.out_dir, 'shader_tools/shader-tools'), host_tag])
    package_name = '-'.join(['shader-tools', host_tag])

    source_root = os.path.join(build_support.android_path(), 'external',
                               'shaderc')
    shaderc_shaderc_dir = os.path.join(source_root, 'shaderc')

    cmake = os.path.join(build_support.android_path(), 'prebuilts', 'cmake',
                         build_host_tag, 'bin', 'cmake')
    ctest = os.path.join(build_support.android_path(), 'prebuilts', 'cmake',
                         build_host_tag, 'bin', 'ctest')
    ninja = os.path.join(build_support.android_path(), 'prebuilts', 'ninja',
                         build_host_tag, 'ninja')
    file_extension = ''

    additional_args = []
    if args.host.startswith("windows"):
        mingw_root = os.path.join(build_support.android_path(), 'prebuilts',
                                  'gcc', build_host_tag, 'host',
                                  'x86_64-w64-mingw32-4.8')
        mingw_compilers = os.path.join(mingw_root, 'bin', 'x86_64-w64-mingw32')
        mingw_toolchain = os.path.join(source_root, 'shaderc', 'cmake',
                                       'linux-mingw-toolchain.cmake')
        additional_args = [
            '-DCMAKE_TOOLCHAIN_FILE=' + mingw_toolchain,
            '-DMINGW_SYSROOT=' + mingw_root,
            '-DMINGW_COMPILER_PREFIX=' + mingw_compilers
        ]
        file_extension = '.exe'
        if args.host == "windows64":
            additional_args.extend(
                ['-DCMAKE_CXX_FLAGS=-fno-rtti -fno-exceptions'])
        else:
            additional_args.extend([
                '-DCMAKE_CXX_FLAGS=-m32 -fno-rtti -fno-exceptions',
                '-DCMAKE_C_FLAGS=-m32'
            ])

    for d in [package_src, obj_out, install_dir]:
        try:
            os.makedirs(d)
        except:
            pass

    build_support.merge_license_files(os.path.join(package_src, 'NOTICE'), [
        os.path.join(shaderc_shaderc_dir, 'LICENSE'),
        os.path.join(shaderc_shaderc_dir, 'third_party',
                     'LICENSE.spirv-tools'),
        os.path.join(shaderc_shaderc_dir, 'third_party', 'LICENSE.glslang')
    ])

    cmake_command = [
        cmake, '-GNinja', '-DCMAKE_MAKE_PROGRAM=' + ninja,
        '-DCMAKE_BUILD_TYPE=Release', '-DCMAKE_INSTALL_PREFIX=' + install_dir,
        '-DSHADERC_THIRD_PARTY_ROOT_DIR=' + source_root,
        '-DSHADERC_GOOGLE_TEST_DIR=' + gtest_dir, shaderc_shaderc_dir
    ]

    cmake_command.extend(additional_args)

    subprocess.check_call(cmake_command, cwd=obj_out)
    subprocess.check_call([cmake, '--build', obj_out, '--', '-v'])
    subprocess.check_call(
        [cmake, '--build', obj_out, '--target', 'install/strip'])

    files_to_copy = [
        'glslc' + file_extension, 'spirv-as' + file_extension,
        'spirv-dis' + file_extension, 'spirv-val' + file_extension
    ]
    if (not args.host.startswith('windows')):
        subprocess.check_call([ctest, '--verbose'], cwd=obj_out)

    for src in files_to_copy:
        shutil.copy2(os.path.join(install_dir, 'bin', src),
                     os.path.join(package_src, src))

    build_support.make_package(package_name, package_src, package_dir)
Example #17
0
import os
import shutil
import site
import subprocess
import sys
import tempfile
import textwrap

import config

site.addsitedir(os.path.join(os.path.dirname(__file__), 'build/lib'))

import build_support  # pylint: disable=import-error

# Importing tests.runners requires that adb can be imported.
site.addsitedir(build_support.android_path('development/python-packages'))

import tests.runners
import tests.printers


ALL_MODULES = {
    'build',
    'clang',
    'cpufeatures',
    'gabi++',
    'gcc',
    'gdbserver',
    'gnustl',
    'gtest',
    'host-tools',
Example #18
0
def _invoke_build(script, args):
    if args is None:
        args = []
    subprocess.check_call([build_support.android_path(script)] + args)
def main(args):
    host_tag = build_support.host_to_tag(args.host)
    build_host_tag = build_support.get_default_host() + "-x86"

    package_dir = args.dist_dir

    # TODO(danalbert): use ndk/sources/third_party/googletest/googletest
    # after it has been updated to a version with CMakeLists
    gtest_dir = os.path.join(build_support.android_path(), 'external',
                             'googletest')

    obj_out = os.path.join(args.out_dir, 'shader_tools/obj')
    install_dir = os.path.join(args.out_dir, 'shader_tools/install')

    package_src = '-'.join([os.path.join(args.out_dir,
                                         'shader_tools/shader-tools'),
                            host_tag])
    package_name = '-'.join(['shader-tools', host_tag])

    source_root = os.path.join(build_support.android_path(), 'external',
                               'shaderc')
    shaderc_shaderc_dir = os.path.join(source_root, 'shaderc')

    cmake = os.path.join(build_support.android_path(),
                         'prebuilts', 'cmake', build_host_tag, 'bin', 'cmake')
    ctest = os.path.join(build_support.android_path(),
                         'prebuilts', 'cmake', build_host_tag, 'bin', 'ctest')
    ninja = os.path.join(build_support.android_path(),
                         'prebuilts', 'ninja', build_host_tag, 'ninja')
    file_extension = ''

    additional_args = []
    if args.host.startswith("windows"):
        mingw_root = os.path.join(build_support.android_path(),
                                  'prebuilts', 'gcc', build_host_tag, 'host',
                                  'x86_64-w64-mingw32-4.8')
        mingw_compilers = os.path.join(mingw_root, 'bin', 'x86_64-w64-mingw32')
        mingw_toolchain = os.path.join(source_root, 'shaderc',
                                       'cmake', 'linux-mingw-toolchain.cmake')
        additional_args = ['-DCMAKE_TOOLCHAIN_FILE=' + mingw_toolchain,
                           '-DMINGW_SYSROOT=' + mingw_root,
                           '-DMINGW_COMPILER_PREFIX=' + mingw_compilers]
        file_extension = '.exe'
        if args.host == "windows64":
            additional_args.extend(
                ['-DCMAKE_CXX_FLAGS=-fno-rtti -fno-exceptions'])
        else:
            additional_args.extend(
                ['-DCMAKE_CXX_FLAGS=-m32 -fno-rtti -fno-exceptions',
                 '-DCMAKE_C_FLAGS=-m32'])

    for d in [package_src, obj_out, install_dir]:
        try:
            os.makedirs(d)
        except:
            pass

    build_support.merge_license_files(os.path.join(package_src, 'NOTICE'), [
        os.path.join(shaderc_shaderc_dir, 'LICENSE'),
        os.path.join(shaderc_shaderc_dir,
                     'third_party',
                     'LICENSE.spirv-tools'),
        os.path.join(shaderc_shaderc_dir,
                     'third_party',
                     'LICENSE.glslang')])

    cmake_command = [cmake, '-GNinja', '-DCMAKE_MAKE_PROGRAM=' + ninja,
                     '-DCMAKE_BUILD_TYPE=Release',
                     '-DCMAKE_INSTALL_PREFIX=' + install_dir,
                     '-DSHADERC_THIRD_PARTY_ROOT_DIR=' + source_root,
                     '-DSHADERC_GOOGLE_TEST_DIR=' + gtest_dir,
                     shaderc_shaderc_dir]

    cmake_command.extend(additional_args)

    subprocess.check_call(cmake_command, cwd=obj_out)
    subprocess.check_call([cmake, '--build', obj_out, '--', '-v'])
    subprocess.check_call([cmake, '--build', obj_out,
                           '--target', 'install/strip'])

    files_to_copy = ['glslc' + file_extension,
                     'spirv-as' + file_extension,
                     'spirv-dis' + file_extension,
                     'spirv-val' + file_extension]
    if (not args.host.startswith('windows')):
        subprocess.check_call([ctest, '--verbose'], cwd=obj_out)

    for src in files_to_copy:
        shutil.copy2(os.path.join(install_dir, 'bin', src),
                     os.path.join(package_src, src))

    build_support.make_package(package_name, package_src, package_dir)
def main(args):
    host_tag = build_support.host_to_tag(args.host)
    build_host_tag = build_support.get_default_host() + "-x86"

    package_dir = args.dist_dir

    # TODO(danalbert): use ndk/sources/third_party/googletest/googletest
    # after it has been updated to a version with CMakeLists
    gtest_cmd = (
        '-DSHADERC_GOOGLE_TEST_DIR=' +
        os.path.join(build_support.android_path(), 'external', 'googletest'))

    obj_out = os.path.join(args.out_dir, 'shader_tools/obj')
    install_dir = os.path.join(args.out_dir, 'shader_tools/install')

    package_src = '-'.join(
        [os.path.join(args.out_dir, 'shader_tools/shader-tools'), host_tag])
    package_name = '-'.join(['shader-tools', host_tag])

    source_root = os.path.join(build_support.android_path(), 'external',
                               'shaderc')
    shaderc_shaderc_dir = os.path.join(source_root, 'shaderc')
    spirv_headers_dir = os.path.join(source_root, 'spirv-headers')

    cmake = os.path.join(build_support.android_path(), 'prebuilts', 'cmake',
                         build_host_tag, 'bin', 'cmake')
    ctest = os.path.join(build_support.android_path(), 'prebuilts', 'cmake',
                         build_host_tag, 'bin', 'ctest')
    ninja = os.path.join(build_support.android_path(), 'prebuilts', 'ninja',
                         build_host_tag, 'ninja')
    file_extension = ''

    additional_args = []
    if args.host.startswith("windows"):
        gtest_cmd = ''
        mingw_root = os.path.join(build_support.android_path(), 'prebuilts',
                                  'gcc', build_host_tag, 'host',
                                  'x86_64-w64-mingw32-4.8')
        mingw_compilers = os.path.join(mingw_root, 'bin', 'x86_64-w64-mingw32')
        mingw_toolchain = os.path.join(source_root, 'shaderc', 'cmake',
                                       'linux-mingw-toolchain.cmake')
        gtest_root = os.path.join(build_support.android_path(), 'external',
                                  'googletest')
        additional_args = [
            '-DCMAKE_TOOLCHAIN_FILE=' + mingw_toolchain,
            '-DMINGW_SYSROOT=' + mingw_root,
            '-DMINGW_COMPILER_PREFIX=' + mingw_compilers,
            '-DSHADERC_GOOGLE_TEST_DIR=' + gtest_root
        ]
        file_extension = '.exe'
        if args.host == "windows64":
            additional_args.extend(
                ['-DCMAKE_CXX_FLAGS=-fno-rtti -fno-exceptions'])
        else:
            additional_args.extend([
                '-DCMAKE_CXX_FLAGS=-m32 -fno-rtti -fno-exceptions',
                '-DCMAKE_C_FLAGS=-m32'
            ])

    for d in [package_src, obj_out, install_dir]:
        try:
            os.makedirs(d)
        except:
            pass

    cmake_command = [
        cmake, '-GNinja', '-DCMAKE_MAKE_PROGRAM=' + ninja,
        '-DCMAKE_BUILD_TYPE=Release', '-DCMAKE_INSTALL_PREFIX=' + install_dir,
        '-DSHADERC_THIRD_PARTY_ROOT_DIR=' + source_root,
        '-DSPIRV-Headers_SOURCE_DIR=' + spirv_headers_dir, gtest_cmd,
        shaderc_shaderc_dir
    ]

    cmake_command.extend(additional_args)

    subprocess.check_call(cmake_command, cwd=obj_out)
    subprocess.check_call([cmake, '--build', obj_out, '--', '-v'])
    subprocess.check_call(
        [cmake, '--build', obj_out, '--target', 'install/strip'])

    files_to_copy = [
        'glslc' + file_extension, 'spirv-as' + file_extension,
        'spirv-dis' + file_extension, 'spirv-val' + file_extension,
        'spirv-cfg' + file_extension, 'spirv-opt' + file_extension
    ]
    scripts_to_copy = [
        'spirv-lesspipe.sh',
    ]
    files_to_copy.extend(scripts_to_copy)

    # Test, except on windows.
    if (not args.host.startswith('windows')):
        subprocess.check_call([ctest, '--verbose'], cwd=obj_out)

    # Copy to install tree.
    for src in files_to_copy:
        shutil.copy2(os.path.join(install_dir, 'bin', src),
                     os.path.join(package_src, src))
    if args.host.startswith('windows'):
        for src in scripts_to_copy:
            # Convert line endings on scripts.
            # Do it in place to preserve executable permissions.
            subprocess.check_call(
                ['unix2dos', '-o',
                 os.path.join(package_src, src)])

    build_support.make_package(package_name, package_src, package_dir)
Example #21
0
def get_all_packages(host, arches):
    new_layout = [
        ('binutils-{arch}-{host}', 'binutils/{triple}'),
        ('build', 'build'),
        ('cpufeatures', 'sources/android/cpufeatures'),
        ('gabixx', 'sources/cxx-stl/gabi++'),
        ('gcc-{arch}-{host}', 'toolchains/{toolchain}-4.9'),
        ('gcclibs-{arch}', 'gcclibs/{triple}'),
        ('gdbserver-{arch}', 'gdbserver/{arch}'),
        ('gnustl-4.9', 'sources/cxx-stl/gnu-libstdc++'),
        ('gtest', 'sources/third_party/googletest'),
        ('host-tools-{host}', 'host-tools'),
        ('libandroid_support', 'sources/android/support'),
        ('libcxx', 'sources/cxx-stl/llvm-libc++'),
        ('libcxxabi', 'sources/cxx-stl/llvm-libc++abi'),
        ('llvm-{host}', 'toolchains/llvm'),
        ('native_app_glue', 'sources/android/native_app_glue'),
        ('ndk_helper', 'sources/android/ndk_helper'),
        ('python-packages', 'python-packages'),
        ('stlport', 'sources/cxx-stl/stlport'),
        ('system-stl', 'sources/cxx-stl/system'),
    ]

    old_layout = [
        ('build', 'build'),
        ('cpufeatures', 'sources/android/cpufeatures'),
        ('gabixx', 'sources/cxx-stl/gabi++'),
        ('gcc-{arch}-{host}', 'toolchains/{toolchain}-4.9/prebuilt/{host}'),
        ('gdbserver-{arch}', 'prebuilt/android-{arch}/gdbserver'),
        ('gnustl-4.9', 'sources/cxx-stl/gnu-libstdc++/4.9'),
        ('gtest', 'sources/third_party/googletest'),
        ('host-tools-{host}', 'prebuilt/{host}'),
        ('libandroid_support', 'sources/android/support'),
        ('libcxx', 'sources/cxx-stl/llvm-libc++'),
        ('libcxxabi', 'sources/cxx-stl/llvm-libc++abi'),
        ('llvm-{host}', 'toolchains/llvm/prebuilt/{host}'),
        ('native_app_glue', 'sources/android/native_app_glue'),
        ('ndk_helper', 'sources/android/ndk_helper'),
        ('python-packages', 'python-packages'),
        ('stlport', 'sources/cxx-stl/stlport'),
        ('system-stl', 'sources/cxx-stl/system'),
    ]

    if USE_NEW_LAYOUT:
        packages = new_layout
    else:
        packages = old_layout

    platforms_path = 'development/ndk/platforms'
    for platform_dir in os.listdir(build_support.android_path(platforms_path)):
        if not platform_dir.startswith('android-'):
            continue
        _, platform_str = platform_dir.split('-')
        package_name = 'platform-' + platform_str
        install_path = 'platforms/android-' + platform_str
        packages.append((package_name, install_path))

    expanded = []
    for package, extract_path in packages:
        package_names = expand_packages(package, host, arches)
        extract_paths = expand_packages(extract_path, host, arches)
        expanded.extend(zip(package_names, extract_paths))
    return expanded
Example #22
0
def build_ndk_helper(_, dist_dir, __):
    path = build_support.android_path(
        'development/ndk/sources/android/ndk_helper')
    build_support.make_package('ndk_helper', path, dist_dir)
import os
import shutil
import site
import subprocess
import sys
import tempfile
import textwrap

import config

site.addsitedir(os.path.join(os.path.dirname(__file__), 'build/lib'))

import build_support  # pylint: disable=import-error

# Importing tests.runners requires that adb can be imported.
site.addsitedir(build_support.android_path('development/python-packages'))

import tests.runners
import tests.printers

ALL_MODULES = {
    'build',
    'clang',
    'cpufeatures',
    'gabi++',
    'gcc',
    'gdbserver',
    'gnustl',
    'gtest',
    'host-tools',
    'libandroid_support',
Example #24
0
def build_libshaderc(_, dist_dir, __):
    print('Building libshaderc...')
    shaderc_root_dir = build_support.android_path('external/shaderc')

    copies = [
        {
            'source_dir': os.path.join(shaderc_root_dir, 'shaderc'),
            'dest_dir': 'shaderc',
            'files': [
                'Android.mk', 'libshaderc/Android.mk',
                'libshaderc_util/Android.mk',
                'third_party/Android.mk',
            ],
            'dirs': [
                'libshaderc/include', 'libshaderc/src',
                'libshaderc_util/include', 'libshaderc_util/src',
            ],
        },
        {
            'source_dir': os.path.join(shaderc_root_dir, 'spirv-tools'),
            'dest_dir': 'shaderc/third_party/spirv-tools',
            'files': [],
            'dirs': ['include', 'source'],
        },
        {
            'source_dir': os.path.join(shaderc_root_dir, 'glslang'),
            'dest_dir': 'shaderc/third_party/glslang',
            'files': ['glslang/OSDependent/osinclude.h'],
            'dirs': [
                'SPIRV',
                'OGLCompilersDLL',
                'glslang/GenericCodeGen',
                'glslang/Include',
                'glslang/MachineIndependent',
                'glslang/OSDependent/Unix',
                'glslang/Public',
            ],
        },
    ]

    default_ignore_patterns = shutil.ignore_patterns(
        "*CMakeLists.txt",
        "*.py",
        "*test.h",
        "*test.cc")

    temp_dir = tempfile.mkdtemp()
    shaderc_path = os.path.join(temp_dir, 'shaderc')
    try:
        for properties in copies:
            source_dir = properties['source_dir']
            dest_dir = os.path.join(temp_dir, properties['dest_dir'])
            for d in properties['dirs']:
                src = os.path.join(source_dir, d)
                dst = os.path.join(dest_dir, d)
                shutil.copytree(src, dst,
                                ignore=default_ignore_patterns)
            for f in properties['files']:
                print(source_dir, ':', dest_dir, ":", f)
                install_file(f, source_dir, dest_dir)

        shaderc_shaderc_dir = os.path.join(shaderc_root_dir, 'shaderc')
        build_support.merge_license_files(
            os.path.join(shaderc_path, 'NOTICE'), [
                os.path.join(shaderc_shaderc_dir, 'LICENSE'),
                os.path.join(shaderc_shaderc_dir,
                             'third_party',
                             'LICENSE.spirv-tools'),
                os.path.join(shaderc_shaderc_dir,
                             'third_party',
                             'LICENSE.glslang')])
        build_support.make_package('shaderc', shaderc_path, dist_dir)
    finally:
        shutil.rmtree(temp_dir)
def _invoke_build(script, args):
    if args is None:
        args = []
    subprocess.check_call([build_support.android_path(script)] + args)
def build_libshaderc(_, dist_dir, __):
    print('Building libshaderc...')
    shaderc_root_dir = build_support.android_path('external/shaderc')

    copies = [
        {
            'source_dir':
            os.path.join(shaderc_root_dir, 'shaderc'),
            'dest_dir':
            'shaderc',
            'files': [
                'Android.mk',
                'libshaderc/Android.mk',
                'libshaderc_util/Android.mk',
                'third_party/Android.mk',
            ],
            'dirs': [
                'libshaderc/include',
                'libshaderc/src',
                'libshaderc_util/include',
                'libshaderc_util/src',
            ],
        },
        {
            'source_dir': os.path.join(shaderc_root_dir, 'spirv-tools'),
            'dest_dir': 'shaderc/third_party/spirv-tools',
            'files': [],
            'dirs': ['include', 'source'],
        },
        {
            'source_dir':
            os.path.join(shaderc_root_dir, 'glslang'),
            'dest_dir':
            'shaderc/third_party/glslang',
            'files': ['glslang/OSDependent/osinclude.h'],
            'dirs': [
                'SPIRV',
                'OGLCompilersDLL',
                'glslang/GenericCodeGen',
                'glslang/Include',
                'glslang/MachineIndependent',
                'glslang/OSDependent/Unix',
                'glslang/Public',
            ],
        },
    ]

    default_ignore_patterns = shutil.ignore_patterns("*CMakeLists.txt", "*.py",
                                                     "*test.h", "*test.cc")

    temp_dir = tempfile.mkdtemp()
    shaderc_path = os.path.join(temp_dir, 'shaderc')
    try:
        for properties in copies:
            source_dir = properties['source_dir']
            dest_dir = os.path.join(temp_dir, properties['dest_dir'])
            for d in properties['dirs']:
                src = os.path.join(source_dir, d)
                dst = os.path.join(dest_dir, d)
                shutil.copytree(src, dst, ignore=default_ignore_patterns)
            for f in properties['files']:
                print(source_dir, ':', dest_dir, ":", f)
                install_file(f, source_dir, dest_dir)

        shaderc_shaderc_dir = os.path.join(shaderc_root_dir, 'shaderc')
        build_support.merge_license_files(os.path.join(
            shaderc_path, 'NOTICE'), [
                os.path.join(shaderc_shaderc_dir, 'LICENSE'),
                os.path.join(shaderc_shaderc_dir, 'third_party',
                             'LICENSE.spirv-tools'),
                os.path.join(shaderc_shaderc_dir, 'third_party',
                             'LICENSE.glslang')
            ])
        build_support.make_package('shaderc', shaderc_path, dist_dir)
    finally:
        shutil.rmtree(temp_dir)
def invoke_external_build(script, args=None):
    _invoke_build(build_support.android_path(script), args)
Example #28
0
def build_vulkan(out_dir, dist_dir, args):
    print('Constructing Vulkan validation layer source...')
    vulkan_root_dir = build_support.android_path('external/vulkan-validation-layers')

    copies = [
        {
            'source_dir': vulkan_root_dir,
            'dest_dir': 'vulkan/src',
            'files': [
              'vk-generate.py',
              'vk_helper.py',
              'vk-layer-generate.py',
              'generator.py',
              'genvk.py',
              'reg.py',
              'source_line_info.py',
              'vulkan.py',
              'vk.xml'
            ],
            'dirs': [
                'layers', 'include'
            ],
        },
        {
            'source_dir': vulkan_root_dir + '/loader',
            'dest_dir': 'vulkan/src/loader',
            'files': [
              'vk_loader_platform.h'
            ],
            'dirs': [],
        },
        {
            'source_dir': build_support.android_path('external/shaderc/glslang'),
            'dest_dir': 'vulkan/glslang',
            'files': [],
            'dirs': [
                'SPIRV',
            ],
        },
    ]

    default_ignore_patterns = shutil.ignore_patterns(
        "*CMakeLists.txt",
        "*test.h",
        "*test.cc",
        "linux",
        "windows")

    vulkan_path = os.path.join(out_dir, 'vulkan/src')
    for properties in copies:
        source_dir = properties['source_dir']
        dest_dir = os.path.join(out_dir, properties['dest_dir'])
        for d in properties['dirs']:
            src = os.path.join(source_dir, d)
            dst = os.path.join(dest_dir, d)
            shutil.rmtree(dst, 'true')
            shutil.copytree(src, dst,
                            ignore=default_ignore_patterns)
        for f in properties['files']:
            install_file(f, source_dir, dest_dir)

    # Copy Android build components
    src = os.path.join(vulkan_root_dir, 'build-android')
    dst = os.path.join(vulkan_path, 'build-android')
    shutil.rmtree(dst, 'true')
    shutil.copytree(src, dst,
                  ignore=default_ignore_patterns)

    build_support.merge_license_files(
        os.path.join(vulkan_path, 'NOTICE'), [
        os.path.join(vulkan_root_dir, 'LICENSE.txt')])

    build_cmd = [
        'bash', vulkan_path + '/build-android/android-generate.sh'
    ]
    print('Generating generated layers...')
    subprocess.check_call(build_cmd)
    print('Generation finished')

    build_args = common_build_args(out_dir, dist_dir, args)
    if args.arch is not None:
        build_args.append('--arch={}'.format(args.arch))
    build_args.append('--no-symbols')

    # TODO: Verify source packaged properly
    print('Packaging Vulkan source...')
    src = os.path.join(out_dir, 'vulkan')
    build_support.make_package('vulkan', src, dist_dir)
    print('Packaging Vulkan source finished')
Example #29
0
def main(args):
    arches = build_support.ALL_ARCHITECTURES
    if args.arch is not None:
        arches = [args.arch]

    abis = []
    for arch in arches:
        abis.extend(build_support.arch_to_abis(arch))

    ndk_build = build_support.ndk_path('build/ndk-build')
    prebuilt_ndk = build_support.android_path('prebuilts/ndk/current')
    platforms_root = os.path.join(prebuilt_ndk, 'platforms')
    toolchains_root = os.path.join(prebuilt_ndk, 'toolchains')
    libcxx_path = build_support.android_path('external/libcxx')
    obj_out = os.path.join(args.out_dir, 'libcxx/obj')

    # TODO(danalbert): Stop building to the source directory.
    # This is historical, and simplifies packaging a bit. We need to pack up
    # all the source as well as the libraries. If build_support.make_package
    # were to change to allow a list of directories instead of one directory,
    # we could make this unnecessary.  Will be a follow up CL.
    lib_out = os.path.join(libcxx_path, 'libs')

    build_cmd = [
        'bash',
        ndk_build,
        '-C',
        THIS_DIR,
        build_support.jobs_arg(),
        'V=1',
        'APP_ABI=' + ' '.join(abis),

        # Use the prebuilt platforms and toolchains.
        'NDK_PLATFORMS_ROOT=' + platforms_root,
        'NDK_TOOLCHAINS_ROOT=' + toolchains_root,
        'NDK_NEW_TOOLCHAINS_LAYOUT=true',

        # Tell ndk-build where all of our makefiles are and where outputs
        # should go. The defaults in ndk-build are only valid if we have a
        # typical ndk-build layout with a jni/{Android,Application}.mk.
        'NDK_PROJECT_PATH=null',
        'APP_BUILD_SCRIPT=' + os.path.join(libcxx_path, 'Android.mk'),
        'NDK_APPLICATION_MK=' + os.path.join(libcxx_path, 'Application.mk'),
        'NDK_OUT=' + obj_out,
        'NDK_LIBS_OUT=' + lib_out,

        # Make sure we don't pick up a cached copy.
        'LIBCXX_FORCE_REBUILD=true',
    ]
    print('Building libc++ for ABIs: {}'.format(', '.join(abis)))
    print('Running: ' + ' '.join(build_cmd))
    subprocess.check_call(build_cmd)

    # The static libraries are installed to NDK_OUT, not NDK_LIB_OUT, so we
    # need to install them to our package directory.
    for abi in abis:
        static_lib_dir = os.path.join(obj_out, 'local', abi)
        install_dir = os.path.join(lib_out, abi)
        is_arm = abi.startswith('armeabi')

        if is_arm:
            shutil.copy2(os.path.join(static_lib_dir, 'libunwind.a'),
                         install_dir)

        shutil.copy2(os.path.join(static_lib_dir, 'libc++abi.a'), install_dir)
        shutil.copy2(os.path.join(static_lib_dir, 'libandroid_support.a'),
                     install_dir)
        shutil.copy2(os.path.join(static_lib_dir, 'libc++_static.a'),
                     install_dir)

        # Create linker scripts for the libraries we use so that we link things
        # properly even when we're not using ndk-build. The linker will read
        # the script in place of the library so that we link the unwinder and
        # other support libraries appropriately.
        static_libs = ['-lc++_static', '-lc++abi', '-landroid_support']
        if is_arm:
            static_libs.extend(['-lunwind', '-latomic'])
        make_linker_script(os.path.join(install_dir, 'libc++.a'), static_libs)

        shared_libs = ['-landroid_support']
        if is_arm:
            shared_libs.extend(['-lunwind', '-latomic'])
        shared_libs.append('-lc++_shared')
        make_linker_script(os.path.join(install_dir, 'libc++.so'), shared_libs)

    build_support.make_package('libc++', libcxx_path, args.dist_dir)
def main(args):
    host_tag = build_support.host_to_tag(args.host)
    build_host_tag = build_support.get_default_host() + "-x86"

    package_dir = args.dist_dir

    # TODO(danalbert): use ndk/sources/third_party/googletest/googletest
    # after it has been updated to a version with CMakeLists
    gtest_cmd = ('-DSHADERC_GOOGLE_TEST_DIR=' +
                 os.path.join(build_support.android_path(),
                              'external', 'googletest'))

    obj_out = os.path.join(args.out_dir, 'shader_tools/obj')
    install_dir = os.path.join(args.out_dir, 'shader_tools/install')

    package_src = '-'.join([os.path.join(args.out_dir,
                                         'shader_tools/shader-tools'),
                            host_tag])
    package_name = '-'.join(['shader-tools', host_tag])

    source_root = os.path.join(build_support.android_path(), 'external',
                               'shaderc')
    shaderc_shaderc_dir = os.path.join(source_root, 'shaderc')
    spirv_headers_dir = os.path.join(source_root, 'spirv-headers')

    cmake = os.path.join(build_support.android_path(),
                         'prebuilts', 'cmake', build_host_tag, 'bin', 'cmake')
    ctest = os.path.join(build_support.android_path(),
                         'prebuilts', 'cmake', build_host_tag, 'bin', 'ctest')
    ninja = os.path.join(build_support.android_path(),
                         'prebuilts', 'ninja', build_host_tag, 'ninja')
    file_extension = ''

    additional_args = []
    if args.host.startswith("windows"):
        # Use MinGW to cross compile.
        # Use the stock MinGW-w64 from Ubuntu.
        # The prebuilts MinGW GCC 4.8.3 appears to be broken.
        mingw_toolchain = os.path.join(source_root, 'shaderc',
                                       'cmake', 'linux-mingw-toolchain.cmake')
        # Turn off pthreads support in gtest. Otherwise I get an error in
        # gtest-port.h for use of type AutoHandle in gtest-port.h without a
        # definition.
        additional_args = ['-DCMAKE_TOOLCHAIN_FILE=' + mingw_toolchain,
                           '-Dgtest_disable_pthreads=ON']
        file_extension = '.exe'
        if args.host == "windows64":
            additional_args.extend(
                ['-DCMAKE_CXX_FLAGS=-fno-rtti -fno-exceptions'])
        else:
            additional_args.extend(
                ['-DCMAKE_CXX_FLAGS=-m32 -fno-rtti -fno-exceptions',
                 '-DCMAKE_C_FLAGS=-m32'])

    for d in [package_src, obj_out, install_dir]:
        try:
            os.makedirs(d)
        except:
            pass

    # Create the NOTICE file.
    license_files = [
        os.path.join(shaderc_shaderc_dir, 'LICENSE'),
        os.path.join(shaderc_shaderc_dir,
                     'third_party',
                     'LICENSE.spirv-tools'),
        os.path.join(shaderc_shaderc_dir,
                     'third_party',
                     'LICENSE.glslang'),
    ]
    # The SPIRV-Headers might not have landed just yet.  Use its
    # license file if it exists.
    spirv_headers_license = os.path.join(spirv_headers_dir, 'LICENSE')
    if os.path.exists(spirv_headers_license):
        license_files.append(spirv_headers_license)

    build_support.merge_license_files(os.path.join(package_src, 'NOTICE'),
                                      license_files)

    cmake_command = [cmake, '-GNinja', '-DCMAKE_MAKE_PROGRAM=' + ninja,
                     '-DCMAKE_BUILD_TYPE=Release',
                     '-DCMAKE_INSTALL_PREFIX=' + install_dir,
                     '-DSHADERC_THIRD_PARTY_ROOT_DIR=' + source_root,
                     '-DSPIRV-Headers_SOURCE_DIR=' + spirv_headers_dir,
                     gtest_cmd,
                     shaderc_shaderc_dir]

    cmake_command.extend(additional_args)

    subprocess.check_call(cmake_command, cwd=obj_out)
    subprocess.check_call([cmake, '--build', obj_out, '--', '-v'])
    subprocess.check_call([cmake, '--build', obj_out,
                           '--target', 'install/strip'])

    files_to_copy = ['glslc' + file_extension,
                     'spirv-as' + file_extension,
                     'spirv-dis' + file_extension,
                     'spirv-val' + file_extension,
                     'spirv-cfg' + file_extension,
                     'spirv-opt' + file_extension]
    scripts_to_copy = ['spirv-lesspipe.sh',]
    files_to_copy.extend(scripts_to_copy)

    # Test, except on windows.
    if (not args.host.startswith('windows')):
        subprocess.check_call([ctest, '--verbose'], cwd=obj_out)

    # Copy to install tree.
    for src in files_to_copy:
        shutil.copy2(os.path.join(install_dir, 'bin', src),
                     os.path.join(package_src, src))
    if args.host.startswith('windows'):
        for src in scripts_to_copy:
            # Convert line endings on scripts.
            # Do it in place to preserve executable permissions.
            subprocess.check_call(['unix2dos', '-o',
                                   os.path.join(package_src, src)])

    build_support.make_package(package_name, package_src, package_dir)
Example #31
0
def main(args):
    arches = build_support.ALL_ARCHITECTURES
    if args.arch is not None:
        arches = [args.arch]

    abis = []
    for arch in arches:
        abis.extend(build_support.arch_to_abis(arch))

    ndk_build = build_support.ndk_path('build/ndk-build')
    prebuilt_ndk = build_support.android_path('prebuilts/ndk/current')
    platforms_root = os.path.join(prebuilt_ndk, 'platforms')
    toolchains_root = os.path.join(prebuilt_ndk, 'toolchains')
    libcxx_path = build_support.ndk_path('sources/cxx-stl/llvm-libc++')
    obj_out = os.path.join(args.out_dir, 'libcxx/obj')

    # TODO(danalbert): Stop building to the source directory.
    # This is historical, and simplifies packaging a bit. We need to pack up
    # all the source as well as the libraries. If build_support.make_package
    # were to change to allow a list of directories instead of one directory,
    # we could make this unnecessary.  Will be a follow up CL.
    lib_out = os.path.join(libcxx_path, 'libs')

    build_cmd = [
        'bash', ndk_build, '-C', THIS_DIR, build_support.jobs_arg(), 'V=1',
        'APP_ABI=' + ' '.join(abis),

        # Use the prebuilt platforms and toolchains.
        'NDK_PLATFORMS_ROOT=' + platforms_root,
        'NDK_TOOLCHAINS_ROOT=' + toolchains_root,
        'NDK_NEW_TOOLCHAINS_LAYOUT=true',

        # Tell ndk-build where all of our makefiles are and where outputs
        # should go. The defaults in ndk-build are only valid if we have a
        # typical ndk-build layout with a jni/{Android,Application}.mk.
        'NDK_PROJECT_PATH=null',
        'APP_BUILD_SCRIPT=' + os.path.join(THIS_DIR, 'Android.mk'),
        'NDK_APPLICATION_MK=' + os.path.join(THIS_DIR, 'Application.mk'),
        'NDK_OUT=' + obj_out,
        'NDK_LIBS_OUT=' + lib_out,

        # Make sure we don't pick up a cached copy.
        'LIBCXX_FORCE_REBUILD=true',

        # Put armeabi-v7a-hard in its own directory.
        '_NDK_TESTING_ALL_=yes',
    ]
    print('Building libc++ for ABIs: {}'.format(', '.join(abis)))
    subprocess.check_call(build_cmd)

    # The static libraries are installed to NDK_OUT, not NDK_LIB_OUT, so we
    # need to install them to our package directory.
    for abi in abis:
        static_lib_dir = os.path.join(obj_out, 'local', abi)
        install_dir = os.path.join(lib_out, abi)
        is_arm = abi.startswith('armeabi')

        if is_arm:
            shutil.copy2(
                os.path.join(static_lib_dir, 'libunwind.a'), install_dir)

        shutil.copy2(os.path.join(static_lib_dir, 'libc++abi.a'), install_dir)
        shutil.copy2(
            os.path.join(static_lib_dir, 'libandroid_support.a'), install_dir)
        shutil.copy2(
            os.path.join(static_lib_dir, 'libc++_static.a'), install_dir)

    build_support.make_package('libcxx', libcxx_path, args.dist_dir)
def build_vulkan(out_dir, dist_dir, args):
    print('Constructing Vulkan validation layer source...')
    vulkan_root_dir = build_support.android_path(
        'external/vulkan-validation-layers')

    copies = [
        {
            'source_dir':
            vulkan_root_dir,
            'dest_dir':
            'vulkan/src',
            'files': [
                'vk-generate.py', 'vk_helper.py', 'vk-layer-generate.py',
                'generator.py', 'genvk.py', 'reg.py', 'source_line_info.py',
                'vulkan.py', 'vk.xml'
            ],
            'dirs': ['layers', 'include'],
        },
        {
            'source_dir': vulkan_root_dir + '/loader',
            'dest_dir': 'vulkan/src/loader',
            'files': ['vk_loader_platform.h'],
            'dirs': [],
        },
        {
            'source_dir':
            build_support.android_path('external/shaderc/glslang'),
            'dest_dir': 'vulkan/glslang',
            'files': [],
            'dirs': [
                'SPIRV',
            ],
        },
    ]

    default_ignore_patterns = shutil.ignore_patterns("*CMakeLists.txt",
                                                     "*test.h", "*test.cc",
                                                     "linux", "windows")

    vulkan_path = os.path.join(out_dir, 'vulkan/src')
    for properties in copies:
        source_dir = properties['source_dir']
        dest_dir = os.path.join(out_dir, properties['dest_dir'])
        for d in properties['dirs']:
            src = os.path.join(source_dir, d)
            dst = os.path.join(dest_dir, d)
            shutil.rmtree(dst, 'true')
            shutil.copytree(src, dst, ignore=default_ignore_patterns)
        for f in properties['files']:
            install_file(f, source_dir, dest_dir)

    # Copy Android build components
    src = os.path.join(vulkan_root_dir, 'build-android')
    dst = os.path.join(vulkan_path, 'build-android')
    shutil.rmtree(dst, 'true')
    shutil.copytree(src, dst, ignore=default_ignore_patterns)

    build_support.merge_license_files(os.path.join(
        vulkan_path, 'NOTICE'), [os.path.join(vulkan_root_dir, 'LICENSE.txt')])

    build_cmd = ['bash', vulkan_path + '/build-android/android-generate.sh']
    print('Generating generated layers...')
    subprocess.check_call(build_cmd)
    print('Generation finished')

    build_args = common_build_args(out_dir, dist_dir, args)
    if args.arch is not None:
        build_args.append('--arch={}'.format(args.arch))
    build_args.append('--no-symbols')

    # TODO: Verify source packaged properly
    print('Packaging Vulkan source...')
    src = os.path.join(out_dir, 'vulkan')
    build_support.make_package('vulkan', src, dist_dir)
    print('Packaging Vulkan source finished')
Example #33
0
def build_native_app_glue(_, dist_dir, __):
    path = build_support.android_path(
        'development/ndk/sources/android/native_app_glue')
    build_support.make_package('native_app_glue', path, dist_dir)