1//
2// Copyright (C) 2011 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
17cc_defaults {
18    name: "libartbase_defaults",
19    defaults: ["art_defaults"],
20    host_supported: true,
21    srcs: [
22        "arch/instruction_set.cc",
23        "base/allocator.cc",
24        "base/arena_allocator.cc",
25        "base/arena_bit_vector.cc",
26        "base/bit_vector.cc",
27        "base/enums.cc",
28        "base/file_magic.cc",
29        "base/file_utils.cc",
30        "base/hex_dump.cc",
31        "base/hiddenapi_flags.cc",
32        "base/logging.cc",
33        "base/malloc_arena_pool.cc",
34        "base/membarrier.cc",
35        "base/memfd.cc",
36        "base/memory_region.cc",
37        "base/mem_map.cc",
38        // "base/mem_map_fuchsia.cc", put in target when fuchsia supported by soong
39        "base/os_linux.cc",
40        "base/runtime_debug.cc",
41        "base/safe_copy.cc",
42        "base/scoped_arena_allocator.cc",
43        "base/scoped_flock.cc",
44        "base/socket_peer_is_trusted.cc",
45        "base/time_utils.cc",
46        "base/unix_file/fd_file.cc",
47        "base/unix_file/random_access_file_utils.cc",
48        "base/utils.cc",
49        "base/zip_archive.cc",
50    ],
51    target: {
52        android: {
53            srcs: [
54                "base/mem_map_unix.cc",
55            ],
56            static_libs: [
57                // ZipArchive support, the order matters here to get all symbols.
58                "libziparchive",
59                "libz",
60            ],
61            shared_libs: [
62                "liblog",
63                // For ashmem.
64                "libartpalette",
65                // For common macros.
66                "libbase",
67            ],
68            export_shared_lib_headers: ["libbase"],
69            // Exclude the version script from Darwin host since it's not
70            // supported by the linker there. That means ASan checks on Darwin
71            // might trigger ODR violations.
72            version_script: "libartbase.map",
73        },
74        not_windows: {
75            srcs: [
76                "base/globals_unix.cc",
77                "base/mem_map_unix.cc",
78            ],
79            shared_libs: [
80                "libziparchive",
81                "libz",
82                "liblog",
83                // For ashmem.
84                "libartpalette",
85                // For common macros.
86                "libbase",
87            ],
88            export_shared_lib_headers: ["libbase"],
89        },
90        linux_glibc: {
91            version_script: "libartbase.map",
92        },
93        windows: {
94            version_script: "libartbase.map",
95            srcs: [
96                "base/mem_map_windows.cc",
97            ],
98            static_libs: [
99                "libziparchive",
100                "libz",
101                "liblog",
102                // For ashmem.
103                "libartpalette",
104                // For common macros.
105                "libbase",
106            ],
107            export_static_lib_headers: ["libbase"],
108            cflags: ["-Wno-thread-safety"],
109        },
110        darwin: {
111            enabled: true, // for libdexfile.
112        },
113    },
114    generated_sources: ["art_libartbase_operator_srcs"],
115    cflags: ["-DBUILDING_LIBART=1"],
116
117    // Utilities used by various ART libs and tools are linked in statically
118    // here to avoid shared lib dependencies outside the ART APEX. No target
119    // there should depend on these separately.
120    whole_static_libs: [
121        "liblz4",
122        "liblzma",
123    ],
124
125    export_include_dirs: ["."],
126    // ART's macros.h depends on libbase's macros.h.
127    // Note: runtime_options.h depends on cmdline. But we don't really want to export this
128    //       generically. dex2oat takes care of it itself.
129}
130
131cc_defaults {
132    name: "libartbase_static_base_defaults",
133    static_libs: [
134        "libbase",
135        "libartpalette",
136        "liblog",
137        "libz",
138        "libziparchive",
139    ],
140}
141
142cc_defaults {
143    name: "libartbase_static_defaults",
144    defaults: ["libartbase_static_base_defaults"],
145    static_libs: ["libartbase"],
146}
147
148cc_defaults {
149    name: "libartbased_static_defaults",
150    defaults: ["libartbase_static_base_defaults"],
151    static_libs: ["libartbased"],
152}
153
154gensrcs {
155    name: "art_libartbase_operator_srcs",
156    cmd: "$(location generate_operator_out) art/libartbase $(in) > $(out)",
157    tools: ["generate_operator_out"],
158    srcs: [
159        "arch/instruction_set.h",
160        "base/allocator.h",
161        "base/unix_file/fd_file.h",
162    ],
163    output_extension: "operator_out.cc",
164}
165
166art_cc_library {
167    name: "libartbase",
168    defaults: [
169        "libartbase_defaults",
170        "libart_nativeunwind_defaults",
171    ],
172    visibility: [
173        // TODO(b/133140750): Clean this up.
174        "//packages/modules/NetworkStack/tests:__subpackages__",
175    ],
176    apex_available: [
177        "com.android.art.release",
178        "com.android.art.debug",
179    ],
180
181    shared_libs: [
182        "libbase",
183        "libziparchive",
184    ],
185    export_shared_lib_headers: ["libbase"],
186    target: {
187        windows: {
188            enabled: true,
189            shared: {
190                enabled: false,
191            },
192        },
193    },
194}
195
196art_cc_library {
197    name: "libartbased",
198    defaults: [
199        "art_debug_defaults",
200        "libartbase_defaults",
201    ],
202    apex_available: [
203        "com.android.art.debug",
204    ],
205    shared_libs: [
206        "libbase",
207        "libziparchive",
208    ],
209    export_shared_lib_headers: ["libbase"],
210    target: {
211        windows: {
212            enabled: true,
213            shared: {
214                enabled: false,
215            },
216        },
217    },
218}
219
220art_cc_library {
221    name: "libartbase-art-gtest",
222    defaults: ["libart-gtest-defaults"],
223    srcs: [
224        "base/common_art_test.cc",
225    ],
226    shared_libs: [
227        "libartbased",
228        "libdexfiled",
229        "libbase",
230        "libbacktrace",
231    ],
232    header_libs: [
233        "libnativehelper_header_only",
234    ],
235    static: {
236        whole_static_libs: ["libc++fs"],
237    },
238    shared: {
239        static_libs: ["libc++fs"],
240    },
241}
242
243art_cc_test {
244    name: "art_libartbase_tests",
245    defaults: [
246        "art_gtest_defaults",
247    ],
248    srcs: [
249        "arch/instruction_set_test.cc",
250        "base/arena_allocator_test.cc",
251        "base/bit_field_test.cc",
252        "base/bit_memory_region_test.cc",
253        "base/bit_string_test.cc",
254        "base/bit_struct_test.cc",
255        "base/bit_table_test.cc",
256        "base/bit_utils_test.cc",
257        "base/bit_vector_test.cc",
258        "base/file_utils_test.cc",
259        "base/hash_set_test.cc",
260        "base/hex_dump_test.cc",
261        "base/histogram_test.cc",
262        "base/indenter_test.cc",
263        "base/intrusive_forward_list_test.cc",
264        "base/leb128_test.cc",
265        "base/logging_test.cc",
266        "base/memfd_test.cc",
267        "base/membarrier_test.cc",
268        "base/memory_region_test.cc",
269        "base/mem_map_test.cc",
270        "base/safe_copy_test.cc",
271        "base/scoped_flock_test.cc",
272        "base/time_utils_test.cc",
273        "base/transform_array_ref_test.cc",
274        "base/transform_iterator_test.cc",
275        "base/unix_file/fd_file_test.cc",
276        "base/utils_test.cc",
277        "base/variant_map_test.cc",
278        "base/zip_archive_test.cc",
279    ],
280    shared_libs: [
281        "libbase",
282    ],
283}
284
285cc_library_headers {
286    name: "art_libartbase_headers",
287    host_supported: true,
288    export_include_dirs: ["."],
289    shared_libs: ["libbase"],
290    export_shared_lib_headers: ["libbase"],
291
292    apex_available: [
293        "com.android.art.debug",
294        "com.android.art.release",
295    ],
296}
297