blob: 8c224ccfb529b402e1e2d29de5a922f42c6ad2d3 [file] [log] [blame]
halcanary19a97202016-08-03 15:08:04 -07001# 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
Hal Canary32498f02019-02-04 15:36:31 -05006import("../../gn/skia.gni")
halcanary19a97202016-08-03 15:08:04 -07007import("../third_party.gni")
Hal Canary70041cf2019-01-28 21:33:21 -05008import("icu.gni")
halcanary19a97202016-08-03 15:08:04 -07009
Kevin Lubick867da4b2019-02-22 15:55:39 -050010declare_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"
Brian Osman66c26ac2018-12-07 13:43:57 -050022 } else {
Kevin Lubick867da4b2019-02-22 15:55:39 -050023 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") {
Hal Canary1b853232019-02-15 11:28:19 -050038 if (target_cpu == "wasm") {
Mike Kleina01c6b02020-04-01 13:47:34 -050039 _u_icu_version_major_num =
40 "65" # defined in source/common/unicode/uvernum.h
Kevin Lubick867da4b2019-02-22 15:55:39 -050041 script = "make_data_cpp.py"
Mike Kleina01c6b02020-04-01 13:47:34 -050042 inputs = [ "$data_dir/icudtl.dat" ]
43 outputs = [ data_assembly ]
Kevin Lubick867da4b2019-02-22 15:55:39 -050044 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 ]
Hal Canary1b853232019-02-15 11:28:19 -050049 } else {
Kevin Lubick867da4b2019-02-22 15:55:39 -050050 script = "../externals/icu/scripts/make_data_assembly.py"
Mike Kleina01c6b02020-04-01 13:47:34 -050051 inputs = [ "$data_dir/icudtl.dat" ]
52 outputs = [ "$data_assembly" ]
Kevin Lubick867da4b2019-02-22 15:55:39 -050053 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" ]
Florin Malita0c2add02019-02-06 02:28:24 +000059 }
60 }
Kevin Lubick867da4b2019-02-22 15:55:39 -050061 }
Florin Malita0c2add02019-02-06 02:28:24 +000062
Kevin Lubick867da4b2019-02-22 15:55:39 -050063 third_party("icu") {
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 "SK_USING_THIRD_PARTY_ICU",
72 ]
73 configs -= [ "//gn:no_rtti" ]
74 defines = [
75 # http://userguide.icu-project.org/howtouseicu
76 "U_COMMON_IMPLEMENTATION",
77 "U_STATIC_IMPLEMENTATION",
78 "U_ENABLE_DYLOAD=0",
79 "U_I18N_IMPLEMENTATION",
80 ]
81 if (target_cpu == "wasm") {
82 # Tell ICU that we are a 32 bit platform, otherwise,
83 # double-conversion-utils.h doesn't know how to operate.
84 defines += [ "__i386__" ]
85 }
86 sources = icu_sources
87 if (is_win) {
Mike Kleina01c6b02020-04-01 13:47:34 -050088 deps = [ ":icudata" ]
Kevin Lubick867da4b2019-02-22 15:55:39 -050089 public_defines += [
90 "U_NOEXCEPT=",
Florin Malita0c2add02019-02-06 02:28:24 +000091 "U_STATIC_IMPLEMENTATION",
Hal Canarye6cfe772019-01-25 12:50:35 -050092 ]
Kevin Lubick867da4b2019-02-22 15:55:39 -050093 libs = [ "Advapi32.lib" ]
94 sources += [
95 "../externals/icu/source/stubdata/stubdata.cpp",
96 "SkLoadICU.cpp",
97 ]
98 } else {
99 sources += [ "$data_assembly" ]
Mike Kleina01c6b02020-04-01 13:47:34 -0500100 deps = [ ":make_data_assembly" ]
Florin Malita0c2add02019-02-06 02:28:24 +0000101 }
Kevin Lubick867da4b2019-02-22 15:55:39 -0500102 }
Hal Canary689334c2019-02-22 11:25:25 -0500103
Kevin Lubick867da4b2019-02-22 15:55:39 -0500104 copy("icudata") {
Mike Kleina01c6b02020-04-01 13:47:34 -0500105 sources = [ "../externals/icu/common/icudtl.dat" ]
106 outputs = [ "$root_out_dir/icudtl.dat" ]
107 data = [ "$root_out_dir/icudtl.dat" ]
Mike Klein10d665d2016-11-01 11:46:10 -0400108 }
halcanary19a97202016-08-03 15:08:04 -0700109}