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} 22 23// 24// Definitions for building the Conscrypt Java library, native code, 25// and associated tests. 26// 27 28// Conscrypt is divided into subdirectories. 29// 30// The structure is: 31// 32// constants/ 33// src/gen # Generates NativeConstants.java. 34// common/ 35// src/main/java # Common Java source for all platforms. 36// src/jni/ 37// main # Common C++ source for all platforms. 38// unbundled # C++ source used for OpenJDK and unbundled Android. 39// src/test/java # Common test files for all platforms. 40// android/ 41// src/main/java # Java source for unbundled Android. 42// openjdk/ 43// src/main/java # Java source for OpenJDK. 44// src/test 45// java/ # Java source for common tests. 46// resources/ # Support files for tests 47// platform/ 48// src/main/java # Java source for bundled Android. 49// src/test 50// java/ # Java source for bundled tests. 51// 52 53cc_defaults { 54 name: "conscrypt_global", 55 56 cflags: [ 57 "-Wall", 58 "-Wextra", 59 "-Werror", 60 "-Wunused", 61 ], 62 63 srcs: [ 64 "common/src/jni/main/cpp/conscrypt/compatibility_close_monitor.cc", 65 "common/src/jni/main/cpp/conscrypt/jniload.cc", 66 "common/src/jni/main/cpp/conscrypt/jniutil.cc", 67 "common/src/jni/main/cpp/conscrypt/native_crypto.cc", 68 "common/src/jni/main/cpp/conscrypt/netutil.cc", 69 "common/src/jni/main/cpp/conscrypt/trace.cc", 70 ], 71 72 local_include_dirs: [ 73 "common/src/jni/main/include", 74 ], 75 76 compile_multilib: "both", 77 stl: "c++_static", 78} 79 80cc_defaults { 81 name: "conscrypt_unbundled-jni-defaults", 82 83 local_include_dirs: [ 84 "common/src/jni/unbundled/include", 85 ], 86 87 shared_libs: [ 88 "liblog", 89 ], 90 91 static_libs: [ 92 "libssl", 93 "libcrypto_static", 94 ], 95 96 sdk_version: "9", 97} 98 99cc_library { 100 name: "libconscrypt_jni", 101 defaults: [ 102 "conscrypt_global", 103 "conscrypt_unbundled-jni-defaults", 104 ], 105} 106 107cc_library_host_shared { 108 name: "libconscrypt_openjdk_jni", 109 defaults: ["conscrypt_global"], 110 111 cflags: [ 112 "-DCONSCRYPT_OPENJDK", 113 ], 114 115 local_include_dirs: [ 116 "common/src/jni/unbundled/include", 117 ], 118 119 static_libs: [ 120 "libssl", 121 "libcrypto_static", 122 ], 123 124 // TODO: b/26097626. ASAN breaks use of this library in JVM. 125 // Re-enable sanitization when the issue with making clients of this library 126 // preload ASAN runtime is resolved. Without that, clients are getting runtime 127 // errors due to unresolved ASAN symbols, such as 128 // __asan_option_detect_stack_use_after_return. 129 sanitize: { 130 never: true, 131 }, 132 133 stl: "libc++_static", 134 135 // The post-build signing tools need signapk.jar and its shared libs 136 multilib: { 137 lib64: { 138 dist: { 139 targets: ["droidcore"], 140 }, 141 }, 142 }, 143} 144 145cc_binary_host { 146 name: "conscrypt_generate_constants", 147 srcs: ["constants/src/gen/cpp/generate_constants.cc"], 148 cflags: [ 149 "-Wall", 150 "-Werror", 151 ], 152 shared_libs: [ 153 "libcrypto", 154 "libssl", 155 ], 156} 157 158genrule { 159 name: "conscrypt-unbundled_generated_constants", 160 out: ["org/conscrypt/NativeConstants.java"], 161 cmd: "$(location conscrypt_generate_constants) > $(out)", 162 tools: ["conscrypt_generate_constants"], 163} 164 165genrule { 166 name: "conscrypt_generated_constants", 167 out: ["com/android/org/conscrypt/NativeConstants.java"], 168 cmd: "$(location conscrypt_generate_constants) com.android.org.conscrypt > $(out)", 169 tools: ["conscrypt_generate_constants"], 170} 171 172filegroup { 173 name: "conscrypt_java_files", 174 srcs: [ 175 "repackaged/common/src/main/java/**/*.java", 176 "repackaged/platform/src/main/java/**/*.java", 177 ":conscrypt_generated_constants", 178 ], 179} 180 181filegroup { 182 name: "conscrypt_public_api_files", 183 srcs: ["publicapi/src/main/java/**/*.java"], 184 path: "publicapi/src/main/java", 185} 186 187// Create the conscrypt library from the source produced by the srcgen/generate_android_src.sh 188// script. 189java_library { 190 name: "conscrypt", 191 visibility: [ 192 "//art/build", 193 "//device:__subpackages__", 194 "//external/robolectric-shadows", 195 "//system/apex/tests", 196 ":__subpackages__", 197 ], 198 apex_available: [ 199 "com.android.conscrypt", 200 "test_com.android.conscrypt", 201 ], 202 // Conscrypt should support Q 203 min_sdk_version: "29", 204 205 installable: true, 206 hostdex: true, 207 208 srcs: [ 209 ":conscrypt_java_files", 210 ":conscrypt_public_api_files", 211 ], 212 213 libs: ["unsupportedappusage"], 214 215 // Conscrypt can be updated independently from the other core libraries so it must only depend 216 // on public SDK and intra-core APIs. 217 sdk_version: "none", 218 system_modules: "art-module-intra-core-api-stubs-system-modules", 219 patch_module: "java.base", 220 221 // Workaround for b/124476339: libjavacrypto is required for both APEX and 222 // hostdex builds, but adding a top-level required property results in 223 // it being installed to /system on Android. 224 // TODO(b/124476339): move required back to a top level property 225 target: { 226 // boringssl_self_test needed in both /system/bin and /apex/com.android.conscrypt/bin 227 android: { 228 required: ["boringssl_self_test"], 229 }, 230 hostdex: { 231 required: ["libjavacrypto"], 232 }, 233 }, 234 235 permitted_packages: [ 236 "android.net.ssl", 237 "com.android.org.conscrypt", 238 ], 239 240 plugins: ["java_api_finder"], 241} 242 243// Referenced implicitly from conscrypt.module.platform.api. 244filegroup { 245 name: "conscrypt.module.platform.api.api.public.latest", 246 srcs: [ 247 "api/platform/last-api.txt", 248 ], 249} 250 251// Referenced implicitly from conscrypt.module.platform.api. 252filegroup { 253 name: "conscrypt.module.platform.api-removed.api.public.latest", 254 srcs: [ 255 "api/platform/last-removed.txt", 256 ], 257} 258 259// A library containing the core platform API stubs of the Conscrypt module. 260// 261// Core platform APIs are only intended for use of other parts of the platform, not the 262// core library modules. 263// 264// The API specification .txt files managed by this only contain the additional 265// classes/members that are in the platform API but which are not in the public 266// API. 267java_sdk_library { 268 name: "conscrypt.module.platform.api", 269 visibility: [ 270 "//external/wycheproof", 271 "//libcore:__subpackages__", 272 ], 273 srcs: [ 274 ":conscrypt_java_files", 275 ], 276 api_dir: "api/platform", 277 api_only: true, 278 droiddoc_options: [ 279 "--hide-annotation libcore.api.Hide", 280 "--show-single-annotation libcore.api.CorePlatformApi", 281 "--skip-annotation-instance-methods=false", 282 ], 283 hostdex: true, 284 285 sdk_version: "none", 286 system_modules: "art-module-platform-api-stubs-system-modules", 287} 288 289// A guaranteed unstripped version of conscrypt. 290// The build system may or may not strip the conscrypt jar, but this one will 291// not be stripped. See b/24535627. 292java_library { 293 name: "conscrypt-testdex", 294 installable: true, 295 296 static_libs: ["conscrypt"], 297 dex_preopt: { 298 enabled: false, 299 }, 300 301 sdk_version: "core_platform", 302 303 required: ["libjavacrypto"], 304} 305 306// Referenced implicitly from conscrypt.module.public.api. 307filegroup { 308 name: "conscrypt.module.public.api.api.public.latest", 309 srcs: [ 310 "api/public/last-api.txt", 311 ], 312} 313 314// Referenced implicitly from conscrypt.module.public.api. 315filegroup { 316 name: "conscrypt.module.public.api-removed.api.public.latest", 317 srcs: [ 318 "api/public/last-removed.txt", 319 ], 320} 321 322// A library containing the public API stubs of the Conscrypt module. 323java_sdk_library { 324 name: "conscrypt.module.public.api", 325 visibility: [ 326 "//frameworks/base", 327 "//libcore", 328 ], 329 srcs: [ 330 ":conscrypt_public_api_files", 331 ], 332 api_dir: "api/public", 333 api_only: true, 334 droiddoc_options: [ 335 // Emit nullability annotations from the source to the stub files. 336 "--include-annotations", 337 ], 338 339 java_version: "1.9", 340 341 sdk_version: "none", 342 system_modules: "art-module-public-api-stubs-system-modules", 343} 344 345// Referenced implicitly from conscrypt.module.intra.core.api. 346filegroup { 347 name: "conscrypt.module.intra.core.api.api.public.latest", 348 srcs: [ 349 "api/intra/last-api.txt", 350 ], 351} 352 353// Referenced implicitly from conscrypt.module.intra.core.api. 354filegroup { 355 name: "conscrypt.module.intra.core.api-removed.api.public.latest", 356 srcs: [ 357 "api/intra/last-removed.txt", 358 ], 359} 360 361// A library containing the intra-core API stubs of the Conscrypt module. 362// 363// Intra-core APIs are only intended for the use of other core library modules. 364// 365// The API specification .txt files managed by this only contain the additional 366// classes/members that are in the intra-core API but which are not the public API. 367java_sdk_library { 368 name: "conscrypt.module.intra.core.api", 369 visibility: [ 370 "//external/okhttp", 371 "//libcore:__subpackages__", 372 ], 373 srcs: [ 374 ":conscrypt_java_files", 375 ":conscrypt_public_api_files", 376 ], 377 api_dir: "api/intra", 378 api_only: true, 379 droiddoc_options: [ 380 "--hide-annotation libcore.api.Hide", 381 "--show-single-annotation libcore.api.IntraCoreApi", 382 "--skip-annotation-instance-methods=false", 383 ], 384 385 sdk_version: "none", 386 system_modules: "art-module-intra-core-api-stubs-system-modules", 387} 388 389// Platform conscrypt crypto JNI library 390cc_defaults { 391 name: "libjavacrypto-defaults", 392 393 cflags: [ 394 "-Wall", 395 "-Wextra", 396 "-Werror", 397 "-Wunused", 398 "-fvisibility=hidden", 399 ], 400 401 srcs: ["common/src/jni/main/cpp/**/*.cc"], 402 local_include_dirs: ["common/src/jni/main/include"], 403} 404 405// Platform conscrypt crypto JNI library 406cc_library_shared { 407 name: "libjavacrypto", 408 host_supported: true, 409 defaults: ["libjavacrypto-defaults"], 410 411 cflags: ["-DJNI_JARJAR_PREFIX=com/android/"], 412 header_libs: ["libnativehelper_header_only"], 413 shared_libs: [ 414 "libcrypto", 415 "liblog", 416 "libssl", 417 ], 418 419 target: { 420 darwin: { 421 enabled: false, 422 }, 423 android: { 424 runtime_libs: ["libandroidio"], 425 }, 426 not_windows: { 427 runtime_libs: ["libandroidio"], 428 }, 429 }, 430 apex_available: [ 431 "com.android.conscrypt", 432 "test_com.android.conscrypt", 433 ], 434 min_sdk_version: "29", 435} 436 437// Unbundled Conscrypt jar for use by signapk and apksigner tool 438// 439// Builds against standard host libraries. 440java_library_host { 441 name: "conscrypt-unbundled", 442 visibility: [ 443 "//build/make/tools/signapk", 444 "//tools/apksig", 445 ], 446 srcs: [ 447 "common/src/main/java/**/*.java", 448 "openjdk/src/main/java/**/*.java", 449 ":conscrypt-unbundled_generated_constants", 450 ], 451 javacflags: ["-XDignore.symbol.file"], 452 java_version: "1.7", 453} 454 455// Static unbundled Conscrypt crypto JNI library 456cc_library_static { 457 name: "libconscrypt_static", 458 defaults: ["libjavacrypto-defaults"], 459 460 cflags: [ 461 "-DJNI_JARJAR_PREFIX=com/google/android/gms/", 462 "-DCONSCRYPT_UNBUNDLED", 463 "-DSTATIC_LIB", 464 ], 465 466 local_include_dirs: ["common/src/jni/unbundled/include"], 467 468 static_libs: [ 469 "libssl", 470 "libcrypto_static", 471 ], 472 sdk_version: "9", 473 stl: "c++_shared", 474} 475 476// Make the conscrypt-tests library. 477java_test { 478 name: "conscrypt-tests", 479 visibility: [ 480 "//cts/tests/libcore/luni", 481 "//external/conscrypt/apex/tests", 482 ], 483 hostdex: true, 484 srcs: [ 485 "repackaged/platform/src/test/java/**/*.java", 486 "repackaged/common/src/test/java/**/*.java", 487 "repackaged/testing/src/main/java/**/*.java", 488 "publicapi/src/test/java/**/*.java", 489 ], 490 java_resource_dirs: [ 491 // Resource directories do not need repackaging. 492 "openjdk/src/test/resources", 493 "common/src/test/resources", 494 ], 495 496 sdk_version: "none", 497 system_modules: "art-module-intra-core-api-stubs-system-modules", 498 libs: [ 499 "conscrypt", 500 "core-test-rules", 501 "junit", 502 "mockito-target-minus-junit4", 503 ], 504 505 static_libs: [ 506 "bouncycastle-unbundled", 507 "bouncycastle-bcpkix-unbundled", 508 "bouncycastle-ocsp-unbundled", 509 ], 510 javacflags: [ 511 "-Xmaxwarns 9999999", 512 //"-Xlint:all", 513 //"-Xlint:-serial,-deprecation,-unchecked", 514 ], 515 516 required: ["libjavacrypto"], 517 java_version: "1.7", 518} 519 520// Make the conscrypt-benchmarks library. 521java_test { 522 name: "conscrypt-benchmarks", 523 srcs: [ 524 "repackaged/testing/src/main/java/**/*.java", 525 "repackaged/benchmark-base/src/main/java/**/*.java", 526 "repackaged/benchmark-android/src/main/java/**/*.java", 527 ], 528 sdk_version: "none", 529 system_modules: "art-module-intra-core-api-stubs-system-modules", 530 libs: [ 531 "conscrypt", 532 "junit", 533 "bouncycastle-unbundled", 534 "bouncycastle-bcpkix-unbundled", 535 "bouncycastle-ocsp-unbundled", 536 "caliper-api-target", 537 ], 538 539 javacflags: [ 540 "-Xmaxwarns 9999999", 541 //"-Xlint:all", 542 //"-Xlint:-serial,-deprecation,-unchecked", 543 ], 544 545 required: ["libjavacrypto"], 546 java_version: "1.7", 547} 548 549// Device SDK exposed by the Conscrypt module. 550sdk { 551 name: "conscrypt-module-sdk", 552 java_sdk_libs: [ 553 "conscrypt.module.public.api", 554 "conscrypt.module.intra.core.api", 555 "conscrypt.module.platform.api", 556 ], 557 native_shared_libs: [ 558 "libconscrypt_jni", 559 ], 560} 561 562// Host tools exported by the Conscrypt module. 563module_exports { 564 name: "conscrypt-module-host-exports", 565 host_supported: true, 566 device_supported: false, 567 java_libs: [ 568 "conscrypt-unbundled", 569 ], 570} 571 572// Test libraries exposed by the Conscrypt module. 573module_exports { 574 name: "conscrypt-module-test-exports", 575 java_libs: [ 576 // For use by robolectric. 577 "conscrypt", 578 // For use by art tests 579 "conscrypt-testdex", 580 ], 581 java_tests: [ 582 // For use by CTS 583 "conscrypt-tests", 584 ], 585} 586