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