1// 2// Copyright (C) 2016 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 default_visibility: [ 19 ":__subpackages__", 20 ], 21 default_applicable_licenses: ["external_conscrypt_license"], 22} 23 24// Added automatically by a large-scale-change that took the approach of 25// 'apply every license found to every target'. While this makes sure we respect 26// every license restriction, it may not be entirely correct. 27// 28// e.g. GPL in an MIT project might only apply to the contrib/ directory. 29// 30// Please consider splitting the single license below into multiple licenses, 31// taking care not to lose any license_kind information, and overriding the 32// default license using the 'licenses: [...]' property on targets as needed. 33// 34// For unused files, consider creating a 'fileGroup' with "//visibility:private" 35// to attach the license to, and including a comment whether the files may be 36// used in the current project. 37// 38// large-scale-change included anything that looked like it might be a license 39// text as a license_text. e.g. LICENSE, NOTICE, COPYING etc. 40// 41// Please consider removing redundant or irrelevant files from 'license_text:'. 42// See: http://go/android-license-faq 43license { 44 name: "external_conscrypt_license", 45 visibility: [":__subpackages__"], 46 license_kinds: [ 47 "SPDX-license-identifier-Apache-2.0", 48 "legacy_unencumbered", 49 ], 50 license_text: [ 51 "LICENSE", 52 "NOTICE", 53 "licenses/**/*", 54 ], 55} 56 57// 58// Definitions for building the Conscrypt Java library, native code, 59// and associated tests. 60// 61 62// Conscrypt is divided into subdirectories. 63// 64// The structure is: 65// 66// constants/ 67// src/gen # Generates NativeConstants.java. 68// common/ 69// src/main/java # Common Java source for all platforms. 70// src/jni/ 71// main # Common C++ source for all platforms. 72// unbundled # C++ source used for OpenJDK and unbundled Android. 73// src/test/java # Common test files for all platforms. 74// android/ 75// src/main/java # Java source for unbundled Android. 76// openjdk/ 77// src/main/java # Java source for OpenJDK. 78// src/test 79// java/ # Java source for common tests. 80// resources/ # Support files for tests 81// platform/ 82// src/main/java # Java source for bundled Android. 83// src/test 84// java/ # Java source for bundled tests. 85// 86 87cc_defaults { 88 name: "conscrypt_global", 89 90 cflags: [ 91 "-Wall", 92 "-Wextra", 93 "-Werror", 94 "-Wunused", 95 ], 96 97 srcs: [ 98 "common/src/jni/main/cpp/conscrypt/compatibility_close_monitor.cc", 99 "common/src/jni/main/cpp/conscrypt/jniload.cc", 100 "common/src/jni/main/cpp/conscrypt/jniutil.cc", 101 "common/src/jni/main/cpp/conscrypt/native_crypto.cc", 102 "common/src/jni/main/cpp/conscrypt/netutil.cc", 103 "common/src/jni/main/cpp/conscrypt/trace.cc", 104 ], 105 106 header_libs: ["jni_headers"], 107 108 local_include_dirs: [ 109 "common/src/jni/main/include", 110 ], 111 112 compile_multilib: "both", 113 stl: "c++_static", 114} 115 116cc_defaults { 117 name: "conscrypt_unbundled-jni-defaults", 118 119 local_include_dirs: [ 120 "common/src/jni/unbundled/include", 121 ], 122 123 header_libs: ["jni_headers"], 124 125 shared_libs: [ 126 "liblog", 127 ], 128 129 static_libs: [ 130 "libssl", 131 "libcrypto_static", 132 ], 133 134 sdk_version: "9", 135} 136 137cc_library { 138 name: "libconscrypt_jni", 139 defaults: [ 140 "conscrypt_global", 141 "conscrypt_unbundled-jni-defaults", 142 ], 143} 144 145cc_library_host_shared { 146 name: "libconscrypt_openjdk_jni", 147 visibility: [ 148 "//build/make/tools/signapk", 149 "//tools/apksig", 150 "//vendor:__subpackages__", 151 ], 152 defaults: ["conscrypt_global"], 153 154 cflags: [ 155 "-DCONSCRYPT_OPENJDK", 156 ], 157 158 local_include_dirs: [ 159 "common/src/jni/unbundled/include", 160 ], 161 162 static_libs: [ 163 "libssl", 164 "libcrypto_static", 165 ], 166 167 // TODO: b/26097626. ASAN breaks use of this library in JVM. 168 // Re-enable sanitization when the issue with making clients of this library 169 // preload ASAN runtime is resolved. Without that, clients are getting runtime 170 // errors due to unresolved ASAN symbols, such as 171 // __asan_option_detect_stack_use_after_return. 172 sanitize: { 173 never: true, 174 }, 175 176 stl: "libc++_static", 177 178 // The post-build signing tools need signapk.jar and its shared libs 179 multilib: { 180 lib64: { 181 dist: { 182 targets: ["droidcore"], 183 }, 184 }, 185 }, 186} 187 188cc_binary_host { 189 name: "conscrypt_generate_constants", 190 srcs: ["constants/src/gen/cpp/generate_constants.cc"], 191 cflags: [ 192 "-Wall", 193 "-Werror", 194 ], 195 shared_libs: [ 196 "libcrypto", 197 "libssl", 198 ], 199} 200 201genrule { 202 name: "conscrypt-unbundled_generated_constants", 203 out: ["org/conscrypt/NativeConstants.java"], 204 cmd: "$(location conscrypt_generate_constants) > $(out)", 205 tools: ["conscrypt_generate_constants"], 206} 207 208genrule { 209 name: "conscrypt_generated_constants", 210 out: ["com/android/org/conscrypt/NativeConstants.java"], 211 cmd: "$(location conscrypt_generate_constants) com.android.org.conscrypt > $(out)", 212 tools: ["conscrypt_generate_constants"], 213} 214 215filegroup { 216 name: "conscrypt_java_files", 217 srcs: [ 218 "repackaged/common/src/main/java/**/*.java", 219 "repackaged/platform/src/main/java/**/*.java", 220 ":conscrypt_generated_constants", 221 ], 222} 223 224filegroup { 225 name: "conscrypt_public_api_files", 226 srcs: ["publicapi/src/main/java/**/*.java"], 227 path: "publicapi/src/main/java", 228} 229 230// Create the conscrypt library from the source produced by the srcgen/generate_android_src.sh 231// script. 232java_library { 233 name: "conscrypt", 234 visibility: [ 235 "//device:__subpackages__", 236 "//system/apex/tests", 237 ":__subpackages__", 238 ], 239 apex_available: [ 240 "com.android.conscrypt", 241 "test_com.android.conscrypt", 242 ], 243 // Conscrypt should support Q 244 min_sdk_version: "29", 245 246 installable: true, 247 // Hostdex is only for ART testing on host: ART build file has its 248 // own hostdex support for conscrypt. 249 hostdex: false, 250 251 srcs: [ 252 ":conscrypt_java_files", 253 ":conscrypt_public_api_files", 254 ], 255 256 libs: ["unsupportedappusage"], 257 258 // Conscrypt can be updated independently from the other core libraries so it must only depend 259 // on public SDK and intra-core APIs. 260 sdk_version: "none", 261 system_modules: "art-module-intra-core-api-stubs-system-modules", 262 patch_module: "java.base", 263 264 target: { 265 // boringssl_self_test needed in both /system/bin and /apex/com.android.conscrypt/bin 266 // prng_seeder is only needed in /system/bin 267 // The required directive is here rather than under boringssl to avoid circular 268 // dependencies. 269 android: { 270 required: [ 271 "boringssl_self_test", 272 "prng_seeder", 273 ], 274 }, 275 }, 276 277 permitted_packages: [ 278 "android.net.ssl", 279 "com.android.org.conscrypt", 280 ], 281 282 plugins: ["java_api_finder"], 283} 284 285// Java library for use on host, e.g. by robolectric. 286java_library { 287 name: "conscrypt-for-host", 288 visibility: [ 289 "//art/build", 290 "//external/robolectric-shadows", 291 "//external/robolectric", 292 "//frameworks/layoutlib", 293 ], 294 static_libs: [ 295 "conscrypt", 296 ], 297 sdk_version: "none", 298 system_modules: "none", 299} 300 301// Referenced implicitly from conscrypt.module.platform.api. 302filegroup { 303 name: "conscrypt.module.platform.api.api.public.latest", 304 srcs: [ 305 "api/platform/last-api.txt", 306 ], 307} 308 309// Referenced implicitly from conscrypt.module.platform.api. 310filegroup { 311 name: "conscrypt.module.platform.api-removed.api.public.latest", 312 srcs: [ 313 "api/platform/last-removed.txt", 314 ], 315} 316 317// Referenced implicitly from conscrypt.module.platform.api. 318filegroup { 319 name: "conscrypt.module.platform.api-incompatibilities.api.public.latest", 320 srcs: [ 321 "api/platform/last-incompatibilities.txt", 322 ], 323} 324 325// A library containing the core platform API stubs of the Conscrypt module. 326// 327// Core platform APIs are only intended for use of other parts of the platform, not the 328// core library modules. 329// 330// The API specification .txt files managed by this only contain the additional 331// classes/members that are in the platform API but which are not in the public 332// API. 333// 334// Note that this entire API surface is considered stable in the sense described in 335// libcore/mmodules/core_platform_api/Android.bp. 336java_sdk_library { 337 name: "conscrypt.module.platform.api", 338 visibility: [ 339 "//build/soong/java/core-libraries", 340 "//external/wycheproof", 341 // Visibility for prebuilt conscrypt-module-sdk from the prebuilt of 342 // this module. 343 // TODO(b/155921753): Restrict this when prebuilts are in their proper 344 // locations. 345 "//prebuilts:__subpackages__", 346 347 // DO NOT REMOVE: Legacy visibility, needed for snapshots that are 348 // generated for the S build. 349 "//libcore/mmodules/core_platform_api", 350 ], 351 srcs: [ 352 ":conscrypt_java_files", 353 ], 354 api_dir: "api/platform", 355 api_only: true, 356 api_lint: { 357 enabled: true, 358 }, 359 droiddoc_options: [ 360 "--hide-annotation libcore.api.Hide", 361 "--show-single-annotation libcore.api.CorePlatformApi\\(status=libcore.api.CorePlatformApi.Status.STABLE\\)", 362 ], 363 hostdex: true, 364 365 sdk_version: "none", 366 system_modules: "art-module-lib-api-stubs-system-modules", 367 368 dist_group: "android", 369 dist_stem: "conscrypt-coreplatform", 370 // TODO: remove this when Conscrypt's @CorePlatformApi has been migrated to @SystemApi 371 unsafe_ignore_missing_latest_api: true, 372} 373 374// A library containing the public API stubs of the Conscrypt module. 375java_sdk_library { 376 name: "conscrypt.module.public.api", 377 visibility: [ 378 "//build/soong/java/core-libraries", 379 "//frameworks/base", 380 "//frameworks/base/api", 381 "//packages/modules/common/sdk", 382 // TODO(b/165823103): Remove visiblity for IPsec once CorePlatformApi is available 383 "//packages/modules/IPsec", 384 // Visibility for prebuilt art-module-host-exports from the prebuilt of 385 // this module. 386 // TODO(b/155921753): Restrict this when prebuilts are in their proper 387 // locations. 388 "//prebuilts:__subpackages__", 389 390 // DO NOT REMOVE: Legacy visibility, needed for snapshots that are 391 // generated for the S build. 392 "//libcore", 393 ], 394 srcs: [ 395 ":conscrypt_public_api_files", 396 ], 397 398 // The base name for the artifacts that are automatically published to the 399 // dist and which end up in one of the sub-directories of prebuilts/sdk. 400 // As long as this matches the name of the artifacts in prebuilts/sdk then 401 // the API will be checked for compatibility against the latest released 402 // version of the API. 403 dist_stem: "conscrypt", 404 405 public: { 406 enabled: true, 407 }, 408 system: { 409 enabled: true, 410 }, 411 module_lib: { 412 enabled: true, 413 }, 414 415 api_dir: "api/public", 416 api_only: true, 417 418 // Emit nullability annotations from the source to the stub files. 419 annotations_enabled: true, 420 421 java_version: "1.9", 422 423 sdk_version: "none", 424 system_modules: "art-module-public-api-stubs-system-modules", 425 dist_group: "android", 426} 427 428// Referenced implicitly from conscrypt.module.intra.core.api. 429filegroup { 430 name: "conscrypt.module.intra.core.api.api.public.latest", 431 srcs: [ 432 "api/intra/last-api.txt", 433 ], 434} 435 436// Referenced implicitly from conscrypt.module.intra.core.api. 437filegroup { 438 name: "conscrypt.module.intra.core.api-removed.api.public.latest", 439 srcs: [ 440 "api/intra/last-removed.txt", 441 ], 442} 443 444// Referenced implicitly from conscrypt.module.intra.core.api. 445filegroup { 446 name: "conscrypt.module.intra.core.api-incompatibilities.api.public.latest", 447 srcs: [ 448 "api/intra/last-incompatibilities.txt", 449 ], 450} 451 452// A library containing the intra-core API stubs of the Conscrypt module. 453// 454// Intra-core APIs are only intended for the use of other core library modules. 455// 456// The API specification .txt files managed by this only contain the additional 457// classes/members that are in the intra-core API but which are not the public API. 458java_sdk_library { 459 name: "conscrypt.module.intra.core.api", 460 visibility: [ 461 "//external/okhttp", 462 "//libcore:__subpackages__", 463 // Visibility for prebuilt conscrypt-module-sdk from the prebuilt of 464 // this module. 465 // TODO(b/155921753): Restrict this when prebuilts are in their proper 466 // locations. 467 "//prebuilts:__subpackages__", 468 ], 469 srcs: [ 470 ":conscrypt_java_files", 471 ":conscrypt_public_api_files", 472 ], 473 api_dir: "api/intra", 474 api_only: true, 475 droiddoc_options: [ 476 "--hide-annotation libcore.api.Hide", 477 "--show-single-annotation libcore.api.IntraCoreApi", 478 ], 479 480 sdk_version: "none", 481 system_modules: "art-module-intra-core-api-stubs-system-modules", 482 483 // Don't copy any output files to the dist. 484 no_dist: true, 485} 486 487// Platform conscrypt crypto JNI library 488cc_defaults { 489 name: "libjavacrypto-defaults", 490 491 cflags: [ 492 "-Wall", 493 "-Wextra", 494 "-Werror", 495 "-Wunused", 496 "-fvisibility=hidden", 497 ], 498 499 srcs: ["common/src/jni/main/cpp/**/*.cc"], 500 header_libs: ["jni_headers"], 501 local_include_dirs: ["common/src/jni/main/include"], 502} 503 504// Platform conscrypt crypto JNI library 505cc_library_shared { 506 name: "libjavacrypto", 507 host_supported: true, 508 defaults: ["libjavacrypto-defaults"], 509 510 cflags: ["-DJNI_JARJAR_PREFIX=com/android/"], 511 header_libs: ["libnativehelper_header_only"], 512 shared_libs: [ 513 "libcrypto", 514 "liblog", 515 "libssl", 516 ], 517 518 target: { 519 darwin: { 520 enabled: false, 521 }, 522 android: { 523 runtime_libs: ["libandroidio"], 524 }, 525 not_windows: { 526 runtime_libs: ["libandroidio"], 527 }, 528 }, 529 apex_available: [ 530 "com.android.conscrypt", 531 "test_com.android.conscrypt", 532 ], 533 min_sdk_version: "29", 534} 535 536// Unbundled Conscrypt jar for use by signapk and apksigner tool 537// 538// Builds against standard host libraries. 539java_library_host { 540 name: "conscrypt-unbundled", 541 visibility: [ 542 "//build/make/tools/signapk", 543 "//tools/apksig", 544 "//external/robolectric/robolectric", 545 "//external/robolectric:__subpackages__", 546 ], 547 srcs: [ 548 "common/src/main/java/**/*.java", 549 "openjdk/src/main/java/**/*.java", 550 ":conscrypt-unbundled_generated_constants", 551 ], 552 javacflags: ["-XDignore.symbol.file"], 553 java_version: "1.8", 554 target: { 555 windows: { 556 enabled: true, 557 }, 558 }, 559} 560 561// Static unbundled Conscrypt crypto JNI library 562cc_library_static { 563 name: "libconscrypt_static", 564 defaults: ["libjavacrypto-defaults"], 565 566 cflags: [ 567 "-DJNI_JARJAR_PREFIX=com/google/android/gms/", 568 "-DCONSCRYPT_UNBUNDLED", 569 "-DSTATIC_LIB", 570 ], 571 572 local_include_dirs: ["common/src/jni/unbundled/include"], 573 574 static_libs: [ 575 "libssl", 576 "libcrypto_static", 577 ], 578 sdk_version: "9", 579 stl: "c++_shared", 580} 581 582// Make the conscrypt-tests library. 583java_test { 584 name: "conscrypt-tests", 585 visibility: [ 586 "//cts/tests/libcore/luni", 587 "//external/conscrypt/apex/tests", 588 ], 589 hostdex: true, 590 srcs: [ 591 "repackaged/platform/src/test/java/**/*.java", 592 "repackaged/common/src/test/java/**/*.java", 593 "repackaged/testing/src/main/java/**/*.java", 594 "publicapi/src/test/java/**/*.java", 595 ], 596 java_resource_dirs: [ 597 // Resource directories do not need repackaging. 598 "openjdk/src/test/resources", 599 "common/src/test/resources", 600 ], 601 602 sdk_version: "none", 603 system_modules: "art-module-intra-core-api-stubs-system-modules", 604 libs: [ 605 "conscrypt", 606 "core-test-rules", 607 "junit", 608 "mockito-target-minus-junit4", 609 "framework-statsd.stubs.module_lib", 610 ], 611 612 static_libs: [ 613 "bouncycastle-unbundled", 614 "bouncycastle-bcpkix-unbundled", 615 "bouncycastle-ocsp-unbundled", 616 ], 617 javacflags: [ 618 "-Xmaxwarns 9999999", 619 //"-Xlint:all", 620 //"-Xlint:-serial,-deprecation,-unchecked", 621 ], 622 623 target: { 624 host: { 625 required: ["libjavacrypto"], 626 }, 627 darwin: { 628 // required module "libjavacrypto" is disabled on darwin 629 enabled: false, 630 }, 631 }, 632 java_version: "1.8", 633} 634 635// Make the conscrypt-benchmarks library. 636java_test { 637 name: "conscrypt-benchmarks", 638 srcs: [ 639 "repackaged/testing/src/main/java/**/*.java", 640 "repackaged/benchmark-base/src/main/java/**/*.java", 641 "repackaged/benchmark-android/src/main/java/**/*.java", 642 ], 643 sdk_version: "none", 644 system_modules: "art-module-intra-core-api-stubs-system-modules", 645 libs: [ 646 "conscrypt", 647 "junit", 648 "bouncycastle-unbundled", 649 "bouncycastle-bcpkix-unbundled", 650 "bouncycastle-ocsp-unbundled", 651 "caliper-api-target", 652 ], 653 654 javacflags: [ 655 "-Xmaxwarns 9999999", 656 //"-Xlint:all", 657 //"-Xlint:-serial,-deprecation,-unchecked", 658 ], 659 660 target: { 661 host: { 662 required: ["libjavacrypto"], 663 }, 664 darwin: { 665 // required module "libjavacrypto" is disabled on darwin 666 enabled: false, 667 }, 668 }, 669 java_version: "1.8", 670} 671 672// Device SDK exposed by the Conscrypt module. 673sdk { 674 name: "conscrypt-module-sdk", 675 bootclasspath_fragments: [ 676 "com.android.conscrypt-bootclasspath-fragment", 677 ], 678 java_sdk_libs: [ 679 "conscrypt.module.public.api", 680 "conscrypt.module.intra.core.api", 681 "conscrypt.module.platform.api", 682 ], 683 native_shared_libs: [ 684 "libconscrypt_jni", 685 ], 686} 687 688// Host tools exported by the Conscrypt module. 689module_exports { 690 name: "conscrypt-module-host-exports", 691 host_supported: true, 692 device_supported: false, 693 java_libs: [ 694 "conscrypt-unbundled", 695 ], 696 native_shared_libs: [ 697 "libconscrypt_openjdk_jni", 698 ], 699} 700 701// Test libraries exposed by the Conscrypt module. 702module_exports { 703 name: "conscrypt-module-test-exports", 704 host_supported: true, 705 target: { 706 android: { 707 java_libs: [ 708 // For use by robolectric and ART tests. 709 "conscrypt-for-host", 710 ], 711 java_tests: [ 712 // For use by CTS 713 "conscrypt-tests", 714 ], 715 // TODO: Remove this when we resolve b/151303681. 716 native_shared_libs: [ 717 "libjavacrypto", 718 ], 719 }, 720 darwin: { 721 enabled: false, 722 }, 723 // For use by ART tests on host. 724 not_windows: { 725 native_shared_libs: [ 726 "libjavacrypto", 727 ], 728 }, 729 }, 730} 731