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_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 } 32 33 config("cpp20") { 34 if (is_win) { 35 cflags_cc = [ "/std:c++20" ] 36 } else { 37 cflags_cc = [ "-std=c++20" ] 38 } 39 } 40 41 config("module") { 42 defines = [ "SKUNICODE_IMPLEMENTATION=1" ] 43 if (is_component_build) { 44 defines += [ "SKUNICODE_DLL" ] 45 } 46 } 47 48 component("skunicode_core") { 49 check_includes = false 50 if (!use_oh_skia) { 51 deps = [ "../..:skia" ] 52 } else { 53 include_dirs = [ "${skia_root_dir}" ] 54 } 55 configs += [ 56 ":module", 57 "../../:skia_private", 58 "../../third_party/icu/config:no_cxx", 59 ] 60 sources = skia_unicode_sources 61 } 62 63 if (skia_use_icu) { 64 component("skunicode_icu") { 65 check_includes = false 66 if (!use_oh_skia) { 67 deps = [ 68 ":skunicode_core", 69 "../..:skia", 70 ] 71 } else { 72 deps = [ ":skunicode_core" ] 73 include_dirs = [ "${skia_root_dir}" ] 74 } 75 configs += [ 76 ":module", 77 "../../:skia_private", 78 "../../third_party/icu/config:no_cxx", 79 ] 80 81 # These are explicitly *not* public defines because we don't want them 82 # to leak to dependents. 83 defines = [ "U_USING_ICU_NAMESPACE=0" ] 84 if (!skia_use_system_icu) { 85 defines += [ "U_DISABLE_RENAMING=1" ] 86 } 87 88 sources = skia_unicode_icu_bidi_sources 89 sources += skia_unicode_bidi_full_sources 90 sources += skia_unicode_icu_sources 91 sources += [ "../../third_party/icu/SkLoadICU.cpp" ] 92 93 # only available for Android at the moment 94 if (skia_use_runtime_icu && (is_android || is_linux)) { 95 sources += skia_unicode_runtime_icu_sources 96 defines += [ "SK_UNICODE_RUNTIME_ICU_AVAILABLE" ] 97 deps += [ "${skia_third_party_dir}/icu:headers" ] 98 } else { 99 sources += skia_unicode_builtin_icu_sources 100 if (skia_use_system_lib) { 101 external_deps = [ "icu:static_icu_for_skia" ] 102 } else { 103 deps += [ "${skia_third_party_dir}/icu" ] 104 } 105 if (is_arkui_x) { 106 defines += [ "U_DISABLE_RENAMING=0" ] 107 deps -= [ "${skia_third_party_dir}/icu" ] 108 deps += [ "//third_party/icu/icu4c:static_icuuc" ] 109 include_dirs += [ 110 "//third_party/icu/icu4c/source/common", 111 "//third_party/icu/icu4c" 112 ] 113 } 114 } 115 } 116 } 117 118 if (skia_use_client_icu) { 119 component("skunicode_client_icu") { 120 check_includes = false 121 deps = [ 122 ":skunicode_core", 123 "../..:skia", 124 ] 125 configs += [ 126 ":module", 127 "../../:skia_private", 128 "../../third_party/icu/config:no_cxx", 129 ] 130 defines = [ 131 # In order to use the bidi_subset at the same time as "full ICU", we must have 132 # compiled icu with the given defines also being set. This is to make sure the functions 133 # we call are given a suffix of "_skia" to prevent ODR violations if this "subset of ICU" 134 # is compiled alongside a full ICU build also. 135 # See https://chromium.googlesource.com/chromium/deps/icu.git/+/d94ab131bc8fef3bc17f356a628d8e4cd44d65d9/source/common/unicode/uversion.h 136 # for how these are used. 137 "U_DISABLE_RENAMING=0", 138 "U_USING_ICU_NAMESPACE=0", 139 "U_LIB_SUFFIX_C_NAME=_skia", 140 "U_HAVE_LIB_SUFFIX=1", 141 "U_DISABLE_VERSION_SUFFIX=1", 142 ] 143 144 sources = skia_unicode_icu_bidi_sources 145 sources += skia_unicode_bidi_subset_sources 146 sources += skia_unicode_client_icu_sources 147 if (skia_use_system_lib) { 148 external_deps = [ "icu:static_icu_bidi_for_skia" ] 149 } else { 150 deps += [ skia_icu_bidi_third_party_dir ] 151 } 152 } 153 } 154 155 if (skia_use_libgrapheme) { 156 component("skunicode_libgrapheme") { 157 check_includes = false 158 deps = [ 159 ":skunicode_core", 160 "../..:skia", 161 ] 162 configs += [ 163 ":module", 164 "../../:skia_private", 165 "../../third_party/icu/config:no_cxx", 166 ] 167 defines = [ 168 "U_DISABLE_RENAMING=0", 169 "U_USING_ICU_NAMESPACE=0", 170 "U_LIB_SUFFIX_C_NAME=_skia", 171 "U_HAVE_LIB_SUFFIX=1", 172 "U_DISABLE_VERSION_SUFFIX=1", 173 ] 174 175 sources = skia_unicode_icu_bidi_sources 176 sources += skia_unicode_bidi_subset_sources 177 178 sources += skia_unicode_libgrapheme_sources 179 deps += [ skia_libgrapheme_third_party_dir ] 180 if (skia_use_system_lib) { 181 external_deps = [ "icu:static_icu_bidi_for_skia" ] 182 } else { 183 deps += [ skia_icu_bidi_third_party_dir ] 184 } 185 } 186 } 187 188 if (skia_use_icu4x) { 189 component("skunicode_icu4x") { 190 check_includes = false 191 deps = [ 192 ":skunicode_core", 193 "../..:skia", 194 ] 195 configs += [ 196 ":module", 197 "../../:skia_private", 198 "../../third_party/icu/config:no_cxx", 199 ] 200 201 sources = skia_unicode_icu4x_sources 202 203 deps += [ "${skia_third_party_dir}/icu4x" ] 204 } 205 } 206 207 group("skunicode") { 208 public_configs = [ ":public_config" ] 209 public_deps = [ ":skunicode_core" ] 210 211 # We have these different flavors of skunicode as independent components because 212 # we have to set different defines for different builds of ICU. 213 if (skia_use_icu) { 214 public_deps += [ ":skunicode_icu" ] 215 } 216 if (skia_use_client_icu) { 217 public_deps += [ ":skunicode_client_icu" ] 218 } 219 if (skia_use_libgrapheme) { 220 public_deps += [ ":skunicode_libgrapheme" ] 221 } 222 if (skia_use_icu4x) { 223 public_deps += [ ":skunicode_icu4x" ] 224 } 225 } 226 227 if (defined(is_skia_standalone) && skia_enable_tools) { 228 skia_source_set("tests") { 229 if (skunicode_tests_enabled && 230 (skia_use_icu || skia_use_libgrapheme || skia_use_icu4x)) { 231 testonly = true 232 deps = [ 233 ":skunicode", 234 "../..:skia", 235 "../..:test", 236 ] 237 sources = skia_unicode_tests 238 external_deps = [] 239 if (skia_use_system_lib) { 240 external_deps += [ "icu:static_icu_bidi_for_skia" ] 241 } else { 242 deps += [ skia_icu_bidi_third_party_dir ] 243 } 244 if (is_ohos) { 245 external_deps = [ "hitrace:hitrace_meter" ] 246 if (!build_ohos_sdk && !is_arkui_x) { 247 external_deps += [ "init:libbegetutil" ] 248 if (defined(defines)) { 249 defines += [ "NOT_BUILD_FOR_OHOS_SDK" ] 250 } else { 251 defines = [ "NOT_BUILD_FOR_OHOS_SDK" ] 252 } 253 } 254 } 255 if (is_arkui_x) { 256 deps += [ "//third_party/bounds_checking_function:libsec_static" ] 257 } else if (is_ohos) { 258 if (is_component_build) { 259 external_deps += [ "bounds_checking_function:libsec_shared" ] 260 } else { 261 external_deps += [ "bounds_checking_function:libsec_static" ] 262 } 263 } 264 } else { 265 sources = [] 266 } 267 } 268 } 269} else { 270 group("skunicode") { 271 } 272 group("tests") { 273 } 274} 275