xref: /aosp_15_r20/external/icu/icu4c/source/common/Android.bp (revision 0e209d3975ff4a8c132096b14b0e9364a753506e)
1// Copyright (C) 2008 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//
16// Common definitions.
17//
18
19package {
20    default_team: "trendy_team_java_core_libraries",
21    // See: http://go/android-license-faq
22    // A large-scale-change added 'default_applicable_licenses' to import
23    // all of the 'license_kinds' from "external_icu_icu4c_license"
24    // to get the below license kinds:
25    //   SPDX-license-identifier-Unicode-DFS
26    default_applicable_licenses: ["external_icu_icu4c_license"],
27}
28
29cc_defaults {
30    name: "libicuuc_defaults",
31    defaults: ["icu4c_defaults"],
32    srcs: [
33        "*.cpp",
34    ],
35    // We deliberately do not set -DICU_DATA_DIR: ICU4C is configured on Android
36    // using udata_setCommonData.
37    cflags: [
38        "-D_REENTRANT",
39        "-DU_COMMON_IMPLEMENTATION",
40
41        "-O3",
42        "-fvisibility=hidden",
43
44        "-Wno-missing-field-initializers",
45        "-Wno-sign-compare",
46    ],
47    rtti: true,
48    target: {
49        android: {
50            cflags: [
51                "-DPIC",
52                "-fPIC",
53            ],
54            static_libs: [
55                "libandroidicuinit", // Required to set the data files in libicuuc.
56                "libicuuc_stubdata",
57            ],
58            shared_libs: [
59                "libbase", // required by libandroidicuinit
60                "liblog", // required by libandroidicuinit
61            ],
62        },
63        not_windows: {
64            static_libs: [
65                "libicuuc_stubdata",
66            ],
67            // linkerconfig links libicuuc statically on host, but we need to avoid exposing
68            // libandroidicuinit independently to other modules. Thus, we links the entire
69            // libandroidicuinit into libicuuc on host.
70            whole_static_libs: [
71                "libandroidicuinit", // Required to set the data files in libicuuc in ART testing.
72            ],
73            required: ["icu-data_host_i18n_apex"],
74        },
75        windows: {
76            // Windows requires importing data as a DLL when building with U_COMMON_IMPLEMENTATION
77            shared_libs: ["libicuuc_stubdata"],
78        },
79    },
80}
81
82cc_library_headers {
83    name: "libicuuc_headers",
84    host_supported: true,
85    native_bridge_supported: true,
86    header_libs: ["icu4c_extra_headers"],
87    export_header_lib_headers: ["icu4c_extra_headers"],
88    export_include_dirs: ["."],
89    apex_available: [
90        "com.android.i18n",
91    ],
92    target: {
93        windows: {
94            enabled: true,
95        },
96    },
97}
98
99//
100// Build for the host and target.
101// Allow static builds for host so that they can be statically
102// linked into libandroid_runtime. That enables libandroid_runtime to
103// be shipped on desktops as one file which saves space and complexity.
104cc_library {
105    name: "libicuuc",
106    host_supported: true,
107    unique_host_soname: true,
108    native_bridge_supported: true,
109    defaults: ["libicuuc_defaults"],
110    apex_available: [
111        "com.android.i18n",
112    ],
113    target: {
114        android: {
115            static: {
116                enabled: false,
117            },
118        },
119    },
120    header_libs: ["libicuuc_headers"],
121    export_header_lib_headers: ["libicuuc_headers"],
122}
123
124cc_library_shared {
125    name: "libicuuc_cts_stub",
126    defaults: ["libicuuc_defaults"],
127    host_supported: false,
128    installable: false,
129    stem: "libicuuc",
130    header_libs: ["libicuuc_headers"],
131    visibility: ["//external/icu:__subpackages__"],
132}
133