| # Copyright 2014 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/buildflags_paint_preview.gni") |
| import("//build/config/chrome_build.gni") |
| import("//build/config/features.gni") |
| import("//build/config/freetype/freetype.gni") |
| import("//build/config/ui.gni") |
| import("//testing/libfuzzer/fuzzer_test.gni") |
| import("//third_party/harfbuzz-ng/harfbuzz.gni") |
| |
| if (use_system_harfbuzz) { |
| import("//build/config/linux/pkg_config.gni") |
| pkg_config("harfbuzz_from_pkgconfig") { |
| visibility = [ |
| "//third_party:freetype_harfbuzz", |
| "//third_party/freetype:freetype_source", |
| ] |
| packages = [ |
| "harfbuzz", |
| "harfbuzz-subset", |
| ] |
| } |
| } else { |
| config("harfbuzz_config") { |
| include_dirs = [ "src/src" ] |
| } |
| |
| config("harfbuzz_warnings") { |
| if (is_win) { |
| # Result of 32-bit shift implicitly converted to 64 bits. |
| cflags = [ "/wd4334" ] |
| } |
| } |
| |
| source_set("harfbuzz_source") { |
| visibility = [ "//third_party:freetype_harfbuzz" ] |
| |
| public = [ |
| "src/src/hb-blob.h", |
| "src/src/hb-buffer.h", |
| "src/src/hb-common.h", |
| "src/src/hb-cplusplus.hh", |
| "src/src/hb-deprecated.h", |
| "src/src/hb-face.h", |
| "src/src/hb-font.h", |
| "src/src/hb-ft.h", |
| "src/src/hb-icu.h", |
| "src/src/hb-map.h", |
| "src/src/hb-ot-font.h", |
| "src/src/hb-ot-layout.h", |
| "src/src/hb-ot-math.h", |
| "src/src/hb-ot-shape.h", |
| "src/src/hb-ot-var.h", |
| "src/src/hb-ot.h", |
| "src/src/hb-set.h", |
| "src/src/hb-shape-plan.h", |
| "src/src/hb-shape.h", |
| "src/src/hb-subset.h", |
| "src/src/hb-unicode.h", |
| "src/src/hb-version.h", |
| "src/src/hb.h", |
| ] |
| |
| sources = [ |
| "src/src/OT/Color/CBDT/CBDT.hh", |
| "src/src/OT/Color/COLR/COLR.hh", |
| "src/src/OT/Color/CPAL/CPAL.hh", |
| "src/src/OT/Color/sbix/sbix.hh", |
| "src/src/OT/Color/svg/svg.hh", |
| "src/src/OT/Layout/GDEF/GDEF.hh", |
| "src/src/OT/glyf/VarCompositeGlyph.hh", |
| "src/src/OT/glyf/composite-iter.hh", |
| "src/src/OT/glyf/coord-setter.hh", |
| "src/src/OT/name/name.hh", |
| "src/src/graph/classdef-graph.hh", |
| "src/src/graph/coverage-graph.hh", |
| "src/src/graph/gsubgpos-context.cc", |
| "src/src/graph/gsubgpos-context.hh", |
| "src/src/graph/gsubgpos-graph.hh", |
| "src/src/graph/markbasepos-graph.hh", |
| "src/src/graph/pairpos-graph.hh", |
| "src/src/graph/split-helpers.hh", |
| "src/src/hb-aat-layout-ankr-table.hh", |
| "src/src/hb-aat-layout-bsln-table.hh", |
| "src/src/hb-aat-layout-common.hh", |
| "src/src/hb-aat-layout-feat-table.hh", |
| "src/src/hb-aat-layout-just-table.hh", |
| "src/src/hb-aat-layout-kerx-table.hh", |
| "src/src/hb-aat-layout-morx-table.hh", |
| "src/src/hb-aat-layout-opbd-table.hh", |
| "src/src/hb-aat-layout-trak-table.hh", |
| "src/src/hb-aat-layout.cc", |
| "src/src/hb-aat-layout.h", |
| "src/src/hb-aat-layout.hh", |
| "src/src/hb-aat-ltag-table.hh", |
| "src/src/hb-aat-map.cc", |
| "src/src/hb-aat-map.hh", |
| "src/src/hb-aat.h", |
| "src/src/hb-algs.hh", |
| "src/src/hb-array.hh", |
| "src/src/hb-atomic.hh", |
| "src/src/hb-bimap.hh", |
| "src/src/hb-bit-page.hh", |
| "src/src/hb-bit-set-invertible.hh", |
| "src/src/hb-bit-set.hh", |
| "src/src/hb-blob.cc", |
| "src/src/hb-blob.hh", |
| "src/src/hb-buffer-deserialize-json.hh", |
| "src/src/hb-buffer-deserialize-text-glyphs.hh", |
| "src/src/hb-buffer-deserialize-text-unicode.hh", |
| "src/src/hb-buffer-serialize.cc", |
| "src/src/hb-buffer-verify.cc", |
| "src/src/hb-buffer.cc", |
| "src/src/hb-buffer.hh", |
| "src/src/hb-cache.hh", |
| "src/src/hb-cff-interp-common.hh", |
| "src/src/hb-cff-interp-cs-common.hh", |
| "src/src/hb-cff-interp-dict-common.hh", |
| "src/src/hb-cff1-interp-cs.hh", |
| "src/src/hb-cff2-interp-cs.hh", |
| "src/src/hb-common.cc", |
| "src/src/hb-config.hh", |
| "src/src/hb-cplusplus.hh", |
| "src/src/hb-debug.hh", |
| "src/src/hb-dispatch.hh", |
| "src/src/hb-draw.cc", |
| "src/src/hb-draw.h", |
| "src/src/hb-draw.hh", |
| "src/src/hb-face-builder.cc", |
| "src/src/hb-face.cc", |
| "src/src/hb-face.hh", |
| "src/src/hb-font.cc", |
| "src/src/hb-font.hh", |
| "src/src/hb-ft.cc", |
| "src/src/hb-icu.cc", |
| "src/src/hb-iter.hh", |
| "src/src/hb-kern.hh", |
| "src/src/hb-limits.hh", |
| "src/src/hb-machinery.hh", |
| "src/src/hb-map.cc", |
| "src/src/hb-map.hh", |
| "src/src/hb-meta.hh", |
| "src/src/hb-ms-feature-ranges.hh", |
| "src/src/hb-multimap.hh", |
| "src/src/hb-mutex.hh", |
| "src/src/hb-null.hh", |
| "src/src/hb-number-parser.hh", |
| "src/src/hb-number.cc", |
| "src/src/hb-number.hh", |
| "src/src/hb-object.hh", |
| "src/src/hb-open-file.hh", |
| "src/src/hb-open-type.hh", |
| "src/src/hb-ot-cff-common.hh", |
| "src/src/hb-ot-cff1-std-str.hh", |
| "src/src/hb-ot-cff1-table.cc", |
| "src/src/hb-ot-cff1-table.hh", |
| "src/src/hb-ot-cff2-table.cc", |
| "src/src/hb-ot-cff2-table.hh", |
| "src/src/hb-ot-cmap-table.hh", |
| "src/src/hb-ot-color.cc", |
| "src/src/hb-ot-color.h", |
| "src/src/hb-ot-deprecated.h", |
| "src/src/hb-ot-face-table-list.hh", |
| "src/src/hb-ot-face.cc", |
| "src/src/hb-ot-face.hh", |
| "src/src/hb-ot-font.cc", |
| "src/src/hb-ot-gasp-table.hh", |
| "src/src/hb-ot-glyf-table.hh", |
| "src/src/hb-ot-hdmx-table.hh", |
| "src/src/hb-ot-head-table.hh", |
| "src/src/hb-ot-hhea-table.hh", |
| "src/src/hb-ot-hmtx-table.hh", |
| "src/src/hb-ot-kern-table.hh", |
| "src/src/hb-ot-layout-base-table.hh", |
| "src/src/hb-ot-layout-common.hh", |
| "src/src/hb-ot-layout-gdef-table.hh", |
| "src/src/hb-ot-layout-gpos-table.hh", |
| "src/src/hb-ot-layout-gsub-table.hh", |
| "src/src/hb-ot-layout-gsubgpos.hh", |
| "src/src/hb-ot-layout-jstf-table.hh", |
| "src/src/hb-ot-layout.cc", |
| "src/src/hb-ot-layout.hh", |
| "src/src/hb-ot-map.cc", |
| "src/src/hb-ot-map.hh", |
| "src/src/hb-ot-math-table.hh", |
| "src/src/hb-ot-math.cc", |
| "src/src/hb-ot-maxp-table.hh", |
| "src/src/hb-ot-meta-table.hh", |
| "src/src/hb-ot-meta.cc", |
| "src/src/hb-ot-meta.h", |
| "src/src/hb-ot-metrics.cc", |
| "src/src/hb-ot-metrics.h", |
| "src/src/hb-ot-metrics.hh", |
| "src/src/hb-ot-name-language-static.hh", |
| "src/src/hb-ot-name-language.hh", |
| "src/src/hb-ot-name-table.hh", |
| "src/src/hb-ot-name.cc", |
| "src/src/hb-ot-name.h", |
| "src/src/hb-ot-os2-table.hh", |
| "src/src/hb-ot-os2-unicode-ranges.hh", |
| "src/src/hb-ot-post-macroman.hh", |
| "src/src/hb-ot-post-table-v2subset.hh", |
| "src/src/hb-ot-post-table.hh", |
| "src/src/hb-ot-shape-fallback.cc", |
| "src/src/hb-ot-shape-fallback.hh", |
| "src/src/hb-ot-shape-normalize.cc", |
| "src/src/hb-ot-shape-normalize.hh", |
| "src/src/hb-ot-shape.cc", |
| "src/src/hb-ot-shape.hh", |
| "src/src/hb-ot-shaper-arabic-fallback.hh", |
| "src/src/hb-ot-shaper-arabic-joining-list.hh", |
| "src/src/hb-ot-shaper-arabic-pua.hh", |
| "src/src/hb-ot-shaper-arabic-table.hh", |
| "src/src/hb-ot-shaper-arabic-win1256.hh", |
| "src/src/hb-ot-shaper-arabic.cc", |
| "src/src/hb-ot-shaper-arabic.hh", |
| "src/src/hb-ot-shaper-default.cc", |
| "src/src/hb-ot-shaper-hangul.cc", |
| "src/src/hb-ot-shaper-hebrew.cc", |
| "src/src/hb-ot-shaper-indic-machine.hh", |
| "src/src/hb-ot-shaper-indic-table.cc", |
| "src/src/hb-ot-shaper-indic.cc", |
| "src/src/hb-ot-shaper-indic.hh", |
| "src/src/hb-ot-shaper-khmer-machine.hh", |
| "src/src/hb-ot-shaper-khmer.cc", |
| "src/src/hb-ot-shaper-myanmar-machine.hh", |
| "src/src/hb-ot-shaper-myanmar.cc", |
| "src/src/hb-ot-shaper-syllabic.cc", |
| "src/src/hb-ot-shaper-syllabic.hh", |
| "src/src/hb-ot-shaper-thai.cc", |
| "src/src/hb-ot-shaper-use-machine.hh", |
| "src/src/hb-ot-shaper-use-table.hh", |
| "src/src/hb-ot-shaper-use.cc", |
| "src/src/hb-ot-shaper-vowel-constraints.cc", |
| "src/src/hb-ot-shaper-vowel-constraints.hh", |
| "src/src/hb-ot-shaper.hh", |
| "src/src/hb-ot-stat-table.hh", |
| "src/src/hb-ot-tag-table.hh", |
| "src/src/hb-ot-tag.cc", |
| "src/src/hb-ot-var-avar-table.hh", |
| "src/src/hb-ot-var-common.hh", |
| "src/src/hb-ot-var-cvar-table.hh", |
| "src/src/hb-ot-var-fvar-table.hh", |
| "src/src/hb-ot-var-gvar-table.hh", |
| "src/src/hb-ot-var-hvar-table.hh", |
| "src/src/hb-ot-var-mvar-table.hh", |
| "src/src/hb-ot-var.cc", |
| "src/src/hb-ot-vorg-table.hh", |
| "src/src/hb-paint-extents.cc", |
| "src/src/hb-paint-extents.hh", |
| "src/src/hb-pool.hh", |
| "src/src/hb-priority-queue.hh", |
| "src/src/hb-repacker.hh", |
| "src/src/hb-sanitize.hh", |
| "src/src/hb-serialize.hh", |
| "src/src/hb-set-digest.hh", |
| "src/src/hb-set.cc", |
| "src/src/hb-set.hh", |
| "src/src/hb-shape-plan.cc", |
| "src/src/hb-shape-plan.hh", |
| "src/src/hb-shape.cc", |
| "src/src/hb-shaper-impl.hh", |
| "src/src/hb-shaper-list.hh", |
| "src/src/hb-shaper.cc", |
| "src/src/hb-shaper.hh", |
| "src/src/hb-static.cc", |
| "src/src/hb-string-array.hh", |
| "src/src/hb-subset-accelerator.hh", |
| "src/src/hb-subset-cff-common.cc", |
| "src/src/hb-subset-cff-common.hh", |
| "src/src/hb-subset-cff1.cc", |
| "src/src/hb-subset-cff1.hh", |
| "src/src/hb-subset-cff2.cc", |
| "src/src/hb-subset-cff2.hh", |
| "src/src/hb-subset-input.cc", |
| "src/src/hb-subset-input.hh", |
| "src/src/hb-subset-plan.cc", |
| "src/src/hb-subset-plan.hh", |
| "src/src/hb-subset-repacker.cc", |
| "src/src/hb-subset-repacker.h", |
| "src/src/hb-subset.cc", |
| "src/src/hb-subset.hh", |
| "src/src/hb-ucd-table.hh", |
| "src/src/hb-ucd.cc", |
| "src/src/hb-unicode-emoji-table.hh", |
| "src/src/hb-unicode.cc", |
| "src/src/hb-unicode.hh", |
| "src/src/hb-utf.hh", |
| "src/src/hb-vector.hh", |
| "src/src/hb.hh", |
| ] |
| |
| # The following sources are explictly not used. |
| # They are referenced to aid in detecting previously uncategorized files. |
| unused_sources = [ |
| "src/src/hb-coretext.cc", |
| "src/src/hb-coretext.h", |
| "src/src/hb-directwrite.cc", |
| "src/src/hb-directwrite.h", |
| "src/src/hb-fallback-shape.cc", |
| "src/src/hb-gdi.cc", |
| "src/src/hb-gdi.h", |
| "src/src/hb-gobject-structs.cc", |
| "src/src/hb-gobject-structs.h", |
| "src/src/hb-gobject.h", |
| "src/src/hb-graphite2.cc", |
| "src/src/hb-graphite2.h", |
| "src/src/hb-style.cc", |
| "src/src/hb-style.h", |
| "src/src/hb-uniscribe.cc", |
| "src/src/hb-uniscribe.h", |
| ] |
| assert(unused_sources != []) |
| |
| defines = [ |
| "HAVE_OT", |
| "HAVE_FREETYPE", |
| "HAVE_ICU", |
| "HAVE_ICU_BUILTIN", |
| "HB_NO_MMAP", |
| "HB_NO_PAINT", |
| "HB_NO_RESOURCE_FORK", |
| |
| # Size reductions by disabling parts that we do not currently require: |
| |
| # SkPDF needs subsetting but does not require subsetting of layout or CFF tables. |
| "HB_NO_SUBSET_LAYOUT", |
| "HB_NO_SUBSET_CFF", |
| |
| # Fallback shaper not required, we only use the HarfBuzz internal OT shaper. |
| "HB_NO_FALLBACK_SHAPE", |
| |
| # Tells HarfBuzz to use ICU instead of the own mini UCDN implementation |
| # that is part of HarfBuzz. |
| "HB_NO_UCD", |
| |
| # Disable .fon file support, not needed for Chrome, and code behind this |
| # flag produces warnings in Clang. Compare https://crbug.com/1002945. |
| "HB_NO_WIN1256", |
| |
| # TODO(https://crbug.com/949962): Remove once this is fixed upstream. |
| "U_DISABLE_VERSION_SUFFIX=0", |
| |
| # Buffer verification not used in production build. |
| "HB_NO_BUFFER_VERIFY", |
| |
| # We're not using HarfBuzz' drawing functions or debug tools in this build. |
| "HB_NO_DRAW", |
| |
| # Don't ship experimental extensions. |
| "HB_NO_BORING_EXPANSION", |
| |
| # Letting HarfBuzz enable warnings through pragmas can block compiler |
| # upgrades in situations where say a ToT compiler build adds a new |
| # stricter warning under -Wfoowarning-subgroup. HarfBuzz pragma-enables |
| # -Wfoowarning which default-enables -Wfoowarning-subgroup implicitly but |
| # HarfBuzz upstream is not yet clean of warnings produced for |
| # -Wfoowarning-subgroup. Hence disabling pragma warning control here. |
| # See also https:/crbug.com/1203071 |
| "HB_NO_PRAGMA_GCC_DIAGNOSTIC_ERROR", |
| "HB_NO_PRAGMA_GCC_DIAGNOSTIC_WARNING", |
| ] |
| |
| if (!is_win && !is_mac) { |
| # Needed for HarfBuzz mutex implementation, see hb-mutex.hh |
| defines += [ "HAVE_PTHREAD" ] |
| } |
| |
| if (enable_paint_preview) { |
| # Paint Previews make use of CFF subsetting. However, enabling this is |
| # expensive for binary size so only compile it when Paint Previews are |
| # compiled. |
| defines -= [ "HB_NO_SUBSET_CFF" ] |
| } |
| |
| if (is_component_build) { |
| if (is_win) { |
| defines += [ "HB_EXTERN=__declspec (dllexport)" ] |
| } else { |
| defines += [ "HB_EXTERN=__attribute__((visibility(\"default\")))" ] |
| # Exposing symbols in component builds can cause a mixture of system |
| # harfbuzz symbols and //third_party harfbuzz symbols to be loaded at |
| # the same time. This can cause issues for libraries that indirectly |
| # load harfbuzz like pango (see https://crbug.com/1146397), so we need |
| # to include metrics symbols (i.e. have HB_NO_METRICS undefined) to |
| # prevent pango from using the system library. Currently, HB_NO_METRICS |
| # is always disabled, due to |
| # https://github.com/harfbuzz/harfbuzz/issues/3482 - if that changes |
| # "HB_NO_METRICS" needs to be removed from the defines list here. |
| # TODO(https://crbug.com/1148459): Remove this workaround once bug |
| # 1148459 is fixed. |
| } |
| } |
| |
| if (use_system_freetype) { |
| configs += [ "//build/linux:freetype_from_pkgconfig" ] |
| } else { |
| configs += [ "//third_party/freetype:freetype_component_config" ] |
| } |
| configs -= [ "//build/config/compiler:chromium_code" ] |
| configs += [ |
| "//build/config/compiler:no_chromium_code", |
| |
| # Must be after no_chromium_code for warning flags to be ordered |
| # correctly. |
| ":harfbuzz_warnings", |
| ] |
| |
| # This allows the compiler to do further optimizations in the code. |
| if (!is_debug) { |
| configs -= [ "//build/config/compiler:default_optimization" ] |
| configs += [ "//build/config/compiler:optimize_speed" ] |
| } |
| |
| public_configs = [ ":harfbuzz_config" ] |
| |
| deps = [ "//third_party/icu:icuuc" ] |
| |
| if (use_glib) { |
| configs += [ "//build/config/linux:glib" ] |
| public += [ "src/src/hb-glib.h" ] |
| sources += [ "src/src/hb-glib.cc" ] |
| } |
| } |
| } |
| |
| # Not all checkouts have a //base directory. |
| if (build_with_chromium) { |
| fuzzer_test("hb_shape_fuzzer") { |
| sources = [ "fuzz/hb_shape_fuzzer.cc" ] |
| deps = [ |
| "//base", |
| "//third_party:freetype_harfbuzz", |
| ] |
| seed_corpus = "fuzz/seed_corpus" |
| } |
| |
| fuzzer_test("hb_subset_fuzzer") { |
| sources = [ "fuzz/hb_subset_fuzzer.cc" ] |
| deps = [ |
| "//base", |
| "//third_party:freetype_harfbuzz", |
| ] |
| seed_corpus = "fuzz/seed_corpus" |
| } |
| } |