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
17package {
18    // See: http://go/android-license-faq
19    // A large-scale-change added 'default_applicable_licenses' to import
20    // all of the 'license_kinds' from "art_license"
21    // to get the below license kinds:
22    //   SPDX-license-identifier-Apache-2.0
23    default_applicable_licenses: ["art_license"],
24    default_team: "trendy_team_art_performance",
25}
26
27cc_defaults {
28    name: "libartbase_defaults",
29    defaults: ["art_defaults"],
30    host_supported: true,
31    srcs: [
32        "arch/instruction_set.cc",
33        "base/allocator.cc",
34        "base/arena_allocator.cc",
35        "base/arena_bit_vector.cc",
36        "base/bit_vector.cc",
37        "base/compiler_filter.cc",
38        "base/file_magic.cc",
39        "base/file_utils.cc",
40        "base/flags.cc",
41        "base/hex_dump.cc",
42        "base/logging.cc",
43        "base/malloc_arena_pool.cc",
44        "base/membarrier.cc",
45        "base/memfd.cc",
46        "base/memory_region.cc",
47        "base/mem_map.cc",
48        // "base/mem_map_fuchsia.cc", put in target when fuchsia supported by soong
49        "base/metrics/metrics_common.cc",
50        "base/os_linux.cc",
51        "base/pointer_size.cc",
52        "base/runtime_debug.cc",
53        "base/scoped_arena_allocator.cc",
54        "base/scoped_flock.cc",
55        "base/socket_peer_is_trusted.cc",
56        "base/time_utils.cc",
57        "base/unix_file/fd_file.cc",
58        "base/unix_file/random_access_file_utils.cc",
59        "base/utils.cc",
60        "base/zip_archive.cc",
61    ],
62    target: {
63        android: {
64            srcs: [
65                "base/globals_unix.cc",
66                "base/mem_map_unix.cc",
67            ],
68            static: {
69                cflags: ["-DART_STATIC_LIBARTBASE"],
70            },
71            static_libs: [
72                "libcap",
73                "libmodules-utils-build",
74                // ZipArchive support, the order matters here to get all symbols.
75                "libziparchive",
76            ],
77            whole_static_libs: ["libtinyxml2"],
78            shared_libs: [
79                "libz",
80                "liblog",
81                // For ashmem.
82                "libartpalette",
83                // For common macros.
84                "libbase",
85            ],
86            export_shared_lib_headers: ["libbase"], // ART's macros.h depends on libbase's macros.h.
87            export_static_lib_headers: [
88                "libcap",
89            ],
90        },
91        not_windows: {
92            srcs: [
93                "base/globals_unix.cc",
94                "base/mem_map_unix.cc",
95            ],
96            static: {
97                cflags: ["-DART_STATIC_LIBARTBASE"],
98            },
99            whole_static_libs: ["libtinyxml2"],
100            shared_libs: [
101                "libziparchive",
102                "libz",
103                "liblog",
104                // For ashmem.
105                "libartpalette",
106                // For common macros.
107                "libbase",
108            ],
109            export_shared_lib_headers: ["libbase"], // ART's macros.h depends on libbase's macros.h.
110        },
111        linux_glibc: {
112            static_libs: [
113                "libcap",
114            ],
115            export_static_lib_headers: [
116                "libcap",
117            ],
118        },
119        windows: {
120            srcs: [
121                "base/mem_map_windows.cc",
122            ],
123            static_libs: [
124                "libziparchive",
125                "libz",
126                "liblog",
127                // For ashmem.
128                "libartpalette",
129                // For common macros.
130                "libbase",
131            ],
132            whole_static_libs: ["libtinyxml2"],
133            export_static_lib_headers: ["libbase"], // ART's macros.h depends on libbase's macros.h.
134
135            cflags: ["-Wno-thread-safety"],
136        },
137        darwin: {
138            enabled: true, // for libdexfile.
139        },
140    },
141    generated_sources: ["art_libartbase_operator_srcs"],
142
143    export_include_dirs: ["."],
144}
145
146cc_defaults {
147    name: "libartbase_static_base_defaults",
148    whole_static_libs: [
149        "libbase",
150        "libartpalette",
151        "liblog",
152        "libz",
153        "libziparchive",
154    ],
155    target: {
156        android: {
157            whole_static_libs: [
158                "libcap",
159            ],
160        },
161        linux_glibc: {
162            whole_static_libs: [
163                "libcap",
164            ],
165        },
166    },
167}
168
169cc_defaults {
170    name: "libartbase_static_defaults",
171    defaults: ["libartbase_static_base_defaults"],
172    whole_static_libs: ["libartbase"],
173}
174
175cc_defaults {
176    name: "libartbased_static_defaults",
177    defaults: ["libartbase_static_base_defaults"],
178    whole_static_libs: ["libartbased"],
179}
180
181gensrcs {
182    name: "art_libartbase_operator_srcs",
183    cmd: "$(location generate_operator_out) art/libartbase $(in) > $(out)",
184    tools: ["generate_operator_out"],
185    srcs: [
186        "arch/instruction_set.h",
187        "base/allocator.h",
188        "base/unix_file/fd_file.h",
189    ],
190    output_extension: "operator_out.cc",
191}
192
193art_cc_library {
194    name: "libartbase",
195    defaults: [
196        "libartbase_defaults",
197        "libart_nativeunwind_defaults",
198    ],
199    visibility: [
200        // TODO(b/183483755): Please visibility checks when the prebuilt
201        // libartbase is present but not preferred, and the prebuilt libdexfile
202        // hence depends on the source instead.
203        // TODO(b/172480617): Alternatively, clean up when we no longer need to
204        // support both prebuilts and sources present simultaneously.
205        "//prebuilts/module_sdk/art/current/host-exports",
206        // TODO(b/133140750): Clean this up.
207        "//packages/modules/NetworkStack/tests:__subpackages__",
208    ],
209    apex_available: [
210        "com.android.art",
211        "com.android.art.debug",
212    ],
213
214    target: {
215        windows: {
216            // Control the enabled property here rather than in
217            // libartbase_defaults, to ensure it overrides properties inherited
218            // from other defaults.
219            enabled: true,
220            shared: {
221                enabled: false,
222            },
223        },
224    },
225    afdo: true,
226}
227
228art_cc_library {
229    name: "libartbased",
230    defaults: [
231        "art_debug_defaults",
232        "libartbase_defaults",
233    ],
234    apex_available: [
235        "com.android.art.debug",
236    ],
237
238    target: {
239        windows: {
240            // Control the enabled property here rather than in
241            // libartbase_defaults, to ensure it overrides properties inherited
242            // from other defaults, in particular any inherited via
243            // art_debug_defaults.
244            enabled: true,
245            shared: {
246                enabled: false,
247            },
248        },
249    },
250}
251
252art_cc_defaults {
253    name: "libartbase-art-gtest-defaults",
254    srcs: [
255        "base/common_art_test.cc",
256    ],
257    header_libs: [
258        "libnativehelper_header_only",
259        // Required for "base/mutex.h" in common_art_test.cc
260        "libart_headers",
261    ],
262    static: {
263        whole_static_libs: [
264            "libcap",
265        ],
266    },
267    shared: {
268        static_libs: [
269            "libcap",
270        ],
271    },
272}
273
274art_cc_library_static {
275    name: "libartbase-art-gtest",
276    defaults: [
277        "libart-gtest-defaults",
278        "libartbase-art-gtest-defaults",
279        "libartbase_static_defaults",
280        "libdexfile_static_defaults",
281    ],
282}
283
284art_cc_library_static {
285    name: "libartbased-art-gtest",
286    defaults: [
287        "art_debug_defaults",
288        "libart-gtest-defaults",
289        "libartbase-art-gtest-defaults",
290        "libartbased_static_defaults",
291        "libdexfiled_static_defaults",
292    ],
293}
294
295art_cc_library_static {
296    name: "libartbase-testing",
297    defaults: [
298        "art_defaults",
299    ],
300    host_supported: true,
301    srcs: [
302        "base/testing.cc",
303    ],
304    header_libs: [
305        "libbase_headers",
306        "art_libartbase_headers",
307    ],
308}
309
310art_cc_defaults {
311    name: "art_libartbase_tests_defaults",
312    tidy_timeout_srcs: [
313        "base/bit_utils_test.cc",
314        "base/intrusive_forward_list_test.cc",
315    ],
316    srcs: [
317        "arch/instruction_set_test.cc",
318        "base/arena_allocator_test.cc",
319        "base/bit_field_test.cc",
320        "base/bit_memory_region_test.cc",
321        "base/bit_string_test.cc",
322        "base/bit_struct_test.cc",
323        "base/bit_table_test.cc",
324        "base/bit_utils_test.cc",
325        "base/bit_vector_test.cc",
326        "base/compiler_filter_test.cc",
327        "base/file_utils_test.cc",
328        "base/flags_test.cc",
329        "base/hash_map_test.cc",
330        "base/hash_set_test.cc",
331        "base/hex_dump_test.cc",
332        "base/histogram_test.cc",
333        "base/indenter_test.cc",
334        "base/intrusive_forward_list_test.cc",
335        "base/leb128_test.cc",
336        "base/logging_test.cc",
337        "base/memfd_test.cc",
338        "base/membarrier_test.cc",
339        "base/memory_region_test.cc",
340        "base/mem_map_test.cc",
341        "base/metrics/metrics_test.cc",
342        "base/scoped_flock_test.cc",
343        "base/time_utils_test.cc",
344        "base/transform_array_ref_test.cc",
345        "base/transform_iterator_test.cc",
346        "base/unix_file/fd_file_test.cc",
347        "base/utils_test.cc",
348        "base/variant_map_test.cc",
349        "base/zip_archive_test.cc",
350    ],
351    static_libs: [
352        "libgmock",
353    ],
354}
355
356// Version of ART gtest `art_libartbase_tests` bundled with the ART APEX on target.
357// TODO(b/192274705): Remove this module when the migration to standalone ART gtests is complete.
358art_cc_test {
359    name: "art_libartbase_tests",
360    defaults: [
361        "art_gtest_defaults",
362        "art_libartbase_tests_defaults",
363    ],
364}
365
366// Standalone version of ART gtest `art_libartbase_tests`, not bundled with the ART APEX on target.
367art_cc_test {
368    name: "art_standalone_libartbase_tests",
369    defaults: [
370        "art_standalone_gtest_defaults",
371        "art_libartbase_tests_defaults",
372    ],
373    data: [":generate-boot-image"],
374    test_config_template: ":art-gtests-target-standalone-with-boot-image-template",
375}
376
377cc_library_headers {
378    name: "art_libartbase_headers",
379    defaults: ["art_defaults"],
380    host_supported: true,
381    export_include_dirs: ["."],
382    shared_libs: ["libbase"],
383    export_shared_lib_headers: ["libbase"],
384
385    whole_static_libs: ["libtinyxml2"],
386
387    apex_available: [
388        "com.android.art",
389        "com.android.art.debug",
390    ],
391}
392