summaryrefslogtreecommitdiffstats
path: root/third_party/harfbuzz-ng/BUILD.gn
blob: 24aa16fb8e56dfccf8abc58079e00d79d072ba98 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
# Copyright 2014 The Chromium 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/chrome_build.gni")
import("//build/config/linux/pkg_config.gni")
import("//build/config/ui.gni")

# The GYP build supports system harfbuzz for non-official builds when using
# pangoft2 1.31.0 or greater (which pulls it in).
# TODO(brettw) we can consider doing this as well, although the benefit is
# unclear and requires shelling out to a script to check the version.
#
# ChromeOS uses an up-to-date system one that we have control over, so we
# don't want to bloat the binary more by including another copy.

declare_args() {
  # Since version 1.31.0, pangoft2 which we depend on pulls in harfbuzz
  # anyways. However, we want to have control of the version of harfbuzz
  # we use, so don't use system harfbuzz unless we are building for
  # chrome os, where we have the system harfbuzz under control.
  use_system_harfbuzz =
      is_linux && is_chromeos && exec_script(pkg_config_script,
                                             pkg_config_args + [
                                                   "--atleast-version=1.31.0",
                                                   "pangoft2",
                                                 ],
                                             "value")
}

if (use_system_harfbuzz) {
  import("//build/config/linux/pkg_config.gni")
  pkg_config("harfbuzz_pkgconfig") {
    packages = [ "harfbuzz" ]
  }
  group("harfbuzz-ng") {
    public_configs = [ ":harfbuzz_pkgconfig" ]
  }
} else {
  config("harfbuzz-ng_config") {
    include_dirs = [ "src" ]
  }

  config("harfbuzz_warnings") {
    cflags = []
    if (is_clang) {
      cflags += [
        "-Wno-unused-value",

        # Harfbuzz uses unused typedefs for its static asserts (and its
        # static asserts are strange enough that they can't be replaced
        # by static_assert).
        "-Wno-unused-local-typedef",
      ]
    }
    if (is_win) {
      # Result of 32-bit shift implicitly converted to 64 bits.
      cflags += [ "/wd4334" ]
    }
  }

  # See also chrome/browser/ui/libgtk2ui/BUILD.gn which pulls this.
  config("pangoft2_link_hack") {
    if (is_linux && use_pango && !is_chromeos && !is_official_build &&
        current_cpu != "arm" && current_cpu != "mipsel" &&
        !is_component_build) {
      # These symbols are referenced from libpangoft2, which will be
      # dynamically linked later.
      ldflags =
          [ "-Wl,-uhb_ft_face_create_cached,-uhb_glib_get_unicode_funcs" ]
    }
  }

  static_library("harfbuzz-ng") {
    sources = [
      "src/hb-atomic-private.hh",
      "src/hb-blob.cc",
      "src/hb-blob.h",
      "src/hb-buffer-deserialize-json.hh",
      "src/hb-buffer-deserialize-text.hh",
      "src/hb-buffer-private.hh",
      "src/hb-buffer-serialize.cc",
      "src/hb-buffer.cc",
      "src/hb-buffer.h",
      "src/hb-cache-private.hh",
      "src/hb-common.cc",
      "src/hb-common.h",
      "src/hb-deprecated.h",
      "src/hb-face-private.hh",
      "src/hb-face.cc",
      "src/hb-face.h",
      "src/hb-fallback-shape.cc",
      "src/hb-font-private.hh",
      "src/hb-font.cc",
      "src/hb-font.h",
      "src/hb-icu.cc",
      "src/hb-icu.h",
      "src/hb-mutex-private.hh",
      "src/hb-object-private.hh",
      "src/hb-open-file-private.hh",
      "src/hb-open-type-private.hh",
      "src/hb-ot-font.cc",
      "src/hb-ot-font.h",
      "src/hb-ot-head-table.hh",
      "src/hb-ot-hhea-table.hh",
      "src/hb-ot-hmtx-table.hh",
      "src/hb-ot-layout-common-private.hh",
      "src/hb-ot-layout-gdef-table.hh",
      "src/hb-ot-layout-gpos-table.hh",
      "src/hb-ot-layout-gsub-table.hh",
      "src/hb-ot-layout-gsubgpos-private.hh",
      "src/hb-ot-layout-private.hh",
      "src/hb-ot-layout.cc",
      "src/hb-ot-layout.h",
      "src/hb-ot-map-private.hh",
      "src/hb-ot-map.cc",
      "src/hb-ot-maxp-table.hh",
      "src/hb-ot-name-table.hh",
      "src/hb-ot-shape-complex-arabic-fallback.hh",
      "src/hb-ot-shape-complex-arabic-private.hh",
      "src/hb-ot-shape-complex-arabic-table.hh",
      "src/hb-ot-shape-complex-arabic.cc",
      "src/hb-ot-shape-complex-default.cc",
      "src/hb-ot-shape-complex-hangul.cc",
      "src/hb-ot-shape-complex-hebrew.cc",
      "src/hb-ot-shape-complex-indic-machine.hh",
      "src/hb-ot-shape-complex-indic-private.hh",
      "src/hb-ot-shape-complex-indic-table.cc",
      "src/hb-ot-shape-complex-indic.cc",
      "src/hb-ot-shape-complex-myanmar-machine.hh",
      "src/hb-ot-shape-complex-myanmar.cc",
      "src/hb-ot-shape-complex-private.hh",
      "src/hb-ot-shape-complex-thai.cc",
      "src/hb-ot-shape-complex-tibetan.cc",
      "src/hb-ot-shape-complex-use-machine.hh",
      "src/hb-ot-shape-complex-use-private.hh",
      "src/hb-ot-shape-complex-use-table.cc",
      "src/hb-ot-shape-complex-use.cc",
      "src/hb-ot-shape-fallback-private.hh",
      "src/hb-ot-shape-fallback.cc",
      "src/hb-ot-shape-normalize-private.hh",
      "src/hb-ot-shape-normalize.cc",
      "src/hb-ot-shape-private.hh",
      "src/hb-ot-shape.cc",
      "src/hb-ot-shape.h",
      "src/hb-ot-tag.cc",
      "src/hb-ot-tag.h",
      "src/hb-ot.h",
      "src/hb-private.hh",
      "src/hb-set-private.hh",
      "src/hb-set.cc",
      "src/hb-set.h",
      "src/hb-shape-plan-private.hh",
      "src/hb-shape-plan.cc",
      "src/hb-shape-plan.h",
      "src/hb-shape.cc",
      "src/hb-shape.h",
      "src/hb-shaper-impl-private.hh",
      "src/hb-shaper-list.hh",
      "src/hb-shaper-private.hh",
      "src/hb-shaper.cc",
      "src/hb-unicode-private.hh",
      "src/hb-unicode.cc",
      "src/hb-unicode.h",
      "src/hb-utf-private.hh",
      "src/hb-version.h",
      "src/hb-warning.cc",
      "src/hb.h",
    ]

    defines = [
      "HAVE_OT",
      "HAVE_ICU",
      "HAVE_ICU_BUILTIN",
      "HB_NO_MT",
    ]

    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",
    ]
    public_configs = [ ":harfbuzz-ng_config" ]

    deps = [
      "//third_party/icu:icuuc",
    ]

    if (is_mac) {
      sources += [
        "src/hb-coretext.cc",
        "src/hb-coretext.h",
      ]
      defines += [ "HAVE_CORETEXT" ]
    }

    # When without -fvisibility=hidden for pango to use the harfbuzz
    # in the tree, all symbols pango needs must be included, or
    # pango uses mixed versions of harfbuzz and leads to crash.
    # See crbug.com/462689.
    if (is_linux && use_pango && !is_chromeos && !is_official_build &&
        current_cpu != "arm" && current_cpu != "mipsel") {
      configs -= [ "//build/config/gcc:symbol_visibility_hidden" ]
      configs += [
        "//build/config/linux:freetype2",
        "//build/config/linux:glib",
      ]
      sources += [
        "src/hb-ft.cc",
        "src/hb-ft.h",
        "src/hb-glib.cc",
        "src/hb-glib.h",
      ]
    }

  }
}