1# Copyright 2016 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.gni") 8import("icu.gni") 9 10declare_args() { 11 skia_use_system_icu = is_official_build 12} 13 14if (skia_use_system_icu) { 15 system("icu") { 16 libs = [ "icuuc" ] 17 defines = [ "U_USING_ICU_NAMESPACE=0" ] 18 } 19} else { 20 if (target_cpu == "wasm") { 21 data_assembly = "$target_gen_dir/icudtl_dat.cpp" 22 } else { 23 data_assembly = "$target_gen_dir/icudtl_dat.S" 24 } 25 data_dir = "../externals/icu/" 26 if (target_cpu == "wasm") { 27 # Use a super super super stripped down version for wasm, 28 # which is the same thing flutter is using. 29 data_dir += "flutter" 30 } else if (is_android) { 31 data_dir += "android" 32 } else if (is_ios) { 33 data_dir += "ios" 34 } else { 35 data_dir += "common" 36 } 37 action("make_data_assembly") { 38 if (target_cpu == "wasm") { 39 _u_icu_version_major_num = 40 "69" # defined in source/common/unicode/uvernum.h 41 script = "make_data_cpp.py" 42 inputs = [ "$data_dir/icudtl.dat" ] 43 outputs = [ data_assembly ] 44 args = [ 45 "icudt${_u_icu_version_major_num}_dat", 46 rebase_path(inputs[0], root_build_dir), 47 rebase_path(data_assembly, root_build_dir), 48 ] 49 } else { 50 script = "../externals/icu/scripts/make_data_assembly.py" 51 inputs = [ "$data_dir/icudtl.dat" ] 52 outputs = [ "$data_assembly" ] 53 args = [ 54 rebase_path(inputs[0], root_build_dir), 55 rebase_path(data_assembly, root_build_dir), 56 ] 57 if (is_mac || is_ios) { 58 args += [ "--mac" ] 59 } 60 if (is_win || is_mingw) { 61 args += [ "--win" ] 62 } 63 } 64 } 65 66 third_party("headers") { 67 public_include_dirs = [ 68 "../externals/icu/source/common", 69 "../externals/icu/source/i18n", 70 ".", 71 ] 72 public_defines = [ 73 "U_USING_ICU_NAMESPACE=0", 74 "U_DISABLE_RENAMING", 75 ] 76 } 77 78 third_party("icu") { 79 public_include_dirs = [ 80 "../externals/icu/source/common", 81 "../externals/icu/source/i18n", 82 ".", 83 ] 84 public_defines = [ 85 "U_USING_ICU_NAMESPACE=0", 86 "U_DISABLE_RENAMING", 87 "SK_USING_THIRD_PARTY_ICU", 88 ] 89 configs = [ "${skia_root_dir}/gn/portable:add_rtti" ] 90 defines = [ 91 # http://userguide.icu-project.org/howtouseicu 92 "U_COMMON_IMPLEMENTATION", 93 "U_STATIC_IMPLEMENTATION", 94 "U_ENABLE_DYLOAD=0", 95 "U_I18N_IMPLEMENTATION", 96 97 # If we don't set this to zero, ICU will set it to 600, 98 # which makes Macs set _POSIX_C_SOURCE=200112L, 99 # which makes Macs set __DARWIN_C_LEVEL=_POSIX_C_SOURCE instead of =__DARWIN_C_FULL, 100 # which makes <time.h> not expose timespec_get, 101 # which makes recent libc++ <ctime> not #include-able with -std=c++17. 102 "_XOPEN_SOURCE=0", 103 ] 104 if (target_cpu == "wasm") { 105 # Tell ICU that we are a 32 bit platform, otherwise, 106 # double-conversion-utils.h doesn't know how to operate. 107 defines += [ "__i386__" ] 108 } 109 sources = icu_sources 110 if (is_win || (defined(is_mingw) && is_mingw)) { 111 deps = [ ":icudata" ] 112 public_defines += [ 113 "U_NOEXCEPT=", 114 "U_STATIC_IMPLEMENTATION", 115 ] 116 if (defined(is_mingw) && is_mingw) { 117 libs = [ "advapi32" ] 118 } else { 119 libs = [ "Advapi32.lib" ] 120 } 121 sources += [ 122 "../externals/icu/source/stubdata/stubdata.cpp", 123 "SkLoadICU.cpp", 124 ] 125 cflags_cc = [ "-DWINVER=0x0601" ] 126 } else { 127 sources += [ "$data_assembly" ] 128 deps = [ ":make_data_assembly" ] 129 } 130 } 131 132 copy("icudata") { 133 sources = [ "../externals/icu/common/icudtl.dat" ] 134 outputs = [ "$root_out_dir/icudtl.dat" ] 135 data = [ "$root_out_dir/icudtl.dat" ] 136 } 137 138 if (is_arkui_x) { 139 config("icu_config") { 140 defines = [ 141 "U_COMMON_IMPLEMENTATION", 142 "U_STATIC_IMPLEMENTATION", 143 "U_ENABLE_DYLOAD=0", 144 "U_I18N_IMPLEMENTATION", 145 "U_USING_ICU_NAMESPACE=0", 146 "U_DISABLE_RENAMING", 147 "SK_USING_THIRD_PARTY_ICU", 148 ] 149 150 include_dirs = [ 151 "../externals/icu/source/common", 152 "../externals/icu/source/i18n", 153 ".", 154 ] 155 } 156 } 157} 158