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 = "63" # defined in source/common/unicode/uvernum.h 40 script = "make_data_cpp.py" 41 inputs = [ 42 "$data_dir/icudtl.dat", 43 ] 44 outputs = [ 45 data_assembly, 46 ] 47 args = [ 48 "icudt${_u_icu_version_major_num}_dat", 49 rebase_path(inputs[0], root_build_dir), 50 rebase_path(data_assembly, root_build_dir), 51 ] 52 } else { 53 script = "../externals/icu/scripts/make_data_assembly.py" 54 inputs = [ 55 "$data_dir/icudtl.dat", 56 ] 57 outputs = [ 58 "$data_assembly", 59 ] 60 args = [ 61 rebase_path(inputs[0], root_build_dir), 62 rebase_path(data_assembly, root_build_dir), 63 ] 64 if (is_mac || is_ios) { 65 args += [ "--mac" ] 66 } 67 } 68 } 69 70 third_party("icu") { 71 public_include_dirs = [ 72 "../externals/icu/source/common", 73 "../externals/icu/source/i18n", 74 ".", 75 ] 76 public_defines = [ 77 "U_USING_ICU_NAMESPACE=0", 78 "SK_USING_THIRD_PARTY_ICU", 79 ] 80 configs -= [ "//gn:no_rtti" ] 81 defines = [ 82 # http://userguide.icu-project.org/howtouseicu 83 "U_COMMON_IMPLEMENTATION", 84 "U_STATIC_IMPLEMENTATION", 85 "U_ENABLE_DYLOAD=0", 86 "U_I18N_IMPLEMENTATION", 87 ] 88 if (target_cpu == "wasm") { 89 # Tell ICU that we are a 32 bit platform, otherwise, 90 # double-conversion-utils.h doesn't know how to operate. 91 defines += [ "__i386__" ] 92 } 93 sources = icu_sources 94 if (is_win) { 95 deps = [ 96 ":icudata", 97 ] 98 public_defines += [ 99 "U_NOEXCEPT=", 100 "U_STATIC_IMPLEMENTATION", 101 ] 102 libs = [ "Advapi32.lib" ] 103 sources += [ 104 "../externals/icu/source/stubdata/stubdata.cpp", 105 "SkLoadICU.cpp", 106 ] 107 } else { 108 sources += [ "$data_assembly" ] 109 deps = [ 110 ":make_data_assembly", 111 ] 112 } 113 } 114 115 copy("icudata") { 116 sources = [ 117 "../externals/icu/common/icudtl.dat", 118 ] 119 outputs = [ 120 "$root_out_dir/icudtl.dat", 121 ] 122 data = [ 123 "$root_out_dir/icudtl.dat", 124 ] 125 } 126} 127