summaryrefslogtreecommitdiff
path: root/chromium/third_party/fontconfig/BUILD.gn
blob: 1bee7acb6b97975516f161131abadc1e4b4e9ecb (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
# 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/sanitizers/sanitizers.gni")
import("//third_party/fontconfig/fontconfig.gni")

assert(is_linux || is_chromeos)

if (use_bundled_fontconfig) {
  config("fontconfig_config") {
    include_dirs = [ "src" ]
  }

  component("fontconfig") {
    sources = [
      "src/src/fcarch.h",
      "src/src/fcatomic.c",
      "src/src/fccache.c",
      "src/src/fccfg.c",
      "src/src/fccharset.c",
      "src/src/fccompat.c",
      "src/src/fcdbg.c",
      "src/src/fcdefault.c",
      "src/src/fcdir.c",
      "src/src/fcformat.c",
      "src/src/fcfreetype.c",
      "src/src/fcfs.c",
      "src/src/fchash.c",
      "src/src/fcinit.c",
      "src/src/fclang.c",
      "src/src/fclist.c",
      "src/src/fcmatch.c",
      "src/src/fcmatrix.c",
      "src/src/fcname.c",
      "src/src/fcobjs.c",
      "src/src/fcpat.c",
      "src/src/fcptrlist.c",
      "src/src/fcrange.c",
      "src/src/fcserialize.c",
      "src/src/fcstat.c",
      "src/src/fcstr.c",
      "src/src/fcweight.c",
      "src/src/fcxml.c",
      "src/src/ftglue.c",
      "src/src/ftglue.h",
    ]

    include_dirs = [
      "include",
      "include/src",
    ]

    defines = [
      "HAVE_CONFIG_H",
      "FC_CACHEDIR=\"/var/cache/fontconfig\"",
      "FC_TEMPLATEDIR=\"/usr/share/fontconfig/conf.avail\"",
      "FONTCONFIG_PATH=\"/etc/fonts\"",
    ]

    # Fontconfig symbols should not be exported from chrome, nacl_helper, or
    # anything else. However, if using the instrumented libraries, we do want to
    # export fontconfig symbols: in this configuration, there are 3 different
    # fontconfigs: this one, the one from instrumented_libraries, and the one
    # from the system. Only the first two get loaded: this one from Chrome, and
    # the one in instrumented_libraries indirectly through eg. gtk -> cairo ->
    # fontconfig. The latter is a different version of fontconfig with a
    # different cache file format. Therefore, the caches would have to get
    # regenerated every time Chrome runs for this other version. Depending on
    # how many fonts the user has installed, this could take several minutes,
    # especially for msan builds. Exporting the newer fontconfig symbols here
    # will ensure that cairo uses this fontconfig, and so avoids the caching
    # issue. In non-instrumented builds, it is ok that the real system
    # fontconfig is used by cairo instead of chromium's because caches for that
    # are warm. We don't *always* export fontconfig because in a rare case, it's
    # possible for the system fontconfig to be newer and have some Foo() that's
    # not in ours. Then eg. cairo would call init functions from our fontconfig
    # and then Foo() from the system fontconfig and crash.
    if (!is_component_build && !(use_prebuilt_instrumented_libraries ||
                                 use_locally_built_instrumented_libraries)) {
      defines += [
        "FC_ATTRIBUTE_VISIBILITY_HIDDEN=__attribute((visibility(\"hidden\")))",
        "FC_ATTRIBUTE_VISIBILITY_EXPORT=__attribute((visibility(\"hidden\")))",
      ]
    }

    deps = [
      "//build/config/freetype",
      "//third_party/libxml",
      "//third_party/zlib",
    ]

    configs -= [ "//build/config/compiler:chromium_code" ]
    configs += [ "//build/config/compiler:no_chromium_code" ]

    public_configs = [ ":fontconfig_config" ]

    if (is_clang) {
      cflags = [
        # Work around a null-conversion warning. See crbug.com/358852.
        "-Wno-non-literal-null-conversion",

        # Work around a pointer-to-bool conversion.
        "-Wno-pointer-bool-conversion",
      ]
    }

    if (!is_win) {
      libs = [ "uuid" ]
    }
  }
} else {
  config("fontconfig_config") {
    libs = [ "fontconfig" ]
  }

  group("fontconfig") {
    public_configs = [ ":fontconfig_config" ]
  }
}