xref: /aosp_15_r20/external/icu/libandroidicu/Android.bp (revision 0e209d3975ff4a8c132096b14b0e9364a753506e)
1// Copyright (C) 2018 The Android Open Source Project
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//      http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15// A shared library for use on Android by frameworks and other code outside
16// of the ART mainline module. It provides a subset of ICU APIs, some
17// Android extensions and stable symbols. Most Android target code should
18// depend on this library.
19//
20// With the exception of a few special cases like host apex build targets,
21// host binaries should use libicuuc + libicui18n directly.
22package {
23    default_team: "trendy_team_java_core_libraries",
24    // See: http://go/android-license-faq
25    // A large-scale-change added 'default_applicable_licenses' to import
26    // all of the 'license_kinds' from "external_icu_license"
27    // to get the below license kinds:
28    //   SPDX-license-identifier-Apache-2.0
29    //   SPDX-license-identifier-Unicode-DFS
30    default_applicable_licenses: ["external_icu_license"],
31    default_visibility: ["//external/icu:__subpackages__"],
32}
33
34cc_library_shared {
35    name: "libandroidicu",
36
37    // All code is imported via libandroidicu_static.
38    srcs: [],
39    // host_supported is required for some cases, e.g. host apex. This library
40    // is not intended for general host use.  Please refer to
41    // external/icu/build/icu.go for the full allowlist.
42    host_supported: true,
43    native_bridge_supported: true,
44    unique_host_soname: true,
45    apex_available: [
46        "com.android.i18n",
47    ],
48
49    // The implementation of libandroidicu depends on libicuuc and and libicui18n,
50    // but we need to export the headers in include/.
51    //
52    // However, include/unicode has a copy of a subset of header files
53    // as in libicuuc and libicui18n. We can't build C/C++ codes against
54    // both set of headers, since the headers have the same relative paths,
55    // and the compiler will find it ambiguous.
56    //
57    // Instead, we build the implementation of the shim libaray
58    // as a static library aganist libicuuc and libicui18n first,
59    // and export the headers in include/.
60    whole_static_libs: ["libandroidicu_static"],
61    shared_libs: [
62        "libbase",
63        "libicuuc",
64        "libicui18n",
65        "liblog",
66    ],
67    header_libs: ["libandroidicu_headers"],
68    export_header_lib_headers: ["libandroidicu_headers"],
69    stubs: {
70        symbol_file: "libandroidicu.map.txt",
71        versions: [
72            "1",
73        ],
74    },
75    cflags: [
76        "-Wall",
77        "-Werror",
78    ],
79    target: {
80        android: {
81            cflags: [
82                "-DANDROID_LINK_SHARED_ICU4C",
83            ],
84            version_script: "libandroidicu.map.txt",
85        },
86        windows: {
87            enabled: true,
88        },
89    },
90    // Only add a new path below if your project needs UConverter or URegularExpression from ICU.
91    visibility: [
92        "//build/orchestrator/apis",
93        "//external/icu:__subpackages__",
94        "//packages/modules/RuntimeI18n:__subpackages__",
95        // The following dependencies can't use libicu instead, because it depends on UConverter
96        // or URegularExpression or statically linking libsqlite / libxml2.
97        "//external/libxml2",
98        "//external/robolectric/nativeruntime/external/sqlite/android",
99        "//external/sqlite:__subpackages__",
100        "//frameworks/av/media/libmedia",
101        "//frameworks/base/ravenwood:__subpackages__",
102    ],
103}
104
105cc_library_headers {
106    name: "libandroidicu_headers",
107    host_supported: true,
108    native_bridge_supported: true,
109    apex_available: [
110        "com.android.art",
111        "com.android.art.debug",
112        "com.android.i18n",
113    ],
114
115    // include/unicode/: Includes modified C headers from ICU4C,
116    //                   but excludes C++ headers.
117    // include/uconfig_local.h: local configuration specific for libandroidicu
118    export_include_dirs: ["include"],
119    target: {
120        windows: {
121            enabled: true,
122        },
123    },
124}
125
126// TODO: http://b/120776993 Testing for libandroidicu
127