• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1//
2// Copyright (C) 2014 The Android Open Source Project
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8//      http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//
16
17package {
18    default_visibility: ["//visibility:private"],
19    // See: http://go/android-license-faq
20    // A large-scale-change added 'default_applicable_licenses' to import
21    // all of the 'license_kinds' from "external_icu_license"
22    // to get the below license kinds:
23    //   SPDX-license-identifier-Apache-2.0
24    //   SPDX-license-identifier-BSD
25    //   SPDX-license-identifier-ICU
26    //   SPDX-license-identifier-MIT
27    //   SPDX-license-identifier-Unicode-DFS
28    //   legacy_unencumbered
29    default_applicable_licenses: ["external_icu_license"],
30}
31
32java_defaults {
33    name: "icu4j-defaults",
34    host_supported: true,
35    hostdex: true,
36
37    // Use the same Java language version in the Android build configuration as used
38    // in main/shared/build/common.properties for the ICU4J build configuration.
39    java_version: "1.7",
40}
41
42java_library {
43    name: "icu4j",
44    visibility: [
45        "//bootable/recovery/tools/image_generator",
46        "//external/icu/tools/srcgen",
47        "//external/jimfs/jimfs",
48        "//external/robolectric-shadows/robolectric",
49        "//external/robolectric-shadows/shadows/framework",
50        "//system/timezone/input_tools/android/telephonylookup_generator",
51        "//system/timezone/input_tools/android/tzlookup_generator",
52    ],
53    defaults: ["icu4j-defaults"],
54
55    srcs: ["main/classes/**/*.java"],
56    java_resource_dirs: ["main/classes/*/src"],
57
58    // User-supplied locale service providers (using the java.text.spi or
59    // java.util.spi mechanisms) are not supported in Android:
60    //
61    // http://developer.android.com/reference/java/util/Locale.html
62    exclude_srcs: ["main/classes/localespi/**/*.java"],
63    exclude_java_resource_dirs: ["main/classes/localespi/src"],
64
65    static_libs: [
66        "icu4j-icudata",
67        "icu4j-icutzdata",
68    ],
69}
70
71// Small static library used by TwilightService in the system server. To avoid @CorePlaformApi,
72// the system server doesn't use CalendarAstronomer in android.icu.
73// Don't link this in boot classpath or Zygote to avoid class collision with the
74// com.ibm.icu.impl.CalendarAstronomer in the app classloader.
75java_library_static {
76    name: "icu4j_calendar_astronomer",
77    host_supported: false,
78    srcs: ["main/classes/core/src/com/ibm/icu/impl/CalendarAstronomer.java"],
79    visibility: ["//frameworks/base/services/core"],
80}
81
82java_test {
83    name: "icu4j-tests",
84    defaults: ["icu4j-defaults"],
85
86    srcs: [
87        "main/tests/**/*.java",
88        "tools/misc/src/com/ibm/icu/dev/tool/locale/*.java",
89    ],
90    java_resource_dirs: ["main/tests/*/src"],
91
92    exclude_srcs: ["main/tests/localespi/**/*.java"],
93    exclude_java_resource_dirs: ["main/tests/localespi/src"],
94
95    static_libs: [
96        "icu4j",
97        "icu4j-testdata",
98        "junit-params",
99    ],
100}
101
102java_import {
103    name: "icu4j-icudata",
104    host_supported: true,
105    jars: ["main/shared/data/icudata.jar"],
106}
107
108java_import {
109    name: "icu4j-icutzdata",
110    host_supported: true,
111    jars: ["main/shared/data/icutzdata.jar"],
112}
113
114java_import {
115    name: "icu4j-testdata",
116    host_supported: true,
117    jars: ["main/shared/data/testdata.jar"],
118}
119
120// LayoutLib (frameworks/layoutlib) and robolectric need JarJar'd versions of
121// the icudata and icutzdata, so add rules for it.
122java_library {
123    name: "icu4j-icudata-jarjar",
124    visibility: [
125        "//external/robolectric-shadows",
126        "//frameworks/layoutlib",
127    ],
128    defaults: ["icu4j-defaults"],
129    static_libs: ["icu4j-icudata"],
130    jarjar_rules: "liblayout-jarjar-rules.txt",
131}
132
133java_library {
134    name: "icu4j-icutzdata-jarjar",
135    visibility: [
136        "//external/robolectric-shadows",
137        "//frameworks/layoutlib",
138    ],
139    defaults: ["icu4j-defaults"],
140    static_libs: ["icu4j-icutzdata"],
141    jarjar_rules: "liblayout-jarjar-rules.txt",
142}
143
144// Compatibility alias until references to icu4j-host are removed
145//
146// When converting .mk files to .bp files do not change the visibility of this
147// module, instead replace usages of this with icu4j
148java_library_host {
149    name: "icu4j-host",
150    static_libs: ["icu4j"],
151}
152
153// Rules to generate android_icu4j files during build time
154// The following rules are used in the downstream branches master-icu-dev only,
155// but NOT used in AOSP.
156generate_script_srcs = [
157    "main/**/*",
158    "samples/**/*",
159]
160generate_script_tools = [
161    "android_icu4j_srcgen_binary",
162    "soong_zip",
163]
164generate_script_tool_files = [
165    ":generate_android_icu4j_script",
166]
167// ANDROID_BUILD_TOP is needed to be set for generate_android_icu4j.sh
168generate_script_common_cmd = "export ANDROID_BUILD_TOP=$$(pwd) && " +
169    "$(location :generate_android_icu4j_script) " +
170    "--no-doc-patch " +
171    "--gen $(genDir) " +
172    "--srcgen-tool $(location android_icu4j_srcgen_binary)"
173
174genrule {
175    name: "generated_android_icu4j_src_files",
176    enabled: false, // http://b/117312606
177    srcs: generate_script_srcs,
178    tools: generate_script_tools,
179    tool_files: generate_script_tool_files,
180    out: ["generated_android_icu4j.srcjar"],
181    cmd: generate_script_common_cmd +
182        "&& $(location soong_zip) -o $(out) -C $(genDir)/android_icu4j/src/main/java " +
183        "-D $(genDir)/android_icu4j/src/main/java",
184}
185
186java_genrule {
187    name: "generated_android_icu4j_resources",
188    enabled: false, // http://b/117312606
189    host_supported: true,
190    srcs: generate_script_srcs,
191    tools: generate_script_tools,
192    tool_files: generate_script_tool_files,
193    out: ["generated_android_icu4j_resources.jar"],
194    cmd: generate_script_common_cmd +
195        "&& $(location soong_zip) -o $(out) -C $(genDir)/android_icu4j/resources " +
196        "-D $(genDir)/android_icu4j/resources",
197}
198
199genrule {
200    name: "generated_android_icu4j_test_files",
201    enabled: false, // http://b/117312606
202    srcs: generate_script_srcs,
203    tools: generate_script_tools,
204    tool_files: generate_script_tool_files,
205    out: ["generated_android_icu4j_test.srcjar"],
206    cmd: generate_script_common_cmd +
207        "&& find $(genDir)/android_icu4j/src/main/tests -type f -not -name \"*.java\" -exec rm {} \\; " +
208        "&& $(location soong_zip) -o $(out) -C $(genDir)/android_icu4j/src/main/tests " +
209        "-D $(genDir)/android_icu4j/src/main/tests",
210}
211
212java_genrule {
213    name: "generated_android_icu4j_test_resources",
214    enabled: false, // http://b/117312606
215    host_supported: true,
216    srcs: generate_script_srcs,
217    tools: generate_script_tools,
218    tool_files: generate_script_tool_files,
219    out: ["generated_android_icu4j_test_resources.jar"],
220    cmd: generate_script_common_cmd +
221        "&& find $(genDir)/android_icu4j/src/main/tests -type f -name \"*.java\" -exec rm {} \\; " +
222        "&& $(location soong_zip) -o $(out) -C $(genDir)/android_icu4j/src/main/tests " +
223        "-D $(genDir)/android_icu4j/src/main/tests",
224}
225