blob: 1418e01ac913c0026cad7f5eb0fd08b578f2f848 [file] [log] [blame]
Kenny Root923342a2016-09-22 17:04:35 -07001//
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
Colin Cross8024b112017-10-09 13:34:58 -070017//
18// Definitions for building the Conscrypt Java library, native code,
19// and associated tests.
20//
21
Neil Fullerde17f742018-09-25 11:48:05 +010022// Conscrypt is divided into subdirectories.
Colin Cross8024b112017-10-09 13:34:58 -070023//
24// The structure is:
25//
26// constants/
27// src/gen # Generates NativeConstants.java.
28// common/
29// src/main/java # Common Java source for all platforms.
30// src/jni/
31// main # Common C++ source for all platforms.
32// unbundled # C++ source used for OpenJDK and unbundled Android.
Adam Vartaniana0509172018-06-15 19:19:20 +010033// src/test/java # Common test files for all platforms.
Colin Cross8024b112017-10-09 13:34:58 -070034// android/
35// src/main/java # Java source for unbundled Android.
36// openjdk/
37// src/main/java # Java source for OpenJDK.
38// src/test
39// java/ # Java source for common tests.
40// resources/ # Support files for tests
41// platform/
42// src/main/java # Java source for bundled Android.
43// src/test
44// java/ # Java source for bundled tests.
45//
46
Kenny Root923342a2016-09-22 17:04:35 -070047cc_defaults {
48 name: "conscrypt_global",
49
50 cflags: [
51 "-Wall",
52 "-Wextra",
53 "-Werror",
54 "-Wunused",
55 ],
56
57 srcs: [
Tobias Thierer33b649f2019-01-22 20:59:36 +000058 "common/src/jni/main/cpp/conscrypt/compatibility_close_monitor.cc",
Nathan Mittlercd7a1582017-08-10 15:17:37 -070059 "common/src/jni/main/cpp/conscrypt/jniload.cc",
60 "common/src/jni/main/cpp/conscrypt/jniutil.cc",
Nathan Mittlerf8c8d4b2017-08-02 06:57:22 -070061 "common/src/jni/main/cpp/conscrypt/native_crypto.cc",
Nathan Mittlercd7a1582017-08-10 15:17:37 -070062 "common/src/jni/main/cpp/conscrypt/netutil.cc",
63 "common/src/jni/main/cpp/conscrypt/trace.cc",
nmittler7782d132016-11-22 11:34:01 -080064 ],
65
66 local_include_dirs: [
67 "common/src/jni/main/include",
Kenny Root923342a2016-09-22 17:04:35 -070068 ],
69
Kenny Root923342a2016-09-22 17:04:35 -070070 compile_multilib: "both",
71 stl: "c++_static",
72}
73
74cc_defaults {
Colin Cross8024b112017-10-09 13:34:58 -070075 name: "conscrypt_unbundled-jni-defaults",
Kenny Root923342a2016-09-22 17:04:35 -070076
Kenny Root923342a2016-09-22 17:04:35 -070077 local_include_dirs: [
nmittler7782d132016-11-22 11:34:01 -080078 "common/src/jni/unbundled/include",
Kenny Root923342a2016-09-22 17:04:35 -070079 ],
80
Kenny Root7bf42db2016-10-05 10:01:40 -070081 shared_libs: [
82 "liblog",
83 ],
84
Kenny Root923342a2016-09-22 17:04:35 -070085 static_libs: [
86 "libssl",
87 "libcrypto",
88 ],
89
90 sdk_version: "9",
91}
92
93cc_library {
94 name: "libconscrypt_jni",
Colin Cross8024b112017-10-09 13:34:58 -070095 defaults: [
96 "conscrypt_global",
97 "conscrypt_unbundled-jni-defaults",
98 ],
Kenny Root923342a2016-09-22 17:04:35 -070099}
100
101cc_library_host_shared {
102 name: "libconscrypt_openjdk_jni",
103 defaults: ["conscrypt_global"],
104
105 cflags: [
106 "-DCONSCRYPT_OPENJDK",
107 ],
108
Kenny Root923342a2016-09-22 17:04:35 -0700109 local_include_dirs: [
nmittler7782d132016-11-22 11:34:01 -0800110 "common/src/jni/unbundled/include",
Kenny Root923342a2016-09-22 17:04:35 -0700111 ],
112
Kenny Root923342a2016-09-22 17:04:35 -0700113 static_libs: [
Adam Vartanian9b0c0172017-08-16 16:44:17 +0100114 "libssl",
115 "libcrypto",
Kenny Root923342a2016-09-22 17:04:35 -0700116 ],
117
118 // TODO: b/26097626. ASAN breaks use of this library in JVM.
119 // Re-enable sanitization when the issue with making clients of this library
120 // preload ASAN runtime is resolved. Without that, clients are getting runtime
121 // errors due to unresolved ASAN symbols, such as
122 // __asan_option_detect_stack_use_after_return.
123 sanitize: {
124 never: true,
125 },
126
Kenny Root7bf42db2016-10-05 10:01:40 -0700127 stl: "libc++_static",
Dan Willemsenc9d6d8f2019-01-04 16:13:27 -0800128
129 // The post-build signing tools need signapk.jar and its shared libs
130 multilib: {
131 lib64: {
132 dist: {
133 targets: ["droidcore"],
134 },
135 },
136 },
Kenny Root923342a2016-09-22 17:04:35 -0700137}
Colin Cross8024b112017-10-09 13:34:58 -0700138
139cc_binary_host {
140 name: "conscrypt_generate_constants",
141 srcs: ["constants/src/gen/cpp/generate_constants.cc"],
Chih-Hung Hsieh7a286142017-10-25 16:07:06 -0700142 cflags: [
143 "-Wall",
144 "-Werror",
145 ],
Colin Cross8024b112017-10-09 13:34:58 -0700146 shared_libs: [
147 "libcrypto",
148 "libssl",
149 ],
150}
151
152genrule {
Paul Duffin31d1d152018-09-19 15:03:21 +0100153 name: "conscrypt-nojarjar_generated_constants",
Colin Cross8024b112017-10-09 13:34:58 -0700154 out: ["org/conscrypt/NativeConstants.java"],
155 cmd: "$(location conscrypt_generate_constants) > $(out)",
156 tools: ["conscrypt_generate_constants"],
157}
158
159// Create the conscrypt library without jarjar for tests
Neil Fullera179d2b2018-09-11 18:43:08 +0100160java_library {
Colin Cross8024b112017-10-09 13:34:58 -0700161 name: "conscrypt-nojarjar",
162 host_supported: true,
163 hostdex: true,
164
165 srcs: [
166 "common/src/main/java/**/*.java",
Paul Duffin31d1d152018-09-19 15:03:21 +0100167 ":conscrypt-nojarjar_generated_constants",
Colin Cross8024b112017-10-09 13:34:58 -0700168 ],
169
Neil Fuller5d272352018-10-12 22:10:57 +0100170 no_standard_libs: true,
171 system_modules: "core-all-system-modules",
Colin Cross8024b112017-10-09 13:34:58 -0700172 target: {
173 android: {
174 srcs: ["platform/src/main/java/**/*.java"],
Neil Fuller5d272352018-10-12 22:10:57 +0100175 libs: ["core-all"],
Colin Cross8024b112017-10-09 13:34:58 -0700176 },
177 host: {
178 srcs: ["openjdk/src/main/java/**/*.java"],
179 javacflags: ["-XDignore.symbol.file"],
180 },
181 },
182
Colin Cross8024b112017-10-09 13:34:58 -0700183 required: ["libjavacrypto"],
184 java_version: "1.7",
185}
186
Paul Duffin31d1d152018-09-19 15:03:21 +0100187genrule {
188 name: "conscrypt_generated_constants",
189 out: ["com/android/org/conscrypt/NativeConstants.java"],
190 cmd: "$(location conscrypt_generate_constants) com.android.org.conscrypt > $(out)",
191 tools: ["conscrypt_generate_constants"],
192}
193
Neil Fuller3bf29f22018-09-24 17:35:33 +0100194filegroup {
195 name: "conscrypt_java_files",
196 srcs: [
197 "repackaged/common/src/main/java/**/*.java",
198 "repackaged/platform/src/main/java/**/*.java",
199 ":conscrypt_generated_constants",
200 ],
201}
202
Adam Vartanianacc0e552018-10-18 10:09:22 +0100203filegroup {
204 name: "conscrypt_public_api_files",
205 srcs: ["publicapi/src/main/java/**/*.java"]
206}
207
Paul Duffin31d1d152018-09-19 15:03:21 +0100208// Create the conscrypt library from the source produced by the srcgen/generate_android_src.sh
209// script.
Colin Cross8024b112017-10-09 13:34:58 -0700210java_library {
211 name: "conscrypt",
Colin Cross291db152018-06-27 11:00:08 -0700212 installable: true,
Colin Cross8024b112017-10-09 13:34:58 -0700213 hostdex: true,
Neil Fullera179d2b2018-09-11 18:43:08 +0100214
Adam Vartanianacc0e552018-10-18 10:09:22 +0100215 srcs: [
216 ":conscrypt_java_files",
217 ":conscrypt_public_api_files",
218 ],
Neil Fullera179d2b2018-09-11 18:43:08 +0100219
Neil Fuller2f117722018-09-26 16:14:23 +0100220 // Conscrypt can be updated independently from the other core libraries so it must only depend
221 // on public SDK and intra-core APIs.
222 no_standard_libs: true,
223 libs: ["core.intra.stubs"],
Tobias Thierer3a4b4042018-09-30 17:42:10 +0100224 patch_module: "java.base",
Neil Fuller2f117722018-09-26 16:14:23 +0100225 system_modules: "core-intra-stubs-system-modules",
Neil Fullera179d2b2018-09-11 18:43:08 +0100226
Pete Bentley02d06db2019-04-15 17:48:45 +0100227 // Workaround for b/124476339: libjavacrypto is required for both APEX and
228 // hostdex builds, but adding a top-level required property results in
229 // it being installed to /system on Android.
230 // TODO(b/124476339): move required back to a top level property
231 target: {
232 hostdex: {
233 required: ["libjavacrypto"],
234 }
235 },
236
Vladimir Marko7d346782019-04-02 10:28:43 +0100237 permitted_packages: [
238 "android.net.ssl",
239 "com.android.org.conscrypt",
240 ],
Kun Niu7fd0a4b2019-07-02 10:16:55 -0700241
242 plugins: ["java_api_finder"],
Colin Cross8024b112017-10-09 13:34:58 -0700243}
244
245// A guaranteed unstripped version of conscrypt.
246// The build system may or may not strip the conscrypt jar, but this one will
247// not be stripped. See b/24535627.
248java_library {
249 name: "conscrypt-testdex",
Colin Cross291db152018-06-27 11:00:08 -0700250 installable: true,
Neil Fullera179d2b2018-09-11 18:43:08 +0100251
Paul Duffin31d1d152018-09-19 15:03:21 +0100252 static_libs: ["conscrypt"],
Vladimir Marko9f0e6cc2018-12-04 10:20:45 +0000253 dex_preopt: {
254 enabled: false,
255 },
Neil Fullera179d2b2018-09-11 18:43:08 +0100256
257 no_framework_libs: true,
258
Neil Fullera179d2b2018-09-11 18:43:08 +0100259 required: ["libjavacrypto"],
Colin Cross8024b112017-10-09 13:34:58 -0700260}
261
262// Platform conscrypt crypto JNI library
263cc_defaults {
264 name: "libjavacrypto-defaults",
265
266 cflags: [
267 "-Wall",
268 "-Wextra",
269 "-Werror",
270 "-Wunused",
271 "-fvisibility=hidden",
272 ],
273
274 srcs: ["common/src/jni/main/cpp/**/*.cc"],
275 include_dirs: [
276 "libcore/luni/src/main/native",
277 ],
278 local_include_dirs: ["common/src/jni/main/include"],
279}
280
281// Platform conscrypt crypto JNI library
282cc_library_shared {
283 name: "libjavacrypto",
284 host_supported: true,
285 defaults: ["libjavacrypto-defaults"],
286
287 cflags: ["-DJNI_JARJAR_PREFIX=com/android/"],
Orion Hodsonb5e43bd2019-01-27 10:57:34 +0000288 header_libs: ["libnativehelper_header_only"],
Colin Cross8024b112017-10-09 13:34:58 -0700289 shared_libs: [
290 "libcrypto",
Colin Cross8024b112017-10-09 13:34:58 -0700291 "liblog",
Colin Cross8024b112017-10-09 13:34:58 -0700292 "libssl",
293 ],
294
295 target: {
296 darwin: {
297 enabled: false,
298 },
299 },
300}
301
302// Unbundled Conscrypt jar
Neil Fullera179d2b2018-09-11 18:43:08 +0100303java_library {
Colin Cross8024b112017-10-09 13:34:58 -0700304 name: "conscrypt_unbundled",
305
306 srcs: [
307 "common/src/main/java/**/*.java",
308 "android/src/main/java/**/*.java",
Paul Duffin31d1d152018-09-19 15:03:21 +0100309 ":conscrypt-nojarjar_generated_constants",
Colin Cross8024b112017-10-09 13:34:58 -0700310 ],
311
312 libs: ["conscrypt-stubs"],
313
Colin Cross6ffb94e2017-10-20 13:44:10 -0700314 sdk_version: "current",
Colin Cross8024b112017-10-09 13:34:58 -0700315 java_version: "1.7",
316}
317
318// Stub library for unbundled builds
Neil Fullera179d2b2018-09-11 18:43:08 +0100319java_library {
Colin Cross8024b112017-10-09 13:34:58 -0700320 name: "conscrypt-stubs",
321
322 srcs: ["android-stub/src/main/java/**/*.java"],
323
Colin Cross6ffb94e2017-10-20 13:44:10 -0700324 sdk_version: "current",
Colin Cross8024b112017-10-09 13:34:58 -0700325 java_version: "1.7",
326}
327
328// Static unbundled Conscrypt crypto JNI library
329cc_library_static {
330 name: "libconscrypt_static",
331 defaults: ["libjavacrypto-defaults"],
332
333 cflags: [
334 "-DJNI_JARJAR_PREFIX=com/google/android/gms/",
335 "-DCONSCRYPT_UNBUNDLED",
336 "-DSTATIC_LIB",
337 ],
338
339 local_include_dirs: ["common/src/jni/unbundled/include"],
340
341 static_libs: [
342 "libssl",
343 "libcrypto",
344 ],
345 sdk_version: "9",
346 stl: "c++_shared",
347}
Colin Crossf569ee32018-09-11 22:38:08 -0700348
349
350// Make the conscrypt-tests library.
351java_test {
352 name: "conscrypt-tests",
353 hostdex: true,
354 srcs: [
Paul Duffin31d1d152018-09-19 15:03:21 +0100355 "repackaged/platform/src/test/java/**/*.java",
356 "repackaged/common/src/test/java/**/*.java",
357 "repackaged/openjdk-integ-tests/src/test/java/**/*.java",
358 "repackaged/testing/src/main/java/**/*.java",
Adam Vartanianacc0e552018-10-18 10:09:22 +0100359 "publicapi/src/test/java/**/*.java",
Colin Crossf569ee32018-09-11 22:38:08 -0700360 ],
361 java_resource_dirs: [
Paul Duffin31d1d152018-09-19 15:03:21 +0100362 // Resource directories do not need repackaging.
Colin Crossf569ee32018-09-11 22:38:08 -0700363 "openjdk/src/test/resources",
364 "openjdk-integ-tests/src/test/resources",
365 ],
Neil Fuller27e690d2018-10-10 12:58:01 +0100366
367 no_standard_libs: true,
Colin Crossf569ee32018-09-11 22:38:08 -0700368 libs: [
Neil Fuller27e690d2018-10-10 12:58:01 +0100369 "core-all",
Neil Fuller719e00f2018-10-19 09:32:43 +0100370 "conscrypt",
Colin Crossf569ee32018-09-11 22:38:08 -0700371 "junit",
372 "mockito-target-minus-junit4",
373 ],
Neil Fuller27e690d2018-10-10 12:58:01 +0100374 system_modules: "core-all-system-modules",
375
Colin Crossf569ee32018-09-11 22:38:08 -0700376 static_libs: [
Colin Crossf569ee32018-09-11 22:38:08 -0700377 "bouncycastle-unbundled",
378 "bouncycastle-bcpkix-unbundled",
379 "bouncycastle-ocsp-unbundled",
380 ],
381 javacflags: [
382 "-Xmaxwarns 9999999",
383 //"-Xlint:all",
384 //"-Xlint:-serial,-deprecation,-unchecked",
385 ],
386
387 required: ["libjavacrypto"],
Colin Crossf569ee32018-09-11 22:38:08 -0700388 java_version: "1.7",
389}
390
391// Make the conscrypt-benchmarks library.
392java_test {
393 name: "conscrypt-benchmarks",
394 srcs: [
Paul Duffin31d1d152018-09-19 15:03:21 +0100395 "repackaged/testing/src/main/java/**/*.java",
396 "repackaged/benchmark-base/src/main/java/**/*.java",
397 "repackaged/benchmark-android/src/main/java/**/*.java",
Colin Crossf569ee32018-09-11 22:38:08 -0700398 ],
Neil Fuller5d272352018-10-12 22:10:57 +0100399 no_standard_libs: true,
Colin Crossf569ee32018-09-11 22:38:08 -0700400 libs: [
Neil Fuller5d272352018-10-12 22:10:57 +0100401 "core-all",
Neil Fuller719e00f2018-10-19 09:32:43 +0100402 "conscrypt",
Colin Crossf569ee32018-09-11 22:38:08 -0700403 "junit",
404 "bouncycastle-unbundled",
405 "bouncycastle-bcpkix-unbundled",
406 "bouncycastle-ocsp-unbundled",
407 "caliper-api-target",
408 ],
Neil Fuller5d272352018-10-12 22:10:57 +0100409 system_modules: "core-all-system-modules",
410
Colin Crossf569ee32018-09-11 22:38:08 -0700411 javacflags: [
412 "-Xmaxwarns 9999999",
413 //"-Xlint:all",
414 //"-Xlint:-serial,-deprecation,-unchecked",
415 ],
416
417 required: ["libjavacrypto"],
Colin Crossf569ee32018-09-11 22:38:08 -0700418 java_version: "1.7",
419}