blob: 73cdd1e89c14a0d9bb7648eaef63ff3895b75172 [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
6declare_args() {
Mike Kleine459afd2017-03-03 09:21:30 -05007 skia_use_system_icu = is_official_build
Hal Canarye6cfe772019-01-25 12:50:35 -05008 skia_icu_use_prebuilt_data = true
halcanary19a97202016-08-03 15:08:04 -07009}
10
Hal Canary32498f02019-02-04 15:36:31 -050011import("../../gn/skia.gni")
halcanary19a97202016-08-03 15:08:04 -070012import("../third_party.gni")
Hal Canary70041cf2019-01-28 21:33:21 -050013import("icu.gni")
halcanary19a97202016-08-03 15:08:04 -070014
Hal Canary32498f02019-02-04 15:36:31 -050015if (skia_use_icu) {
16 if (skia_use_system_icu) {
17 system("icu") {
18 libs = [ "icuuc" ]
19 defines = [ "U_USING_ICU_NAMESPACE=0" ]
20 }
Brian Osman66c26ac2018-12-07 13:43:57 -050021 } else {
Hal Canarye6cfe772019-01-25 12:50:35 -050022 if (target_cpu == "wasm") {
23 _data = "$target_gen_dir/icudtl_dat.cpp"
24 _data_script = "make_data_assembly.py"
25 } else if (is_win) {
26 _data = "$target_gen_dir/icudtl_dat.obj"
27 _data_script = "make_data_obj_win.py"
Hal Canary0e07ad72018-02-08 13:06:56 -050028 } else {
Hal Canarye6cfe772019-01-25 12:50:35 -050029 _data = "$target_gen_dir/icudtl_dat.S"
30 _data_script = "make_data_assembly.py"
Hal Canary0e07ad72018-02-08 13:06:56 -050031 }
Hal Canary32498f02019-02-04 15:36:31 -050032 third_party("icu") {
33 public_include_dirs = [
Hal Canarye6cfe772019-01-25 12:50:35 -050034 "../externals/icu/icu4c/source/common",
35 "../externals/icu/icu4c/source/i18n",
Hal Canary32498f02019-02-04 15:36:31 -050036 ".",
37 ]
38 public_defines = [
39 "U_USING_ICU_NAMESPACE=0",
Hal Canarye6cfe772019-01-25 12:50:35 -050040 "U_STATIC_IMPLEMENTATION",
Hal Canary32498f02019-02-04 15:36:31 -050041 "SK_USING_THIRD_PARTY_ICU",
42 ]
43 configs -= [ "//gn:no_rtti" ]
Hal Canarye6cfe772019-01-25 12:50:35 -050044 deps = [
45 ":assemble_data",
Hal Canary32498f02019-02-04 15:36:31 -050046 ]
47 sources = icu_sources
Hal Canarye6cfe772019-01-25 12:50:35 -050048 sources += [ _data ]
49 defines = [
50 # http://userguide.icu-project.org/howtouseicu
51 "U_ENABLE_DYLOAD=0",
52 "U_NOEXCEPT=",
53 "U_COMMON_IMPLEMENTATION",
54 "U_I18N_IMPLEMENTATION",
55 ]
Hal Canary32498f02019-02-04 15:36:31 -050056 if (is_win) {
Hal Canarye6cfe772019-01-25 12:50:35 -050057 defines += [ "U_PLATFORM_HAS_WINUWP_API=1" ]
Hal Canary32498f02019-02-04 15:36:31 -050058 }
59 }
Hal Canarye6cfe772019-01-25 12:50:35 -050060 _dat_file = "$target_gen_dir/icu.dat"
61 action("assemble_data") {
62 script = _data_script
63 sources = [
64 _dat_file,
65 ]
66 outputs = [
67 _data,
68 ]
69 args = [
70 icu_dtname,
71 current_os,
72 target_cpu,
73 rebase_path(_dat_file, root_build_dir),
74 rebase_path(_data, root_build_dir),
75 ]
76 deps = [
77 ":get_data",
78 ]
79 }
80 if (skia_icu_use_prebuilt_data) {
81 action("get_data") {
82 script = "download_file.py"
Hal Canary32498f02019-02-04 15:36:31 -050083 outputs = [
Hal Canarye6cfe772019-01-25 12:50:35 -050084 _dat_file,
Hal Canary32498f02019-02-04 15:36:31 -050085 ]
Hal Canarye6cfe772019-01-25 12:50:35 -050086 args = [
87 "https://storage.googleapis.com/$icu_dat_bucket/$icu_dat_md5",
88 icu_dat_md5,
89 rebase_path(_dat_file, root_build_dir),
90 ]
91 }
92 } else {
93 action("get_data") {
94 script = "build_icu_data_file.py"
95 outputs = [
96 _dat_file,
97 ]
98 args = [
99 rebase_path("../externals/icu", root_build_dir),
100 rebase_path(_dat_file, root_build_dir),
101 ]
Hal Canary32498f02019-02-04 15:36:31 -0500102 }
Hal Canary0e07ad72018-02-08 13:06:56 -0500103 }
Mike Klein10d665d2016-11-01 11:46:10 -0400104 }
halcanary19a97202016-08-03 15:08:04 -0700105}