1# Copyright 2021 Google Inc. 2# 3# Use of this source code is governed by a BSD-style license that can be 4# found in the LICENSE file. 5 6import("../../gn/skia.gni") 7import("../../third_party/icu/icu.gni") 8import("skunicode.gni") 9 10declare_args() { 11 skia_use_runtime_icu = false 12 skunicode_tests_enabled = true 13} 14 15if (skia_use_icu || skia_use_client_icu || skia_use_libgrapheme || 16 skia_use_bidi || skia_use_icu4x) { 17 config("public_config") { 18 defines = [ "SK_UNICODE_AVAILABLE" ] 19 if (skia_use_icu) { 20 defines += [ "SK_UNICODE_ICU_IMPLEMENTATION" ] 21 } 22 if (skia_use_client_icu) { 23 defines += [ "SK_UNICODE_CLIENT_IMPLEMENTATION" ] 24 } 25 if (skia_use_libgrapheme) { 26 defines += [ "SK_UNICODE_LIBGRAPHEME_IMPLEMENTATION" ] 27 } 28 if (skia_use_icu4x) { 29 defines += [ "SK_UNICODE_ICU4X_IMPLEMENTATION" ] 30 } 31 if (skia_use_bidi) { 32 defines += [ "SK_UNICODE_BIDI_IMPLEMENTATION" ] 33 } 34 } 35 36 config("cpp20") { 37 if (is_win) { 38 cflags_cc = [ "/std:c++20" ] 39 } else { 40 cflags_cc = [ "-std=c++20" ] 41 } 42 } 43 44 config("module") { 45 defines = [ "SKUNICODE_IMPLEMENTATION=1" ] 46 if (is_component_build) { 47 defines += [ "SKUNICODE_DLL" ] 48 } 49 } 50 51 component("skunicode_core") { 52 check_includes = false 53 deps = [ "../..:skia" ] 54 configs += [ 55 ":module", 56 "../../:skia_private", 57 "../../third_party/icu/config:no_cxx", 58 ] 59 sources = skia_unicode_sources 60 } 61 62 if (skia_use_icu) { 63 component("skunicode_icu") { 64 check_includes = false 65 deps = [ 66 ":skunicode_core", 67 "../..:skia", 68 ] 69 configs += [ 70 ":module", 71 "../../:skia_private", 72 "../../third_party/icu/config:no_cxx", 73 ] 74 75 # These are explicitly *not* public defines because we don't want them 76 # to leak to dependents. 77 defines = [ "U_USING_ICU_NAMESPACE=0" ] 78 if (!skia_use_system_icu) { 79 defines += [ "U_DISABLE_RENAMING=1" ] 80 } 81 82 sources = skia_unicode_icu_bidi_sources 83 sources += skia_unicode_bidi_full_sources 84 sources += skia_unicode_icu_sources 85 86 # only available for Android at the moment 87 if (skia_use_runtime_icu && (is_android || is_linux)) { 88 sources += skia_unicode_runtime_icu_sources 89 defines += [ "SK_UNICODE_RUNTIME_ICU_AVAILABLE" ] 90 deps += [ "//third_party/icu:headers" ] 91 } else { 92 sources += skia_unicode_builtin_icu_sources 93 deps += [ "//third_party/icu" ] 94 } 95 } 96 } 97 98 if (skia_use_client_icu) { 99 component("skunicode_client_icu") { 100 check_includes = false 101 deps = [ 102 ":skunicode_core", 103 "../..:skia", 104 ] 105 configs += [ 106 ":module", 107 "../../:skia_private", 108 "../../third_party/icu/config:no_cxx", 109 ] 110 defines = [ 111 # In order to use the bidi_subset at the same time as "full ICU", we must have 112 # compiled icu with the given defines also being set. This is to make sure the functions 113 # we call are given a suffix of "_skia" to prevent ODR violations if this "subset of ICU" 114 # is compiled alongside a full ICU build also. 115 # See https://chromium.googlesource.com/chromium/deps/icu.git/+/d94ab131bc8fef3bc17f356a628d8e4cd44d65d9/source/common/unicode/uversion.h 116 # for how these are used. 117 "U_DISABLE_RENAMING=0", 118 "U_USING_ICU_NAMESPACE=0", 119 "U_LIB_SUFFIX_C_NAME=_skia", 120 "U_HAVE_LIB_SUFFIX=1", 121 "U_DISABLE_VERSION_SUFFIX=1", 122 ] 123 124 sources = skia_unicode_icu_bidi_sources 125 sources += skia_unicode_bidi_subset_sources 126 sources += skia_unicode_client_icu_sources 127 deps += [ skia_icu_bidi_third_party_dir ] 128 } 129 } 130 131 if (skia_use_bidi) { 132 component("skunicode_bidi") { 133 check_includes = false 134 deps = [ 135 ":skunicode_core", 136 "../..:skia", 137 ] 138 configs += [ 139 ":module", 140 "../../:skia_private", 141 "../../third_party/icu/config:no_cxx", 142 ] 143 defines = [ 144 # In order to use the bidi_subset at the same time as "full ICU", we must have 145 # compiled icu with the given defines also being set. This is to make sure the functions 146 # we call are given a suffix of "_skia" to prevent ODR violations if this "subset of ICU" 147 # is compiled alongside a full ICU build also. 148 # See https://chromium.googlesource.com/chromium/deps/icu.git/+/d94ab131bc8fef3bc17f356a628d8e4cd44d65d9/source/common/unicode/uversion.h 149 # for how these are used. 150 "U_DISABLE_RENAMING=0", 151 "U_USING_ICU_NAMESPACE=0", 152 "U_LIB_SUFFIX_C_NAME=_skia", 153 "U_HAVE_LIB_SUFFIX=1", 154 "U_DISABLE_VERSION_SUFFIX=1", 155 ] 156 157 sources = skia_unicode_icu_bidi_sources 158 sources += skia_unicode_bidi_subset_sources 159 sources += skia_unicode_bidi_sources 160 deps += [ skia_icu_bidi_third_party_dir ] 161 } 162 } 163 164 if (skia_use_libgrapheme) { 165 component("skunicode_libgrapheme") { 166 check_includes = false 167 deps = [ 168 ":skunicode_core", 169 "../..:skia", 170 ] 171 configs += [ 172 ":module", 173 "../../:skia_private", 174 "../../third_party/icu/config:no_cxx", 175 ] 176 defines = [ 177 "U_DISABLE_RENAMING=0", 178 "U_USING_ICU_NAMESPACE=0", 179 "U_LIB_SUFFIX_C_NAME=_skia", 180 "U_HAVE_LIB_SUFFIX=1", 181 "U_DISABLE_VERSION_SUFFIX=1", 182 ] 183 184 sources = skia_unicode_icu_bidi_sources 185 sources += skia_unicode_bidi_subset_sources 186 187 sources += skia_unicode_libgrapheme_sources 188 deps += [ 189 skia_icu_bidi_third_party_dir, 190 skia_libgrapheme_third_party_dir, 191 ] 192 } 193 } 194 195 if (skia_use_icu4x) { 196 component("skunicode_icu4x") { 197 check_includes = false 198 deps = [ 199 ":skunicode_core", 200 "../..:skia", 201 ] 202 configs += [ 203 ":module", 204 "../../:skia_private", 205 "../../third_party/icu/config:no_cxx", 206 ] 207 208 sources = skia_unicode_icu4x_sources 209 210 deps += [ "//third_party/icu4x" ] 211 } 212 } 213 214 group("skunicode") { 215 public_configs = [ ":public_config" ] 216 public_deps = [ ":skunicode_core" ] 217 218 # We have these different flavors of skunicode as independent components because 219 # we have to set different defines for different builds of ICU. 220 if (skia_use_icu) { 221 public_deps += [ ":skunicode_icu" ] 222 } 223 if (skia_use_client_icu) { 224 public_deps += [ ":skunicode_client_icu" ] 225 } 226 if (skia_use_bidi) { 227 public_deps += [ ":skunicode_bidi" ] 228 } 229 if (skia_use_libgrapheme) { 230 public_deps += [ ":skunicode_libgrapheme" ] 231 } 232 if (skia_use_icu4x) { 233 public_deps += [ ":skunicode_icu4x" ] 234 } 235 } 236 237 if (defined(is_skia_standalone) && skia_enable_tools) { 238 skia_source_set("tests") { 239 if (skunicode_tests_enabled && 240 (skia_use_icu || skia_use_libgrapheme || skia_use_icu4x)) { 241 testonly = true 242 deps = [ 243 ":skunicode", 244 "../..:skia", 245 "../..:test", 246 ] 247 sources = skia_unicode_tests 248 deps += [ skia_icu_bidi_third_party_dir ] 249 } else { 250 sources = [] 251 } 252 } 253 } 254} else { 255 group("skunicode") { 256 } 257 group("tests") { 258 } 259} 260