def build_gcc_libs(out_dir, dist_dir, args): print('Packaging GCC libs...') arches = build_support.ALL_ARCHITECTURES if args.arch is not None: arches = [args.arch] for arch in arches: toolchain = build_support.arch_to_toolchain(arch) triple = fixup_toolchain_triple(toolchain) libgcc_subdir = 'lib/gcc/{}/4.9'.format(triple) is64 = arch.endswith('64') libatomic_subdir = '{}/lib{}'.format(triple, '64' if is64 else '') lib_names = [ (libatomic_subdir, 'libatomic.a'), (libgcc_subdir, 'libgcc.a'), ] lib_dirs = [''] if arch == 'arm': lib_dirs += [ 'armv7-a', 'armv7-a/hard', 'armv7-a/thumb', 'armv7-a/thumb/hard', 'thumb', ] libs = [] for lib_dir in lib_dirs: for subdir, lib in lib_names: libs.append((subdir, os.path.join(lib_dir, lib))) install_dir = os.path.join(out_dir, 'gcclibs', triple) if os.path.exists(install_dir): shutil.rmtree(install_dir) os.makedirs(install_dir) # These are target libraries, so the OS we use here is not # important. We explicitly use Linux because for whatever reason # the Windows aarch64 toolchain doesn't include libatomic. gcc_path = get_prebuilt_gcc('linux', arch) for gcc_subdir, lib in libs: src = os.path.join(gcc_path, gcc_subdir, lib) dst = os.path.join(install_dir, lib) dst_dir = os.path.dirname(dst) if not os.path.exists(dst_dir): os.makedirs(dst_dir) shutil.copy2(src, dst) shutil.copy2(os.path.join(gcc_path, 'NOTICE'), os.path.join(install_dir, 'NOTICE')) archive_name = os.path.join('gcclibs-' + arch) build_support.make_package(archive_name, install_dir, dist_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)
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 main(args) -> None: RS_VERSION = 'current' host: Host = args.host package_dir = args.dist_dir os_name = args.host.value if os_name == 'windows64': os_name = 'windows' prebuilt_path = get_rs_prebuilt_path(f'{os_name}-x86') print(f'prebuilt path: {prebuilt_path}') package_name = f'renderscript-toolchain-{host_to_tag(host)}' built_path = os.path.join(prebuilt_path, RS_VERSION) build_support.make_package(package_name, built_path, package_dir)
def main(args): RS_VERSION = 'current' host = args.host out_dir = args.out_dir package_dir = args.dist_dir os_name = host if os_name == 'windows64': os_name = 'windows' prebuilt_path = get_rs_prebuilt_path(os_name + '-x86') print('prebuilt path: ' + prebuilt_path) if host == 'darwin': host = 'darwin-x86_64' elif host == 'linux': host = 'linux-x86_64' elif host == 'windows': host = 'windows' elif host == 'windows64': host = 'windows-x86_64' package_name = 'renderscript-toolchain-{}'.format(host) built_path = os.path.join(prebuilt_path, RS_VERSION) build_support.make_package(package_name, built_path, package_dir)
def main(args): RS_VERSION = 'current' host = args.host out_dir = args.out_dir; package_dir = args.dist_dir os_name = host if os_name == 'windows64': os_name = 'windows' prebuilt_path = get_rs_prebuilt_path(os_name + '-x86') print('prebuilt path: ' + prebuilt_path) if host == 'darwin': host = 'darwin-x86_64' elif host == 'linux': host = 'linux-x86_64' elif host == 'windows': host = 'windows' elif host == 'windows64': host = 'windows-x86_64' package_name = 'renderscript-toolchain-{}'.format(host) built_path = os.path.join(prebuilt_path, RS_VERSION) build_support.make_package(package_name, built_path, package_dir)
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 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)
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')
def build_ndk_helper(_, dist_dir, __): path = build_support.ndk_path('sources/android/ndk_helper') build_support.make_package('ndk_helper', path, dist_dir)
def build_cpufeatures(_, dist_dir, __): path = build_support.ndk_path('sources/android/cpufeatures') build_support.make_package('cpufeatures', path, dist_dir)
def pack_binutils(arch, host_tag, out_dir, binutils_path): archive_name = '-'.join(['binutils', arch, host_tag]) build_support.make_package(archive_name, binutils_path, out_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')
def build_gtest(_, dist_dir, __): path = build_support.ndk_path('sources/third_party/googletest') build_support.make_package('gtest', path, dist_dir)
def build_native_app_glue(_, dist_dir, __): path = build_support.ndk_path('sources/android/native_app_glue') build_support.make_package('native_app_glue', path, dist_dir)
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 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)
def build_build(_, dist_dir, __): path = build_support.ndk_path('build') build_support.make_package('build', path, 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"): 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)
def build_system_stl(_out_dir, dist_dir, _args): print('Building system-stl...') path = build_support.ndk_path('sources/cxx-stl/system') build_support.make_package('system-stl', path, dist_dir)
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 build_libcxxabi(_out_dir, dist_dir, _args): print('Building libc++abi...') path = build_support.ndk_path('sources/cxx-stl/llvm-libc++abi') build_support.make_package('libcxxabi', path, 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_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 build_libandroid_support(_out_dir, dist_dir, _args): print('Building libandroid_support...') path = build_support.ndk_path('sources/android/support') build_support.make_package('libandroid_support', path, dist_dir)
def build_gabixx(_out_dir, dist_dir, _args): print('Building gabi++...') path = build_support.ndk_path('sources/cxx-stl/gabi++') build_support.make_package('gabixx', path, 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_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"): # 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)