diff --git a/build/linux/unbundle/fontconfig.gn b/build/linux/unbundle/fontconfig.gn new file mode 100644 index 0000000..87926d5 --- /dev/null +++ b/build/linux/unbundle/fontconfig.gn @@ -0,0 +1,13 @@ +# Copyright 2017 The Chromium Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +assert(is_linux || is_chromeos) + +config("fontconfig_config") { + libs = [ "fontconfig" ] +} + +group("fontconfig") { + public_configs = [ ":fontconfig_config" ] +} diff --git a/build/linux/unbundle/freetype2.gn b/build/linux/unbundle/freetype2.gn new file mode 100644 index 0000000..3b8cafb --- /dev/null +++ b/build/linux/unbundle/freetype2.gn @@ -0,0 +1,35 @@ +# Copyright 2013 The Flutter Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import("//build/config/linux/pkg_config.gni") +import("//build/shim_headers.gni") + +config("freetype_config") { + include_dirs = [ "include/freetype-flutter-config" ] + + cflags = [] + + if (is_clang) { + cflags += [ + "-Wno-unused-function", + "-Wno-unused-variable", + ] + } +} + +pkg_config("system_freetype2") { + packages = [ "freetype2" ] +} + +source_set("freetype2") { + output_name = "freetype2" + deps = [ + "//third_party/libpng", + "//third_party/zlib", + ] + public_configs = [ + ":freetype_config", + ":system_freetype2", + ] +} diff --git a/build/linux/unbundle/harfbuzz.gn b/build/linux/unbundle/harfbuzz.gn new file mode 100644 index 0000000..72d3e06 --- /dev/null +++ b/build/linux/unbundle/harfbuzz.gn @@ -0,0 +1,31 @@ +# Copyright 2013 The Flutter Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import("//build/config/linux/pkg_config.gni") + +pkg_config("system_harfbuzz") { + packages = [ "harfbuzz" ] +} + +pkg_config("system_harfbuzz_subset") { + packages = [ "harfbuzz-subset" ] +} + +source_set("harfbuzz") { + output_name = "harfbuzz" + deps = [ + "//third_party/freetype2", + "//third_party/icu:icuuc", + ] + public_configs = [ ":system_harfbuzz" ] +} + +source_set("harfbuzz_subset") { + output_name = "harfbuzz_subset" + deps = [ + "//third_party/freetype2", + "//third_party/icu:icuuc", + ] + public_configs = [ ":system_harfbuzz_subset" ] +} diff --git a/build/linux/unbundle/icu.gn b/build/linux/unbundle/icu.gn new file mode 100644 index 0000000..9e54d4e --- /dev/null +++ b/build/linux/unbundle/icu.gn @@ -0,0 +1,262 @@ +# Copyright 2016 The Chromium Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import("//build/config/linux/pkg_config.gni") +import("//build/shim_headers.gni") + +group("icu") { + public_deps = [ + ":icui18n", + ":icuuc", + ] +} + +config("icu_config") { + defines = [ + "USING_SYSTEM_ICU=1", + "ICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_STATIC", + + # U_EXPORT (defined in unicode/platform.h) is used to set public visibility + # on classes through the U_COMMON_API and U_I18N_API macros (among others). + # When linking against the system ICU library, we want its symbols to have + # public LTO visibility. This disables CFI checks for the ICU classes and + # allows whole-program optimization to be applied to the rest of Chromium. + # + # Both U_COMMON_API and U_I18N_API macros would be defined to U_EXPORT only + # when U_COMBINED_IMPLEMENTATION is defined (see unicode/utypes.h). Because + # we override the default system UCHAR_TYPE (char16_t), it is not possible + # to use U_COMBINED_IMPLEMENTATION at this moment, meaning the U_COMMON_API + # and U_I18N_API macros are set to U_IMPORT which is an empty definition. + # + # Until building with UCHAR_TYPE=char16_t is supported, one way to apply + # public visibility (and thus public LTO visibility) to all ICU classes is + # to define U_IMPORT to have the same value as U_EXPORT. For more details, + # please see: https://crbug.com/822820 + "U_IMPORT=U_EXPORT", + ] +} + +pkg_config("system_icui18n") { + packages = [ "icu-i18n" ] +} + +pkg_config("system_icuuc") { + packages = [ "icu-uc" ] +} + +source_set("icui18n") { + public_deps = [ ":icui18n_shim" ] + public_configs = [ + ":icu_config", + ":system_icui18n", + ] +} + +source_set("icuuc") { + public_deps = [ ":icuuc_shim" ] + public_configs = [ + ":icu_config", + ":system_icuuc", + ] +} + +group("icui18n_hidden_visibility") { + public_deps = [ ":icui18n" ] +} + +group("icuuc_hidden_visibility") { + public_deps = [ ":icuuc" ] +} + +shim_headers("icui18n_shim") { + root_path = "source/i18n" + headers = [ + # This list can easily be updated using the commands below: + # cd third_party/icu/source/i18n + # find unicode -iname '*.h' -printf ' "%p",\n' | LC_ALL=C sort -u + "unicode/alphaindex.h", + "unicode/basictz.h", + "unicode/calendar.h", + "unicode/choicfmt.h", + "unicode/coleitr.h", + "unicode/coll.h", + "unicode/compactdecimalformat.h", + "unicode/curramt.h", + "unicode/currpinf.h", + "unicode/currunit.h", + "unicode/datefmt.h", + "unicode/dcfmtsym.h", + "unicode/decimfmt.h", + "unicode/dtfmtsym.h", + "unicode/dtitvfmt.h", + "unicode/dtitvinf.h", + "unicode/dtptngen.h", + "unicode/dtrule.h", + "unicode/fieldpos.h", + "unicode/fmtable.h", + "unicode/format.h", + "unicode/fpositer.h", + "unicode/gender.h", + "unicode/gregocal.h", + "unicode/listformatter.h", + "unicode/measfmt.h", + "unicode/measunit.h", + "unicode/measure.h", + "unicode/msgfmt.h", + "unicode/numfmt.h", + "unicode/numsys.h", + "unicode/plurfmt.h", + "unicode/plurrule.h", + "unicode/rbnf.h", + "unicode/rbtz.h", + "unicode/regex.h", + "unicode/region.h", + "unicode/reldatefmt.h", + "unicode/scientificnumberformatter.h", + "unicode/search.h", + "unicode/selfmt.h", + "unicode/simpletz.h", + "unicode/smpdtfmt.h", + "unicode/sortkey.h", + "unicode/stsearch.h", + "unicode/tblcoll.h", + "unicode/timezone.h", + "unicode/tmunit.h", + "unicode/tmutamt.h", + "unicode/tmutfmt.h", + "unicode/translit.h", + "unicode/tzfmt.h", + "unicode/tznames.h", + "unicode/tzrule.h", + "unicode/tztrans.h", + "unicode/ucal.h", + "unicode/ucol.h", + "unicode/ucoleitr.h", + "unicode/ucsdet.h", + "unicode/udat.h", + "unicode/udateintervalformat.h", + "unicode/udatpg.h", + "unicode/ufieldpositer.h", + "unicode/uformattable.h", + "unicode/ugender.h", + "unicode/ulocdata.h", + "unicode/umsg.h", + "unicode/unirepl.h", + "unicode/unum.h", + "unicode/unumsys.h", + "unicode/upluralrules.h", + "unicode/uregex.h", + "unicode/uregion.h", + "unicode/ureldatefmt.h", + "unicode/usearch.h", + "unicode/uspoof.h", + "unicode/utmscale.h", + "unicode/utrans.h", + "unicode/vtzone.h", + ] +} + +shim_headers("icuuc_shim") { + root_path = "source/common" + headers = [ + # This list can easily be updated using the commands below: + # cd third_party/icu/source/common + # find unicode -iname '*.h' -printf ' "%p",\n' | LC_ALL=C sort -u + "unicode/appendable.h", + "unicode/brkiter.h", + "unicode/bytestream.h", + "unicode/bytestrie.h", + "unicode/bytestriebuilder.h", + "unicode/caniter.h", + "unicode/casemap.h", + "unicode/char16ptr.h", + "unicode/chariter.h", + "unicode/dbbi.h", + "unicode/docmain.h", + "unicode/dtintrv.h", + "unicode/edits.h", + "unicode/enumset.h", + "unicode/errorcode.h", + "unicode/filteredbrk.h", + "unicode/icudataver.h", + "unicode/icuplug.h", + "unicode/idna.h", + "unicode/localematcher.h", + "unicode/localpointer.h", + "unicode/locdspnm.h", + "unicode/locid.h", + "unicode/messagepattern.h", + "unicode/normalizer2.h", + "unicode/normlzr.h", + "unicode/parseerr.h", + "unicode/parsepos.h", + "unicode/platform.h", + "unicode/ptypes.h", + "unicode/putil.h", + "unicode/rbbi.h", + "unicode/rep.h", + "unicode/resbund.h", + "unicode/schriter.h", + "unicode/simpleformatter.h", + "unicode/std_string.h", + "unicode/strenum.h", + "unicode/stringpiece.h", + "unicode/stringtriebuilder.h", + "unicode/symtable.h", + "unicode/ubidi.h", + "unicode/ubiditransform.h", + "unicode/ubrk.h", + "unicode/ucasemap.h", + "unicode/ucat.h", + "unicode/uchar.h", + "unicode/ucharstrie.h", + "unicode/ucharstriebuilder.h", + "unicode/uchriter.h", + "unicode/uclean.h", + "unicode/ucnv.h", + "unicode/ucnv_cb.h", + "unicode/ucnv_err.h", + "unicode/ucnvsel.h", + "unicode/uconfig.h", + "unicode/ucurr.h", + "unicode/udata.h", + "unicode/udisplaycontext.h", + "unicode/uenum.h", + "unicode/uidna.h", + "unicode/uiter.h", + "unicode/uldnames.h", + "unicode/ulistformatter.h", + "unicode/uloc.h", + "unicode/umachine.h", + "unicode/umisc.h", + "unicode/unifilt.h", + "unicode/unifunct.h", + "unicode/unimatch.h", + "unicode/uniset.h", + "unicode/unistr.h", + "unicode/unorm.h", + "unicode/unorm2.h", + "unicode/uobject.h", + "unicode/urename.h", + "unicode/urep.h", + "unicode/ures.h", + "unicode/uscript.h", + "unicode/uset.h", + "unicode/usetiter.h", + "unicode/ushape.h", + "unicode/usprep.h", + "unicode/ustring.h", + "unicode/ustringtrie.h", + "unicode/utext.h", + "unicode/utf.h", + "unicode/utf16.h", + "unicode/utf32.h", + "unicode/utf8.h", + "unicode/utf_old.h", + "unicode/utrace.h", + "unicode/utypes.h", + "unicode/uvernum.h", + "unicode/uversion.h", + ] +} diff --git a/build/linux/unbundle/libjpeg-turbo.gn b/build/linux/unbundle/libjpeg-turbo.gn new file mode 100644 index 0000000..be0c674 --- /dev/null +++ b/build/linux/unbundle/libjpeg-turbo.gn @@ -0,0 +1,11 @@ +# Copyright 2013 The Flutter Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +config("libjpeg_config") { + libs = [ "jpeg" ] +} + +group("libjpeg") { + public_configs = [ ":libjpeg_config" ] +} diff --git a/build/linux/unbundle/libpng.gn b/build/linux/unbundle/libpng.gn new file mode 100644 index 0000000..91e0ee4 --- /dev/null +++ b/build/linux/unbundle/libpng.gn @@ -0,0 +1,23 @@ +# Copyright 2016 The Chromium Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import("//build/config/linux/pkg_config.gni") +import("//build/shim_headers.gni") + +pkg_config("libpng_config") { + packages = [ "libpng" ] +} + +shim_headers("libpng_shim") { + root_path = "." + headers = [ + "png.h", + "pngconf.h", + ] +} + +source_set("libpng") { + deps = [ ":libpng_shim" ] + public_configs = [ ":libpng_config" ] +} diff --git a/build/linux/unbundle/libwebp.gn b/build/linux/unbundle/libwebp.gn new file mode 100644 index 0000000..708cc9c --- /dev/null +++ b/build/linux/unbundle/libwebp.gn @@ -0,0 +1,35 @@ +# Copyright 2016 The Chromium Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import("//build/config/linux/pkg_config.gni") +import("//build/shim_headers.gni") + +pkg_config("system_libwebp") { + packages = [ + "libwebp", + "libwebpdemux", + "libwebpmux", + ] +} + +shim_headers("libwebp_shim") { + root_path = "src/src" + headers = [ + "webp/decode.h", + "webp/demux.h", + "webp/encode.h", + "webp/mux.h", + "webp/mux_types.h", + "webp/types.h", + ] +} + +source_set("libwebp_webp") { + deps = [ ":libwebp_shim" ] + public_configs = [ ":system_libwebp" ] +} + +group("libwebp") { + deps = [ ":libwebp_webp" ] +} diff --git a/build/linux/unbundle/libxml.gn b/build/linux/unbundle/libxml.gn new file mode 100644 index 0000000..b42d044 --- /dev/null +++ b/build/linux/unbundle/libxml.gn @@ -0,0 +1,13 @@ +# Copyright 2016 The Chromium Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import("//build/config/linux/pkg_config.gni") + +pkg_config("system_libxml") { + packages = [ "libxml-2.0" ] +} + +source_set("libxml") { + public_configs = [ ":system_libxml" ] +} diff --git a/build/linux/unbundle/replace_gn_files.py b/build/linux/unbundle/replace_gn_files.py new file mode 100755 index 0000000..b8b24c6 --- /dev/null +++ b/build/linux/unbundle/replace_gn_files.py @@ -0,0 +1,101 @@ +#!/usr/bin/env python3 +# Copyright 2016 The Chromium Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +""" +Replaces GN files in tree with files from here that +make the build use system libraries. +""" + +import argparse +import os +import shutil +import sys + + +REPLACEMENTS = { + # Use system libabsl_2xxx. These 18 shims MUST be used together. + 'absl_algorithm': 'third_party/abseil-cpp/absl/algorithm/BUILD.gn', + 'absl_base': 'third_party/abseil-cpp/absl/base/BUILD.gn', + 'absl_cleanup': 'third_party/abseil-cpp/absl/cleanup/BUILD.gn', + 'absl_container': 'third_party/abseil-cpp/absl/container/BUILD.gn', + 'absl_debugging': 'third_party/abseil-cpp/absl/debugging/BUILD.gn', + 'absl_flags': 'third_party/abseil-cpp/absl/flags/BUILD.gn', + 'absl_functional': 'third_party/abseil-cpp/absl/functional/BUILD.gn', + 'absl_hash': 'third_party/abseil-cpp/absl/hash/BUILD.gn', + 'absl_memory': 'third_party/abseil-cpp/absl/memory/BUILD.gn', + 'absl_meta': 'third_party/abseil-cpp/absl/meta/BUILD.gn', + 'absl_numeric': 'third_party/abseil-cpp/absl/numeric/BUILD.gn', + 'absl_random': 'third_party/abseil-cpp/absl/random/BUILD.gn', + 'absl_status': 'third_party/abseil-cpp/absl/status/BUILD.gn', + 'absl_strings': 'third_party/abseil-cpp/absl/strings/BUILD.gn', + 'absl_synchronization': 'third_party/abseil-cpp/absl/synchronization/BUILD.gn', + 'absl_time': 'third_party/abseil-cpp/absl/time/BUILD.gn', + 'absl_types': 'third_party/abseil-cpp/absl/types/BUILD.gn', + 'absl_utility': 'third_party/abseil-cpp/absl/utility/BUILD.gn', + # + 'fontconfig': 'third_party/fontconfig/BUILD.gn', + 'freetype2': 'third_party/freetype2/BUILD.gn', + 'harfbuzz': 'third_party/harfbuzz/BUILD.gn', + 'icu': 'third_party/icu/BUILD.gn', + 'libjpeg-turbo': 'third_party/libjpeg-turbo/BUILD.gn', + 'libpng': 'third_party/libpng/BUILD.gn', + 'libwebp': 'build/secondary/third_party/libwebp/BUILD.gn', + 'libxml': 'third_party/libxml/BUILD.gn', + 'libXNVCtrl': 'third_party/angle/src/third_party/libXNVCtrl/BUILD.gn', + 'sqlite': 'third_party/sqlite/BUILD.gn', + # Use system libSPIRV-Tools in Swiftshader. These two shims MUST be used together. + 'swiftshader-SPIRV-Headers': 'third_party/swiftshader/third_party/SPIRV-Headers/BUILD.gn', + 'swiftshader-SPIRV-Tools': 'third_party/swiftshader/third_party/SPIRV-Tools/BUILD.gn', + # Use system libSPIRV-Tools inside ANGLE. These two shims MUST be used together + # and can only be used if WebGPU is not compiled (use_dawn=false) + 'vulkan-SPIRV-Headers': 'third_party/vulkan-deps/spirv-headers/src/BUILD.gn', + 'vulkan-SPIRV-Tools': 'third_party/vulkan-deps/spirv-tools/src/BUILD.gn', + # + 'zlib': 'third_party/zlib/BUILD.gn', +} + + +def DoMain(argv): + my_dirname = os.path.dirname(__file__) + source_tree_root = os.path.abspath( + os.path.join(my_dirname, '..', '..', '..')) + + parser = argparse.ArgumentParser() + parser.add_argument('--system-libraries', nargs='*', default=[]) + parser.add_argument('--undo', action='store_true') + + args = parser.parse_args(argv) + + handled_libraries = set() + for lib, path in REPLACEMENTS.items(): + if lib not in args.system_libraries: + continue + handled_libraries.add(lib) + + if args.undo: + # Restore original file, and also remove the backup. + # This is meant to restore the source tree to its original state. + os.rename(os.path.join(source_tree_root, path + '.orig'), + os.path.join(source_tree_root, path)) + else: + # Create a backup copy for --undo. + shutil.copyfile(os.path.join(source_tree_root, path), + os.path.join(source_tree_root, path + '.orig')) + + # Copy the GN file from directory of this script to target path. + shutil.copyfile(os.path.join(my_dirname, '%s.gn' % lib), + os.path.join(source_tree_root, path)) + + unhandled_libraries = set(args.system_libraries) - handled_libraries + if unhandled_libraries: + print('Unrecognized system libraries requested: %s' % ', '.join( + sorted(unhandled_libraries)), file=sys.stderr) + return 1 + + return 0 + + +if __name__ == '__main__': + sys.exit(DoMain(sys.argv[1:])) diff --git a/build/linux/unbundle/sqlite.gn b/build/linux/unbundle/sqlite.gn new file mode 100644 index 0000000..e6c653d --- /dev/null +++ b/build/linux/unbundle/sqlite.gn @@ -0,0 +1,20 @@ +# Copyright 2013 The Flutter Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import("//build/config/linux/pkg_config.gni") +import("//build/shim_headers.gni") + +pkg_config("system_sqlite") { + packages = [ "sqlite3" ] +} + +shim_headers("sqlite_shim") { + root_path = "." + headers = [ "sqlite3.h" ] +} + +source_set("sqlite") { + public_deps = [ ":sqlite_shim" ] + public_configs = [ ":system_sqlite" ] +} diff --git a/build/linux/unbundle/zlib.gn b/build/linux/unbundle/zlib.gn new file mode 100644 index 0000000..6daf3c6 --- /dev/null +++ b/build/linux/unbundle/zlib.gn @@ -0,0 +1,72 @@ +# Copyright 2016 The Chromium Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import("//build/shim_headers.gni") + +declare_args() { + use_zlib_ng = false +} + +if (use_zlib_ng) { + _suffix = "-ng" +} else { + _suffix = "" +} + +shim_headers("zlib_shim") { + root_path = "." + headers = [ "zlib.h%zlib$_suffix.h" ] + additional_includes = [ "third_party" ] +} + +config("system_zlib") { + defines = [ "USE_SYSTEM_ZLIB=1" ] +} + +config("zlib_config") { + configs = [ ":system_zlib" ] +} + +source_set("zlib") { + public_deps = [ ":zlib_shim" ] + libs = [ "z$_suffix" ] + public_configs = [ ":system_zlib" ] +} + +shim_headers("minizip_shim") { + root_path = "contrib" + headers = [ + "minizip/crypt.h", + "minizip/ioapi.h", + "minizip/iowin32.h", + "minizip/mztools.h", + "minizip/unzip.h", + "minizip/zip.h", + ] +} + +source_set("minizip") { + deps = [ ":minizip_shim" ] + libs = [ "minizip" ] +} + +static_library("zip") { + sources = [ + "google/zip.cc", + "google/zip.h", + "google/zip_internal.cc", + "google/zip_internal.h", + "google/zip_reader.cc", + "google/zip_reader.h", + ] + deps = [ ":minizip" ] +} + +static_library("compression_utils") { + sources = [ + "google/compression_utils.cc", + "google/compression_utils.h", + ] + deps = [ ":zlib" ] +} diff --git a/build/shim_headers.gni b/build/shim_headers.gni new file mode 100644 index 0000000..1d24e0a --- /dev/null +++ b/build/shim_headers.gni @@ -0,0 +1,42 @@ +# Copyright 2016 The Chromium Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. +template("shim_headers") { + action_name = "gen_${target_name}" + config_name = "${target_name}_config" + shim_headers_path = "${root_gen_dir}/shim_headers/${target_name}" + config(config_name) { + include_dirs = [ shim_headers_path ] + if (defined(invoker.additional_includes)) { + foreach(i, invoker.additional_includes) { + include_dirs += [ shim_headers_path + "/" + i ] + } + } + } + action(action_name) { + script = "//tools/generate_shim_headers.py" + args = [ + "--generate", + "--headers-root", + rebase_path(invoker.root_path), + "--output-directory", + rebase_path(shim_headers_path), + ] + if (defined(invoker.prefix)) { + args += [ + "--prefix", + invoker.prefix, + ] + } + args += invoker.headers + outputs = [] + foreach(h, invoker.headers) { + outputs += [ shim_headers_path + "/" + + rebase_path(invoker.root_path, "//") + "/" + h ] + } + } + group(target_name) { + public_deps = [ ":${action_name}" ] + all_dependent_configs = [ ":${config_name}" ] + } +} diff --git a/tools/generate_shim_headers.py b/tools/generate_shim_headers.py new file mode 100644 index 0000000..aaa16f8 --- /dev/null +++ b/tools/generate_shim_headers.py @@ -0,0 +1,116 @@ +#!/usr/bin/env python +# Copyright 2012 The Chromium Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +""" +Generates shim headers that mirror the directory structure of bundled headers, +but just forward to the system ones. + +This allows seamless compilation against system headers with no changes +to our source code. +""" + + +import optparse +import os.path +import sys + + +SHIM_TEMPLATE = """ +#if defined(OFFICIAL_BUILD) +#error shim headers must not be used in official builds! +#endif +""" + + +def GeneratorMain(argv): + parser = optparse.OptionParser() + parser.add_option('--headers-root', action='append') + parser.add_option('--define', action='append') + parser.add_option('--output-directory') + parser.add_option('--prefix', default='') + parser.add_option('--use-include-next', action='store_true') + parser.add_option('--outputs', action='store_true') + parser.add_option('--generate', action='store_true') + + options, args = parser.parse_args(argv) + + if not options.headers_root: + parser.error('Missing --headers-root parameter.') + if not options.output_directory: + parser.error('Missing --output-directory parameter.') + if not args: + parser.error('Missing arguments - header file names.') + + source_tree_root = os.path.abspath( + os.path.join(os.path.dirname(__file__), '..')) + + for root in options.headers_root: + target_directory = os.path.join( + options.output_directory, + os.path.relpath(root, source_tree_root)) + if options.generate and not os.path.exists(target_directory): + os.makedirs(target_directory) + + for header_spec in args: + if ';' in header_spec: + (header_filename, + include_before, + include_after) = header_spec.split(';', 2) + else: + header_filename = header_spec + include_before = '' + include_after = '' + if '%' in header_filename: + (header_filename, + upstream_header_filename) = header_filename.split('%', 1) + else: + upstream_header_filename = header_filename + if options.outputs: + yield os.path.join(target_directory, header_filename) + if options.generate: + header_path = os.path.join(target_directory, header_filename) + header_dir = os.path.dirname(header_path) + if not os.path.exists(header_dir): + os.makedirs(header_dir) + with open(header_path, 'w') as f: + f.write(SHIM_TEMPLATE) + + if options.define: + for define in options.define: + key, value = define.split('=', 1) + # This non-standard push_macro extension is supported + # by compilers we support (GCC, clang). + f.write('#pragma push_macro("%s")\n' % key) + f.write('#undef %s\n' % key) + f.write('#define %s %s\n' % (key, value)) + + if include_before: + for header in include_before.split(':'): + f.write('#include %s\n' % header) + + include_target = options.prefix + upstream_header_filename + if options.use_include_next: + f.write('#include_next <%s>\n' % include_target) + else: + f.write('#include <%s>\n' % include_target) + + if include_after: + for header in include_after.split(':'): + f.write('#include %s\n' % header) + + if options.define: + for define in options.define: + key, value = define.split('=', 1) + # This non-standard pop_macro extension is supported + # by compilers we support (GCC, clang). + f.write('#pragma pop_macro("%s")\n' % key) + + +def DoMain(argv): + return '\n'.join(GeneratorMain(argv)) + + +if __name__ == '__main__': + DoMain(sys.argv[1:]) --- /dev/null +++ ./build/linux/unbundle/vulkan-SPIRV-Headers.gn @@ -0,0 +1,19 @@ +# This shim can only be used if you build Chromium without DAWN + +import("//build/shim_headers.gni") + +shim_headers("vulkan-SPIRV-Headers_shim") { + root_path = "include" + headers = [ + "spirv/unified1/GLSL.std.450.h", + "spirv/unified1/NonSemanticClspvReflection.h", + "spirv/unified1/NonSemanticDebugPrintf.h", + "spirv/unified1/OpenCL.std.h", + "spirv/unified1/spirv.h", + "spirv/unified1/spirv.hpp", + ] +} + +source_set("spv_headers") { + deps = [ ":vulkan-SPIRV-Headers_shim" ] +} --- /dev/null +++ ./build/linux/unbundle/vulkan-SPIRV-Tools.gn @@ -0,0 +1,73 @@ +# This shim can only be used if you build Chromium without DAWN + +import("//build/config/linux/pkg_config.gni") +import("//build/shim_headers.gni") + +pkg_config("spvtools_internal_config") { + packages = [ "SPIRV-Tools" ] +} + +shim_headers("vulkan-SPIRV-Tools_shim") { + root_path = "include" + headers = [ + "spirv-tools/instrument.hpp", + "spirv-tools/libspirv.h", + "spirv-tools/libspirv.hpp", + "spirv-tools/linker.hpp", + "spirv-tools/optimizer.hpp", + ] +} + +source_set("SPIRV-Tools") { + deps = [ ":vulkan-SPIRV-Tools_shim" ] + public_configs = [ ":spvtools_internal_config" ] +} + +source_set("spvtools") { + deps = [ ":vulkan-SPIRV-Tools_shim" ] + public_configs = [ ":spvtools_internal_config" ] +} + +source_set("spvtools_core_enums_unified1") { + deps = [ ":vulkan-SPIRV-Tools_shim" ] + public_configs = [ ":spvtools_internal_config" ] +} + +source_set("spvtools_core_tables_unified1") { + deps = [ ":vulkan-SPIRV-Tools_shim" ] + public_configs = [ ":spvtools_internal_config" ] +} + +source_set("spvtools_headers") { + deps = [ ":vulkan-SPIRV-Tools_shim" ] + public_configs = [ ":spvtools_internal_config" ] +} + +source_set("spvtools_language_header_cldebuginfo100") { + deps = [ ":vulkan-SPIRV-Tools_shim" ] + public_configs = [ ":spvtools_internal_config" ] +} + +source_set("spvtools_language_header_debuginfo") { + deps = [ ":vulkan-SPIRV-Tools_shim" ] + public_configs = [ ":spvtools_internal_config" ] +} + +source_set("spvtools_language_header_vkdebuginfo100") { + deps = [ ":vulkan-SPIRV-Tools_shim" ] + public_configs = [ ":spvtools_internal_config" ] +} + +source_set("spvtools_opt") { + deps = [ ":vulkan-SPIRV-Tools_shim" ] + public_configs = [ ":spvtools_internal_config" ] +} + +config("spvtools_public_config") { + configs = [ ":spvtools_internal_config" ] +} + +source_set("spvtools_val") { + deps = [ ":vulkan-SPIRV-Tools_shim" ] + public_configs = [ ":spvtools_internal_config" ] +}