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} 25 26cc_defaults { 27 name: "libdexfile_defaults", 28 defaults: ["art_defaults"], 29 host_supported: true, 30 srcs: [ 31 "dex/art_dex_file_loader.cc", 32 "dex/compact_dex_file.cc", 33 "dex/compact_offset_table.cc", 34 "dex/descriptors_names.cc", 35 "dex/dex_file.cc", 36 "dex/dex_file_exception_helpers.cc", 37 "dex/dex_file_layout.cc", 38 "dex/dex_file_loader.cc", 39 "dex/dex_file_tracking_registrar.cc", 40 "dex/dex_file_verifier.cc", 41 "dex/dex_instruction.cc", 42 "dex/modifiers.cc", 43 "dex/primitive.cc", 44 "dex/signature.cc", 45 "dex/standard_dex_file.cc", 46 "dex/type_lookup_table.cc", 47 "dex/utf.cc", 48 ], 49 header_libs: [ 50 "jni_headers", 51 "libdexfile_external_headers", 52 ], 53 export_header_lib_headers: [ 54 "jni_headers", 55 "libdexfile_external_headers", 56 ], 57 target: { 58 android: { 59 srcs: [ 60 "external/dex_file_ext.cc", 61 ], 62 static_libs: [ 63 "libziparchive", 64 ], 65 shared_libs: [ 66 // libz provides a stub from platform, shouldn't be statically linked 67 "libz", 68 // For MemMap. 69 "libartpalette", 70 "liblog", 71 // For common macros. 72 "libbase", 73 ], 74 export_shared_lib_headers: [ 75 "libbase", 76 ], 77 }, 78 not_windows: { 79 srcs: [ 80 "external/dex_file_ext.cc", 81 ], 82 shared_libs: [ 83 "libziparchive", 84 "libz", 85 // For MemMap. 86 "libartpalette", 87 "liblog", 88 // For common macros. 89 "libbase", 90 ], 91 export_shared_lib_headers: [ 92 "libbase", 93 ], 94 }, 95 windows: { 96 static_libs: [ 97 "libziparchive", 98 "libz", 99 // For MemMap. 100 "libartpalette", 101 "liblog", 102 // For common macros. 103 "libbase", 104 ], 105 export_static_lib_headers: [ 106 "libbase", 107 ], 108 cflags: ["-Wno-thread-safety"], 109 }, 110 darwin: { 111 enabled: true, 112 }, 113 }, 114 generated_sources: ["dexfile_operator_srcs"], 115 export_include_dirs: ["."], 116} 117 118cc_defaults { 119 name: "libdexfile_static_base_defaults", 120 whole_static_libs: [ 121 "libbase", 122 "liblog", 123 "libz", 124 "libziparchive", 125 ], 126} 127 128cc_defaults { 129 name: "libdexfile_static_defaults", 130 defaults: [ 131 "libartbase_static_defaults", 132 "libdexfile_static_base_defaults", 133 ], 134 defaults_visibility: [ 135 "//art:__subpackages__", 136 ], 137 whole_static_libs: ["libdexfile"], 138} 139 140cc_defaults { 141 name: "libdexfiled_static_defaults", 142 defaults: [ 143 "libartbased_static_defaults", 144 "libdexfile_static_base_defaults", 145 ], 146 whole_static_libs: ["libdexfiled"], 147} 148 149gensrcs { 150 name: "dexfile_operator_srcs", 151 cmd: "$(location generate_operator_out) art/libdexfile $(in) > $(out)", 152 tools: ["generate_operator_out"], 153 srcs: [ 154 "dex/dex_file.h", 155 "dex/dex_file_layout.h", 156 "dex/dex_instruction.h", 157 "dex/dex_instruction_utils.h", 158 "dex/invoke_type.h", 159 ], 160 output_extension: "operator_out.cc", 161} 162 163art_cc_library { 164 name: "libdexfile", 165 visibility: [ 166 // Allow libdexfile_support users to list this as a runtime_libs 167 // dependency - see comment for libdexfile_support. It shouldn't be used 168 // for any other purpose. 169 "//external/perfetto", 170 "//system/core/debuggerd", 171 "//system/extras/simpleperf", 172 "//system/unwinding/libunwindstack", 173 ], 174 defaults: [ 175 "libdexfile_defaults", 176 "libart_nativeunwind_defaults", 177 ], 178 target: { 179 android: { 180 shared_libs: [ 181 "libartbase", 182 ], 183 export_shared_lib_headers: [ 184 "libartbase", 185 ], 186 }, 187 not_windows: { 188 shared_libs: [ 189 "libartbase", 190 ], 191 export_shared_lib_headers: [ 192 "libartbase", 193 ], 194 }, 195 windows: { 196 enabled: true, 197 shared: { 198 enabled: false, 199 }, 200 static_libs: [ 201 "libartbase", 202 ], 203 export_static_lib_headers: [ 204 "libartbase", 205 ], 206 }, 207 }, 208 apex_available: [ 209 "com.android.art", 210 "com.android.art.debug", 211 ], 212 stubs: { 213 symbol_file: "libdexfile.map.txt", 214 versions: ["1"], 215 }, 216} 217 218art_cc_library { 219 name: "libdexfiled", 220 defaults: [ 221 "art_debug_defaults", 222 "libdexfile_defaults", 223 ], 224 target: { 225 android: { 226 shared_libs: [ 227 "libartbased", 228 ], 229 export_shared_lib_headers: [ 230 "libartbased", 231 ], 232 }, 233 not_windows: { 234 shared_libs: [ 235 "libartbased", 236 ], 237 export_shared_lib_headers: [ 238 "libartbased", 239 ], 240 }, 241 windows: { 242 enabled: true, 243 shared: { 244 enabled: false, 245 }, 246 static_libs: [ 247 "libartbased", 248 ], 249 export_static_lib_headers: [ 250 "libartbased", 251 ], 252 }, 253 }, 254 apex_available: [ 255 "com.android.art.debug", 256 // TODO(b/183882457): This lib doesn't go into com.android.art, but 257 // apex_available lists need to be the same for internal libs to avoid 258 // stubs, and libartd depends on this. 259 "com.android.art", 260 ], 261} 262 263art_cc_defaults { 264 name: "art_libdexfile_tests_defaults", 265 srcs: [ 266 "dex/art_dex_file_loader_test.cc", 267 "dex/class_accessor_test.cc", 268 "dex/code_item_accessors_test.cc", 269 "dex/compact_dex_file_test.cc", 270 "dex/compact_offset_table_test.cc", 271 "dex/descriptors_names_test.cc", 272 "dex/test_dex_file_builder_test.cc", 273 "dex/dex_file_loader_test.cc", 274 "dex/dex_file_verifier_test.cc", 275 "dex/dex_instruction_test.cc", 276 "dex/primitive_test.cc", 277 "dex/string_reference_test.cc", 278 "dex/type_lookup_table_test.cc", 279 "dex/utf_test.cc", 280 ], 281 data: [ 282 ":art-gtest-jars-GetMethodSignature", 283 ":art-gtest-jars-Lookup", 284 ":art-gtest-jars-Main", 285 ":art-gtest-jars-MultiDex", 286 ":art-gtest-jars-Nested", 287 ], 288 header_libs: ["jni_headers"], 289 shared_libs: [ 290 "libbacktrace", 291 "libziparchive", 292 ], 293} 294 295// Version of ART gtest `art_libdexfile_tests` bundled with the ART APEX on target. 296// TODO(b/192274705): Remove this module when the migration to standalone ART gtests is complete. 297art_cc_test { 298 name: "art_libdexfile_tests", 299 defaults: [ 300 "art_gtest_defaults", 301 "art_libdexfile_tests_defaults", 302 ], 303} 304 305// Standalone version of ART gtest `art_libdexfile_tests`, not bundled with the ART APEX on target. 306art_cc_test { 307 name: "art_standalone_libdexfile_tests", 308 defaults: [ 309 "art_standalone_gtest_defaults", 310 "art_libdexfile_tests_defaults", 311 ], 312 test_config: "art_standalone_libdexfile_tests.xml", 313} 314 315cc_library_headers { 316 name: "libdexfile_external_headers", 317 visibility: ["//visibility:public"], 318 host_supported: true, 319 header_libs: ["libbase_headers"], 320 export_header_lib_headers: ["libbase_headers"], 321 export_include_dirs: ["external/include"], 322 323 target: { 324 windows: { 325 enabled: true, 326 }, 327 }, 328 329 apex_available: [ 330 "//apex_available:platform", 331 "com.android.art", 332 "com.android.art.debug", 333 "com.android.media", 334 "com.android.runtime", 335 ], 336 min_sdk_version: "S", 337} 338 339// Make dex_instruction_list.h available for tools/jvmti-agents/titrace 340cc_library_headers { 341 name: "libdexfile_all_headers", 342 visibility: ["//art:__subpackages__"], 343 host_supported: true, 344 export_include_dirs: ["."], 345 346 apex_available: [ 347 "com.android.art", 348 "com.android.art.debug", 349 ], 350 min_sdk_version: "S", 351} 352 353art_cc_test { 354 name: "art_libdexfile_external_tests", 355 defaults: [ 356 "art_module_source_build_defaults", 357 "art_test_defaults", 358 ], 359 test_suites: ["general-tests"], 360 srcs: [ 361 "external/dex_file_ext_c_test.c", 362 "external/dex_file_ext_test.cc", 363 ], 364 shared_libs: [ 365 "libartbase", 366 "libdexfile", 367 ], 368 header_libs: [ 369 "jni_headers", 370 "libdexfile_external_headers", 371 ], 372} 373 374// Support library with a C++ API for accessing the libdexfile API for external 375// (non-ART) users. 376// 377// This library dlopens libdexfile(d).so on first use, so there is no build time 378// dependency on dex file logic. It is therefore safe to use from binaries 379// compiled without dex file support, given they won't encounter any dex file 380// stack frames. 381// 382// IMPORTANT: When adding a static_libs dependency on this library, please 383// remember to also add a corresponding 384// 385// runtime_libs: ["libdexfile"], 386// 387// That is necessary since Soong doesn't propagate dependencies transitively for 388// static libraries (b/169779783). 389art_cc_library_static { 390 name: "libdexfile_support", 391 visibility: ["//visibility:public"], 392 host_supported: true, 393 srcs: [ 394 "external/dex_file_supp.cc", 395 ], 396 runtime_libs: ["libdexfile"], 397 shared_libs: [ 398 "liblog", 399 "libbase", 400 ], 401 header_libs: ["libdexfile_external_headers"], 402 export_header_lib_headers: ["libdexfile_external_headers"], 403 404 apex_available: [ 405 "//apex_available:platform", 406 "com.android.art", 407 "com.android.art.debug", 408 "com.android.media", 409 "com.android.media.swcodec", 410 "com.android.runtime", 411 ], 412 min_sdk_version: "S", 413} 414 415art_cc_defaults { 416 name: "art_libdexfile_support_tests_defaults", 417 defaults: [ 418 "art_module_source_build_defaults", 419 ], 420 test_suites: ["general-tests"], 421 srcs: [ 422 "external/dex_file_supp_test.cc", 423 ], 424 shared_libs: [ 425 "libartbase", 426 "libbase", 427 "libdexfile", 428 "liblog", 429 ], 430 static_libs: [ 431 "libdexfile_support", 432 ], 433} 434 435// Version of ART gtest `art_libdexfile_support_tests` bundled with the ART APEX on target. 436// TODO(b/192274705): Remove this module when the migration to standalone ART gtests is complete. 437art_cc_test { 438 name: "art_libdexfile_support_tests", 439 host_supported: true, 440 defaults: [ 441 "art_test_defaults", 442 "art_libdexfile_support_tests_defaults", 443 ], 444} 445 446// Standalone version of ART gtest `art_libdexfile_support_tests`, not bundled with the ART APEX on 447// target. 448art_cc_test { 449 name: "art_standalone_libdexfile_support_tests", 450 defaults: [ 451 "art_standalone_test_defaults", 452 "art_libdexfile_support_tests_defaults", 453 ], 454 455 // Support multilib variants (using different suffix per sub-architecture), which is needed on 456 // build targets with secondary architectures, as the MTS test suite packaging logic flattens 457 // all test artifacts into a single `testcases` directory. 458 compile_multilib: "both", 459 multilib: { 460 lib32: { 461 suffix: "32", 462 }, 463 lib64: { 464 suffix: "64", 465 }, 466 }, 467 468 test_suites: [ 469 "mts-art", 470 ], 471} 472 473cc_library_static { 474 name: "libdexfile_support_static", 475 host_supported: true, 476 srcs: [ 477 "external/dex_file_supp.cc", 478 ], 479 cflags: ["-DSTATIC_LIB"], 480 header_libs: ["libdexfile_external_headers"], 481 export_header_lib_headers: ["libdexfile_external_headers"], 482} 483 484cc_defaults { 485 name: "libdexfile_support_static_defaults", 486 defaults: [ 487 "libdexfile_static_defaults", 488 ], 489 whole_static_libs: [ 490 "libdexfile", 491 "libdexfile_support_static", 492 ], 493} 494 495cc_defaults { 496 name: "libdexfiled_support_static_defaults", 497 defaults: [ 498 "libdexfiled_static_defaults", 499 ], 500 whole_static_libs: [ 501 "libdexfiled", 502 "libdexfile_support_static", 503 ], 504} 505 506art_cc_test { 507 name: "art_libdexfile_support_static_tests", 508 test_suites: ["general-tests"], 509 defaults: [ 510 "art_module_source_build_defaults", 511 "art_test_defaults", 512 "libdexfile_support_static_defaults", 513 ], 514 srcs: [ 515 "external/dex_file_supp_test.cc", 516 ], 517} 518 519// For use by external packages allowed to link in static libdexfile_support. 520// This is not allowed in any module that may end up in an APEX or platform 521// image, so visibility is restrictive. 522cc_library_static { 523 name: "libdexfile_static", 524 host_supported: true, 525 visibility: [ 526 // Required for simpleperf, libsimpleperf_record, and libsimpleperf_report 527 // in the NDK. 528 "//system/extras/simpleperf", 529 "//cts/tests/tests/simpleperf", 530 ], 531 // Using libdexfile_support_static_defaults will link in external libs like 532 // libbase and libz statically as well, which are likely to cause duplicate 533 // copies in the depending module. 534 // TODO(b/169885605): Avoid exposing symbols from those libs. 535 defaults: [ 536 "art_defaults", 537 "libdexfile_support_static_defaults", 538 ], 539} 540 541art_cc_test { 542 name: "art_libdexfile_static_tests", 543 defaults: ["art_test_defaults"], 544 test_suites: ["general-tests"], 545 srcs: [ 546 "external/dex_file_supp_test.cc", 547 ], 548 static_libs: [ 549 "libdexfile_static", 550 ], 551 enabled: false, 552 target: { 553 linux: { 554 enabled: true, 555 }, 556 }, 557 // TODO(b/181740144): Enable a ubsan check to create a dependency on 558 // ubsan_minimal. It's needed to be able to link with the prebuilt 559 // libdexfile_static.a, which contains libziparchive.a, which is 560 // built with some ubsan checks 561 // (https://cs.android.com/android/platform/superproject/+/master:system/libziparchive/Android.bp;l=47-59;drc=c7b498fdf2002194709e40ea58ce39f43684fc14) 562 // that the SDK snapshots currently don't propagate properly for static 563 // libs. 564 sanitize: { 565 misc_undefined: ["shift"], 566 }, 567} 568 569filegroup { 570 name: "art_libdexfile_dex_instruction_list_header", 571 srcs: ["dex/dex_instruction_list.h"], 572} 573