def __init__(self): super(ArgParser, self).__init__( description='Repackages NDK modules as a monolithic package. If ' '--unpack is used, instead installs the monolithic ' 'package to a directory.') self.add_argument( '--arch', choices=build_support.ALL_ARCHITECTURES, help='Bundle only the given architecture.') self.add_argument( '--host', choices=('darwin', 'linux', 'windows', 'windows64'), default=build_support.get_default_host(), help='Package binaries for given OS (e.g. linux).') self.add_argument( '--build-number', default=0, help='Build number for use in version files.') self.add_argument( '--release', help='Ignored. Temporarily compatibility.') self.add_argument( '-f', '--force', dest='force', action='store_true', help='Clobber out directory if it exists.') self.add_argument( '--dist-dir', type=os.path.realpath, default=build_support.get_dist_dir(build_support.get_out_dir()), help='Directory containing NDK modules.') self.add_argument( '--unpack', action='store_true', help='Unpack the NDK to a directory rather than make a tarball.') self.add_argument( 'out_dir', metavar='OUT_DIR', help='Directory to install bundle or tarball to.')
def __init__(self): super(ArgParser, self).__init__(description=inspect.getdoc(sys.modules[__name__])) self.add_argument( '--arch', choices=('arm', 'arm64', 'mips', 'mips64', 'x86', 'x86_64'), help='Build for the given architecture. Build all by default.') package_group = self.add_mutually_exclusive_group() package_group.add_argument( '--package', action='store_true', dest='package', default=True, help='Package the NDK when done building (default).') package_group.add_argument( '--no-package', action='store_false', dest='package', help='Do not package the NDK when done building.') package_group.add_argument( '--force-package', action='store_true', dest='force_package', help='Force a package even if only building a subset of modules.') test_group = self.add_mutually_exclusive_group() test_group.add_argument('--test', action='store_true', dest='test', default=True, help=textwrap.dedent("""\ Run host tests when finished. --package is required. Not supported when targeting Windows. """)) test_group.add_argument('--no-test', action='store_false', dest='test', help='Do not run host tests when finished.') self.add_argument('--build-number', help='Build number for use in version files.') self.add_argument('--release', help='Ignored. Temporarily compatibility.') self.add_argument('--system', choices=('darwin', 'linux', 'windows', 'windows64'), default=build_support.get_default_host(), help='Build for the given OS.') module_group = self.add_mutually_exclusive_group() module_group.add_argument('--module', choices=sorted(ALL_MODULES), help='NDK modules to build.') module_group.add_argument('--host-only', action='store_true', help='Skip building target components.')
def __init__(self): super(ArgParser, self).__init__( description=inspect.getdoc(sys.modules[__name__])) self.add_argument( '--arch', choices=('arm', 'arm64', 'mips', 'mips64', 'x86', 'x86_64'), help='Build for the given architecture. Build all by default.') package_group = self.add_mutually_exclusive_group() package_group.add_argument( '--package', action='store_true', dest='package', default=True, help='Package the NDK when done building (default).') package_group.add_argument( '--no-package', action='store_false', dest='package', help='Do not package the NDK when done building.') package_group.add_argument( '--force-package', action='store_true', dest='force_package', help='Force a package even if only building a subset of modules.') test_group = self.add_mutually_exclusive_group() test_group.add_argument( '--test', action='store_true', dest='test', default=True, help=textwrap.dedent("""\ Run host tests when finished. --package is required. Not supported when targeting Windows. """)) test_group.add_argument( '--no-test', action='store_false', dest='test', help='Do not run host tests when finished.') self.add_argument( '--build-number', help='Build number for use in version files.') self.add_argument( '--release', help='Ignored. Temporarily compatibility.') self.add_argument( '--system', choices=('darwin', 'linux', 'windows', 'windows64'), default=build_support.get_default_host(), help='Build for the given OS.') module_group = self.add_mutually_exclusive_group() module_group.add_argument( '--module', choices=sorted(ALL_MODULES), help='NDK modules to build.') module_group.add_argument( '--host-only', action='store_true', help='Skip building target components.')
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)
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 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_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)