Fix build.
[chromium-blink-merge.git] / third_party / harfbuzz-ng / BUILD.gn
blob195c5c81c806c752b196ecbe685fc2381a485e93
1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
5 import("//build/config/linux/pkg_config.gni")
7 # The GYP build supports system harfbuzz for non-official builds when using
8 # pangoft2 1.31.0 or greater (which pulls it in).
9 # TODO(brettw) we can consider doing this as well, although the benefit is
10 # unclear and requires shelling out to a script to check the version.
12 # ChromeOS uses an up-to-date system one that we have control over, so we
13 # don't want to bloat the binary more by including another copy.
15 declare_args() {
16   if (is_chromeos) {
17     # ChromeOS includes an up-to-date system harfbuzz that we have control
18     # over, so it use the system one by default.
19     use_system_harfbuzz = true
20   } else if (is_official_build) {
21     # For official builds, we want to control the Harbuzz version so always
22     # use our included one. Currently the sysroot includes a version of pangoft
23     # that doesn't link to harfbuzz, so there are no linker problems. If we
24     # update that version, we'll need to work around the duplicate symbols some
25     # other way.
26     use_system_harfbuzz = false
27   } else if (is_linux) {
28     # Use the system harfbuzz for newer versions of pangoft, and not for older
29     # ones. pangoft links to the system harfbuzz starting with 1.31.0, which
30     # causes duplicate symbols when we link our own version.
31     use_system_harfbuzz = exec_script(
32         pkg_config_script,
33         pkg_config_args + [ "--atleast-version=1.31.0", "pangoft2" ],
34         "value")
35   } else {
36     use_system_harfbuzz = false
37   }
40 if (use_system_harfbuzz) {
41   import("//build/config/linux/pkg_config.gni")
42   pkg_config("harfbuzz_pkgconfig") {
43     packages = [ "harfbuzz" ]
44   }
45   group("harfbuzz-ng") {
46     public_configs = [ ":harfbuzz_pkgconfig" ]
47   }
49 } else {
50   config("harfbuzz-ng_config") {
51     include_dirs = [ "src" ]
52   }
54   static_library("harfbuzz-ng") {
55     sources = [
56       "src/hb-atomic-private.hh",
57       "src/hb-blob.cc",
58       "src/hb-blob.h",
59       "src/hb-buffer.cc",
60       "src/hb-buffer-deserialize-json.hh",
61       "src/hb-buffer-deserialize-text.hh",
62       "src/hb-buffer.h",
63       "src/hb-buffer-private.hh",
64       "src/hb-buffer-serialize.cc",
65       "src/hb-cache-private.hh",
66       "src/hb-common.cc",
67       "src/hb-common.h",
68       "src/hb-deprecated.h",
69       "src/hb-face.cc",
70       "src/hb-face.h",
71       "src/hb-face-private.hh",
72       "src/hb-fallback-shape.cc",
73       "src/hb-font.cc",
74       "src/hb-font.h",
75       "src/hb-font-private.hh",
76       "src/hb.h",
77       "src/hb-icu.cc",
78       "src/hb-icu.h",
79       "src/hb-mutex-private.hh",
80       "src/hb-object-private.hh",
81       "src/hb-open-file-private.hh",
82       "src/hb-open-type-private.hh",
83       "src/hb-ot.h",
84       "src/hb-ot-head-table.hh",
85       "src/hb-ot-hhea-table.hh",
86       "src/hb-ot-hmtx-table.hh",
87       "src/hb-ot-layout.cc",
88       "src/hb-ot-layout-common-private.hh",
89       "src/hb-ot-layout-gdef-table.hh",
90       "src/hb-ot-layout-gpos-table.hh",
91       "src/hb-ot-layout-gsubgpos-private.hh",
92       "src/hb-ot-layout-gsub-table.hh",
93       "src/hb-ot-layout.h",
94       "src/hb-ot-layout-private.hh",
95       "src/hb-ot-map.cc",
96       "src/hb-ot-map-private.hh",
97       "src/hb-ot-maxp-table.hh",
98       "src/hb-ot-name-table.hh",
99       "src/hb-ot-shape.cc",
100       "src/hb-ot-shape-complex-arabic.cc",
101       "src/hb-ot-shape-complex-arabic-fallback.hh",
102       "src/hb-ot-shape-complex-arabic-table.hh",
103       "src/hb-ot-shape-complex-default.cc",
104       "src/hb-ot-shape-complex-hangul.cc",
105       "src/hb-ot-shape-complex-hebrew.cc",
106       "src/hb-ot-shape-complex-indic.cc",
107       "src/hb-ot-shape-complex-indic-machine.hh",
108       "src/hb-ot-shape-complex-indic-private.hh",
109       "src/hb-ot-shape-complex-indic-table.cc",
110       "src/hb-ot-shape-complex-myanmar.cc",
111       "src/hb-ot-shape-complex-myanmar-machine.hh",
112       "src/hb-ot-shape-complex-private.hh",
113       "src/hb-ot-shape-complex-sea.cc",
114       "src/hb-ot-shape-complex-sea-machine.hh",
115       "src/hb-ot-shape-complex-thai.cc",
116       "src/hb-ot-shape-complex-tibetan.cc",
117       "src/hb-ot-shape-fallback.cc",
118       "src/hb-ot-shape-fallback-private.hh",
119       "src/hb-ot-shape.h",
120       "src/hb-ot-shape-normalize.cc",
121       "src/hb-ot-shape-normalize-private.hh",
122       "src/hb-ot-shape-private.hh",
123       "src/hb-ot-tag.cc",
124       "src/hb-ot-tag.h",
125       "src/hb-private.hh",
126       "src/hb-set.cc",
127       "src/hb-set.h",
128       "src/hb-set-private.hh",
129       "src/hb-shape.cc",
130       "src/hb-shape.h",
131       "src/hb-shape-plan.cc",
132       "src/hb-shape-plan.h",
133       "src/hb-shape-plan-private.hh",
134       "src/hb-shaper.cc",
135       "src/hb-shaper-impl-private.hh",
136       "src/hb-shaper-list.hh",
137       "src/hb-shaper-private.hh",
138       "src/hb-unicode.cc",
139       "src/hb-unicode.h",
140       "src/hb-unicode-private.hh",
141       "src/hb-utf-private.hh",
142       "src/hb-version.h",
143       "src/hb-warning.cc",
144     ]
146     defines = [
147       "HAVE_OT",
148       "HAVE_ICU",
149       "HAVE_ICU_BUILTIN",
150       "HB_NO_MT",
151     ]
153     configs -= [ "//build/config/compiler:chromium_code" ]
154     configs += [ "//build/config/compiler:no_chromium_code" ]
155     public_configs = [ ":harfbuzz-ng_config" ]
157     deps = [
158       "//third_party/icu:icuuc",
159     ]
161     cflags = []
162     if (is_clang) {
163       cflags += [ "-Wno-unused-value" ]
164     }
165     if (is_win) {
166       cflags += [
167         "/wd4267",  # size_t to 'type' converion.
168         "/wd4334",  # Result of 32-bit shift implicitly converted to 64 bits.
169       ]
170     }
171     if (is_mac) {
172       sources += [
173         "src/hb-coretext.cc",
174         "src/hb-coretext.h",
175       ]
176       defines += [ "HAVE_CORETEXT" ]
177     }
178   }