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