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 && !is_wasm 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 } 61 } 62 63 third_party("headers") { 64 public_include_dirs = [ 65 "../externals/icu/source/common", 66 "../externals/icu/source/i18n", 67 ".", 68 ] 69 public_defines = [ 70 "U_USING_ICU_NAMESPACE=0", 71 "U_DISABLE_RENAMING", 72 ] 73 } 74 75 third_party("icu") { 76 public_include_dirs = [ 77 "../externals/icu/source/common", 78 "../externals/icu/source/i18n", 79 ".", 80 ] 81 public_defines = [ 82 "U_USING_ICU_NAMESPACE=0", 83 "U_DISABLE_RENAMING", 84 "SK_USING_THIRD_PARTY_ICU", 85 ] 86 configs = [ "//gn/portable:add_rtti" ] 87 defines = [ 88 # http://userguide.icu-project.org/howtouseicu 89 "U_COMMON_IMPLEMENTATION", 90 "U_STATIC_IMPLEMENTATION", 91 "U_ENABLE_DYLOAD=0", 92 "U_I18N_IMPLEMENTATION", 93 94 # If we don't set this to zero, ICU will set it to 600, 95 # which makes Macs set _POSIX_C_SOURCE=200112L, 96 # which makes Macs set __DARWIN_C_LEVEL=_POSIX_C_SOURCE instead of =__DARWIN_C_FULL, 97 # which makes <time.h> not expose timespec_get, 98 # which makes recent libc++ <ctime> not #include-able with -std=c++17. 99 "_XOPEN_SOURCE=0", 100 ] 101 if (target_cpu == "wasm") { 102 # Tell ICU that we are a 32 bit platform, otherwise, 103 # double-conversion-utils.h doesn't know how to operate. 104 defines += [ "__i386__" ] 105 } 106 sources = icu_sources 107 if (is_win) { 108 deps = [ ":icudata" ] 109 public_defines += [ 110 "U_NOEXCEPT=", 111 "U_STATIC_IMPLEMENTATION", 112 ] 113 libs = [ "Advapi32.lib" ] 114 sources += [ 115 "../externals/icu/source/stubdata/stubdata.cpp", 116 "SkLoadICU.cpp", 117 ] 118 } else { 119 sources += [ "$data_assembly" ] 120 deps = [ ":make_data_assembly" ] 121 } 122 } 123 124 copy("icudata") { 125 sources = [ "../externals/icu/common/icudtl.dat" ] 126 outputs = [ "$root_out_dir/icudtl.dat" ] 127 data = [ "$root_out_dir/icudtl.dat" ] 128 } 129} 130