| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import("//build/config/chrome_build.gni") | 5 import("//build/config/chrome_build.gni") |
| 6 import("//build/config/features.gni") | 6 import("//build/config/features.gni") |
| 7 import("//build/config/linux/pkg_config.gni") | 7 import("//build/config/linux/pkg_config.gni") |
| 8 import("//build/config/freetype/freetype.gni") |
| 8 import("//build/config/ui.gni") | 9 import("//build/config/ui.gni") |
| 9 import("//testing/libfuzzer/fuzzer_test.gni") | 10 import("//testing/libfuzzer/fuzzer_test.gni") |
| 10 | 11 import("//third_party/harfbuzz-ng/harfbuzz.gni") |
| 11 declare_args() { | |
| 12 # Blink uses a cutting-edge version of Harfbuzz; most Linux distros do not | |
| 13 # contain a new enough version of the code to work correctly. However, | |
| 14 # ChromeOS chroots (i.e, real ChromeOS builds for devices) do contain a | |
| 15 # new enough version of the library, and so this variable exists so that | |
| 16 # ChromeOS can build against the system lib and keep binary sizes smaller. | |
| 17 use_system_harfbuzz = false | |
| 18 } | |
| 19 | 12 |
| 20 if (use_system_harfbuzz) { | 13 if (use_system_harfbuzz) { |
| 21 import("//build/config/linux/pkg_config.gni") | 14 import("//build/config/linux/pkg_config.gni") |
| 22 pkg_config("harfbuzz_pkgconfig") { | 15 pkg_config("harfbuzz_pkgconfig") { |
| 23 packages = [ "harfbuzz" ] | 16 packages = [ "harfbuzz" ] |
| 24 } | 17 } |
| 25 group("harfbuzz-ng") { | 18 group("harfbuzz-ng") { |
| 26 public_configs = [ ":harfbuzz_pkgconfig" ] | 19 public_configs = [ ":harfbuzz_pkgconfig" ] |
| 27 } | 20 } |
| 28 } else { | 21 } else { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 43 ] | 36 ] |
| 44 } | 37 } |
| 45 if (is_win) { | 38 if (is_win) { |
| 46 # Result of 32-bit shift implicitly converted to 64 bits. | 39 # Result of 32-bit shift implicitly converted to 64 bits. |
| 47 cflags += [ "/wd4334" ] | 40 cflags += [ "/wd4334" ] |
| 48 } | 41 } |
| 49 } | 42 } |
| 50 | 43 |
| 51 # See also chrome/browser/ui/libgtkui/BUILD.gn which pulls this. | 44 # See also chrome/browser/ui/libgtkui/BUILD.gn which pulls this. |
| 52 config("pangoft2_link_hack") { | 45 config("pangoft2_link_hack") { |
| 53 if (is_linux && use_pango && !is_chromeos && !is_official_build && | 46 if (is_linux && use_pango && !use_system_harfbuzz && !is_component_build) { |
| 54 current_cpu != "arm" && current_cpu != "mipsel" && !is_component_build)
{ | |
| 55 # These symbols are referenced from libpangoft2, which will be | 47 # These symbols are referenced from libpangoft2, which will be |
| 56 # dynamically linked later. | 48 # dynamically linked later. |
| 57 ldflags = [ "-Wl,-uhb_ft_face_create_cached,-uhb_glib_get_unicode_funcs" ] | 49 ldflags = [ "-Wl,-uhb_ft_face_create_cached,-uhb_glib_get_unicode_funcs" ] |
| 58 } | 50 } |
| 59 } | 51 } |
| 60 | 52 |
| 61 static_library("harfbuzz-ng") { | 53 static_library("harfbuzz-ng") { |
| 62 sources = [ | 54 sources = [ |
| 63 "src/hb-atomic-private.hh", | 55 "src/hb-atomic-private.hh", |
| 64 "src/hb-blob.cc", | 56 "src/hb-blob.cc", |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 "src/hb-coretext.h", | 183 "src/hb-coretext.h", |
| 192 ] | 184 ] |
| 193 defines += [ "HAVE_CORETEXT" ] | 185 defines += [ "HAVE_CORETEXT" ] |
| 194 libs = [ | 186 libs = [ |
| 195 "CoreFoundation.framework", | 187 "CoreFoundation.framework", |
| 196 "CoreGraphics.framework", | 188 "CoreGraphics.framework", |
| 197 "CoreText.framework", | 189 "CoreText.framework", |
| 198 ] | 190 ] |
| 199 } | 191 } |
| 200 | 192 |
| 201 # When without -fvisibility=hidden for pango to use the harfbuzz | |
| 202 # in the tree, all symbols pango needs must be included, or | |
| 203 # pango uses mixed versions of harfbuzz and leads to crash. | |
| 204 # See crbug.com/462689. | |
| 205 if (is_linux && use_pango && !is_chromeos && !is_official_build && | |
| 206 current_cpu != "arm" && current_cpu != "mipsel") { | |
| 207 deps += [ "//build/config/freetype" ] | |
| 208 configs -= [ "//build/config/gcc:symbol_visibility_hidden" ] | |
| 209 configs += [ "//build/config/gcc:symbol_visibility_default" ] | |
| 210 sources += [ | |
| 211 "src/hb-ft.cc", | |
| 212 "src/hb-ft.h", | |
| 213 ] | |
| 214 } | |
| 215 if (use_glib) { | 193 if (use_glib) { |
| 216 configs += [ "//build/config/linux:glib" ] | 194 configs += [ "//build/config/linux:glib" ] |
| 217 sources += [ | 195 sources += [ |
| 218 "src/hb-glib.cc", | 196 "src/hb-glib.cc", |
| 219 "src/hb-glib.h", | 197 "src/hb-glib.h", |
| 220 ] | 198 ] |
| 221 } | 199 } |
| 222 } | 200 } |
| 201 |
| 202 config("harfbuzz-ng-ft-deferred-linkage") { |
| 203 # Use this in //third_party/freetype2 to link without the hb_ft* symbols |
| 204 # existing yet. |
| 205 |
| 206 # Use this in harbuzz-ng-ft to link without the regular hb_* symbols |
| 207 # existing yet. |
| 208 |
| 209 # The dependency circle is as follows: FreeType depends on HarfBuzz for the |
| 210 # autofitter, HarfBuzz depends on FreeType for the hb_ft functions that |
| 211 # pangocairo depends on. We can solve this by linking //third_party/freetype |
| 212 # incompletely, with leaving the hb_ft_font_create function undefined. Then |
| 213 # linking harfbuzz-ng-ft incompletely, with leaving the standard harfbuzz |
| 214 # symbols undefined, then using the freetype group in |
| 215 # //build/config/freetype which binds everything together: harfbuzz-ng, |
| 216 # freetype-without-harfbuzz, and harfbuzz-ng-ft. |
| 217 if (!is_clang) { |
| 218 ldflags = [ "-Wl,--unresolved-symbols=ignore-all" ] |
| 219 } else { |
| 220 ldflags = [ "-Wl,-undefined,dynamic_lookup" ] |
| 221 } |
| 222 } |
| 223 |
| 224 # if (is_linux && use_pango && !use_system_harfbuzz) { |
| 225 static_library("harfbuzz-ng-ft") { |
| 226 sources = [ |
| 227 "src/hb-ft.cc", |
| 228 "src/hb-ft.h", |
| 229 ] |
| 230 |
| 231 if (is_component_build) { |
| 232 configs -= [ "//build/config/gcc:symbol_visibility_hidden" ] |
| 233 configs += [ "//build/config/gcc:symbol_visibility_default" ] |
| 234 } |
| 235 |
| 236 configs -= [ "//build/config/compiler:chromium_code" ] |
| 237 configs += [ |
| 238 "//build/config/compiler:no_chromium_code", |
| 239 ":harfbuzz-ng-ft-deferred-linkage", |
| 240 |
| 241 # Must be after no_chromium_code for warning flags to be ordered |
| 242 # correctly. |
| 243 ":harfbuzz_warnings", |
| 244 ] |
| 245 public_configs = [ ":harfbuzz-ng_config" ] |
| 246 |
| 247 defines = [ |
| 248 "HAVE_OT", |
| 249 "HAVE_ICU", |
| 250 "HAVE_ICU_BUILTIN", |
| 251 "HB_NO_MT", |
| 252 ] |
| 253 |
| 254 deps = [ |
| 255 "//build/config/freetype:freetype-without-harfbuzz", |
| 256 ] |
| 257 } |
| 258 |
| 259 # } |
| 223 } | 260 } |
| 224 | 261 |
| 225 fuzzer_test("harfbuzz_fuzzer") { | 262 fuzzer_test("harfbuzz_fuzzer") { |
| 226 sources = [ | 263 sources = [ |
| 227 "fuzz/harfbuzz_fuzzer.cc", | 264 "fuzz/harfbuzz_fuzzer.cc", |
| 228 ] | 265 ] |
| 229 deps = [ | 266 deps = [ |
| 230 ":harfbuzz-ng", | 267 ":harfbuzz-ng", |
| 231 ] | 268 ] |
| 232 libfuzzer_options = [ "max_len=16800" ] | 269 libfuzzer_options = [ "max_len=16800" ] |
| 233 seed_corpus = "fuzz/seed_corpus" | 270 seed_corpus = "fuzz/seed_corpus" |
| 234 } | 271 } |
| OLD | NEW |