blob: 4214f04b55b8ec176124dd70509b4db21008b8a5 [file] [log] [blame]
Tom Cherry8d225d82017-05-12 17:00:31 -07001//
Jan Monschcd7c9132020-05-08 02:34:40 +02002// Copyright (C) 2017-2020 The Android Open Source Project
Tom Cherry8d225d82017-05-12 17:00:31 -07003//
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
Bob Badourb30c9712021-02-12 14:49:55 -080017package {
18 default_applicable_licenses: ["external_avb_license"],
19}
20
21// Added automatically by a large-scale-change that took the approach of
22// 'apply every license found to every target'. While this makes sure we respect
23// every license restriction, it may not be entirely correct.
24//
25// e.g. GPL in an MIT project might only apply to the contrib/ directory.
26//
27// Please consider splitting the single license below into multiple licenses,
28// taking care not to lose any license_kind information, and overriding the
29// default license using the 'licenses: [...]' property on targets as needed.
30//
31// For unused files, consider creating a 'fileGroup' with "//visibility:private"
32// to attach the license to, and including a comment whether the files may be
33// used in the current project.
34// See: http://go/android-license-faq
35license {
36 name: "external_avb_license",
37 visibility: [":__subpackages__"],
38 license_kinds: [
39 "SPDX-license-identifier-Apache-2.0",
40 "SPDX-license-identifier-BSD",
41 "SPDX-license-identifier-MIT",
42 ],
43 license_text: [
44 "LICENSE",
45 ],
46}
47
ThiƩbaud Weksteen23dbe6e2020-05-15 15:52:02 +020048subdirs = [
49 "test",
50 "tools",
51]
Bryan Henry99df6c82018-10-25 15:00:43 -070052
Tom Cherry8d225d82017-05-12 17:00:31 -070053cc_defaults {
54 name: "avb_defaults",
55 cflags: [
56 "-D_FILE_OFFSET_BITS=64",
57 "-D_POSIX_C_SOURCE=199309L",
58 "-Wa,--noexecstack",
59 "-Werror",
60 "-Wall",
61 "-Wextra",
62 "-Wformat=2",
David Zeuthen047ecf72017-06-28 14:10:55 -040063 "-Wmissing-prototypes",
Tom Cherry8d225d82017-05-12 17:00:31 -070064 "-Wno-psabi",
65 "-Wno-unused-parameter",
Yi Konged46d642018-01-03 11:52:56 -080066 "-Wno-format",
Tom Cherry8d225d82017-05-12 17:00:31 -070067 "-ffunction-sections",
68 "-fstack-protector-strong",
69 "-g",
70 "-DAVB_ENABLE_DEBUG",
71 "-DAVB_COMPILATION",
72 ],
73 cppflags: [
74 "-Wnon-virtual-dtor",
75 "-fno-strict-aliasing",
76 ],
77 ldflags: [
78 "-Wl,--gc-sections",
79 "-rdynamic",
80 ],
81 target: {
82 darwin: {
83 enabled: false,
84 },
85 },
86}
87
88cc_defaults {
89 name: "avb_sources",
90 srcs: [
91 "libavb/avb_chain_partition_descriptor.c",
Lonnie Liu97740e52017-11-09 11:16:15 -080092 "libavb/avb_cmdline.c",
Tom Cherry8d225d82017-05-12 17:00:31 -070093 "libavb/avb_crc32.c",
94 "libavb/avb_crypto.c",
95 "libavb/avb_descriptor.c",
96 "libavb/avb_footer.c",
97 "libavb/avb_hash_descriptor.c",
98 "libavb/avb_hashtree_descriptor.c",
99 "libavb/avb_kernel_cmdline_descriptor.c",
100 "libavb/avb_property_descriptor.c",
101 "libavb/avb_rsa.c",
Tom Cherry8d225d82017-05-12 17:00:31 -0700102 "libavb/avb_slot_verify.c",
103 "libavb/avb_util.c",
104 "libavb/avb_vbmeta_image.c",
105 "libavb/avb_version.c",
106 ],
107}
108
Andrew Scull725bff42021-04-29 20:39:42 +0000109cc_defaults {
110 name: "avb_crypto_ops_impl_boringssl",
111 srcs: [
112 "libavb/boringssl/sha.c",
113 ],
114 local_include_dirs: [
115 "libavb/boringssl",
116 ],
117 shared_libs: [
118 "libcrypto",
119 ],
120}
121
122cc_defaults {
123 name: "avb_crypto_ops_impl_sha",
124 srcs: [
125 "libavb/sha/sha256_impl.c",
126 "libavb/sha/sha512_impl.c",
127 ],
128 local_include_dirs: [
129 "libavb/sha",
130 ],
131}
132
Alex Light027718c2019-03-07 16:44:46 -0800133python_binary_host {
Tom Cherry8d225d82017-05-12 17:00:31 -0700134 name: "avbtool",
Jan Monscha18b2ec2020-04-22 11:43:35 +0200135 srcs: ["avbtool.py"],
Alex Light027718c2019-03-07 16:44:46 -0800136 main: "avbtool.py",
Tom Cherry8d225d82017-05-12 17:00:31 -0700137 required: ["fec"],
Alex Light027718c2019-03-07 16:44:46 -0800138 version: {
139 py2: {
Jan Monsch13efb5f2020-04-22 17:34:24 +0200140 enabled: false,
Alex Light027718c2019-03-07 16:44:46 -0800141 },
142 py3: {
Jan Monsch13efb5f2020-04-22 17:34:24 +0200143 enabled: true,
Bowgo Tsaie4c67ec2021-01-28 13:29:01 +0800144 embedded_launcher: true,
Julien Desprez0d584b62021-01-15 17:56:56 -0800145 },
146 },
Julien Desprez809d2692021-01-27 14:07:27 -0800147 compile_multilib: "first",
Alex Light027718c2019-03-07 16:44:46 -0800148}
149
Jan Monsch0ec6b9a2020-01-29 14:38:46 +0100150python_library_host {
151 name: "aftl_proto",
152 srcs: [
Jan Monschfd21e7b2020-04-18 01:33:33 +0200153 "proto/api.proto",
Jan Monschfd21e7b2020-04-18 01:33:33 +0200154 "proto/crypto/sigpb/sigpb.proto",
155 "proto/crypto/keyspb/keyspb.proto",
156 "proto/trillian.proto",
Jan Monsch0ec6b9a2020-01-29 14:38:46 +0100157 ],
Jan Monschfd21e7b2020-04-18 01:33:33 +0200158 proto: {
159 include_dirs: [
160 "external/protobuf/src",
161 ],
162 local_include_dirs: [
163 "proto",
164 ],
165 canonical_path_from_root: false,
166 },
Jan Monsch0ec6b9a2020-01-29 14:38:46 +0100167 version: {
168 py2: {
Jan Monsch7ec41822020-04-15 01:16:44 +0200169 enabled: false,
Jan Monsch0ec6b9a2020-01-29 14:38:46 +0100170 },
171 py3: {
Jan Monsch7ec41822020-04-15 01:16:44 +0200172 enabled: true,
Jan Monsch0ec6b9a2020-01-29 14:38:46 +0100173 },
174 },
175}
176
Dan Austin715f5032020-01-08 10:18:05 -0800177python_binary_host {
178 name: "aftltool",
Jan Monsch5ac429e2019-12-11 19:04:26 +0100179 srcs: [
Jan Monschfd21e7b2020-04-18 01:33:33 +0200180 "aftltool.py",
Jan Monscha18b2ec2020-04-22 11:43:35 +0200181 "avbtool.py",
Dan Austin715f5032020-01-08 10:18:05 -0800182 ],
Jan Monsch0ec6b9a2020-01-29 14:38:46 +0100183 libs: [
184 "aftl_proto",
185 ],
Dan Austin715f5032020-01-08 10:18:05 -0800186 main: "aftltool.py",
Dan Austin715f5032020-01-08 10:18:05 -0800187 version: {
188 py2: {
Jan Monsch7ec41822020-04-15 01:16:44 +0200189 enabled: false,
Dan Austin715f5032020-01-08 10:18:05 -0800190 },
191 py3: {
Jan Monsch7ec41822020-04-15 01:16:44 +0200192 enabled: true,
Dan Austin715f5032020-01-08 10:18:05 -0800193 },
194 },
195}
196
197python_test_host {
198 name: "aftltool_test",
199 main: "aftltool_test.py",
200 srcs: [
Jan Monschfd21e7b2020-04-18 01:33:33 +0200201 "aftltool.py",
Dan Austin715f5032020-01-08 10:18:05 -0800202 "aftltool_test.py",
Jan Monscha18b2ec2020-04-22 11:43:35 +0200203 "avbtool.py",
Jan Monsch5ac429e2019-12-11 19:04:26 +0100204 ],
Jan Monsch0ec6b9a2020-01-29 14:38:46 +0100205 libs: [
206 "aftl_proto",
207 ],
208 data: [
Jan Monsch443bf322020-02-19 14:56:44 +0100209 "test/data/**/*.*",
Jan Monsch0ec6b9a2020-01-29 14:38:46 +0100210 ],
Julien Desprezd09c6ce2021-01-13 11:41:00 -0800211 test_options: {
212 unit_test: true,
213 },
Jan Monsch5ac429e2019-12-11 19:04:26 +0100214 version: {
215 py2: {
Jan Monsch7ec41822020-04-15 01:16:44 +0200216 enabled: false,
Jan Monsch5ac429e2019-12-11 19:04:26 +0100217 },
218 py3: {
Jan Monsch7ec41822020-04-15 01:16:44 +0200219 enabled: true,
Jan Monsch5ac429e2019-12-11 19:04:26 +0100220 },
221 },
222}
223
Tom Cherry8d225d82017-05-12 17:00:31 -0700224// Build libavb - this is a static library that depends
225// on only libc and doesn't drag in any other dependencies.
226cc_library_static {
227 name: "libavb",
228 defaults: [
229 "avb_defaults",
230 "avb_sources",
Andrew Scull725bff42021-04-29 20:39:42 +0000231 "avb_crypto_ops_impl_boringssl",
Tom Cherry8d225d82017-05-12 17:00:31 -0700232 ],
233 host_supported: true,
Inseob Kimf1bca772021-06-14 11:53:04 +0900234 ramdisk_available: true,
Jiyong Park44e07122018-05-24 14:07:34 +0900235 recovery_available: true,
Chin-Ting Kuo3cf5c722019-09-16 11:38:01 +0800236 header_libs: [
237 "avb_headers",
238 ],
239 export_header_lib_headers: ["avb_headers"],
Tom Cherry8d225d82017-05-12 17:00:31 -0700240 target: {
Andreas Gampe364a3422018-12-26 11:12:11 -0800241 linux: {
Tom Cherry8d225d82017-05-12 17:00:31 -0700242 srcs: ["libavb/avb_sysdeps_posix.c"],
243 },
Dan Willemsen34ec1232017-10-02 10:41:07 -0700244 linux_glibc: {
Tom Cherry8d225d82017-05-12 17:00:31 -0700245 cflags: ["-fno-stack-protector"],
246 },
247 },
248}
249
250// Build libavb_user for the target - in addition to libavb, it
251// includes libavb_ab, libavb_user and also depends on libbase and
252// libfs_mgr.
253cc_library_static {
254 name: "libavb_user",
255 defaults: [
256 "avb_defaults",
257 "avb_sources",
Andrew Scull725bff42021-04-29 20:39:42 +0000258 "avb_crypto_ops_impl_boringssl",
Tom Cherry8d225d82017-05-12 17:00:31 -0700259 ],
Jiyong Park44e07122018-05-24 14:07:34 +0900260 recovery_available: true,
Chin-Ting Kuo3cf5c722019-09-16 11:38:01 +0800261 header_libs: [
262 "avb_headers",
263 ],
264 export_header_lib_headers: ["avb_headers"],
Tom Cherry8d225d82017-05-12 17:00:31 -0700265 shared_libs: ["libbase"],
266 static_libs: ["libfs_mgr"],
David Zeuthen37f59462017-09-20 15:02:32 -0400267 cflags: [
268 "-DAVB_AB_I_UNDERSTAND_LIBAVB_AB_IS_DEPRECATED",
269 ],
Tom Cherry8d225d82017-05-12 17:00:31 -0700270 srcs: [
271 "libavb/avb_sysdeps_posix.c",
272 "libavb_ab/avb_ab_flow.c",
Bowgo Tsai84c610e2017-09-28 15:13:05 +0800273 "libavb_user/avb_ops_user.cpp",
Tom Cherry8d225d82017-05-12 17:00:31 -0700274 "libavb_user/avb_user_verity.c",
David Zeuthen0922bf82017-06-19 17:50:38 -0400275 "libavb_user/avb_user_verification.c",
Tom Cherry8d225d82017-05-12 17:00:31 -0700276 ],
277}
278
279cc_binary {
280 name: "avbctl",
281 defaults: ["avb_defaults"],
282 static_libs: [
283 "libavb_user",
284 "libfs_mgr",
285 ],
Andrew Scull725bff42021-04-29 20:39:42 +0000286 shared_libs: [
287 "libbase",
288 "libcrypto",
289 ],
Tom Cherry8d225d82017-05-12 17:00:31 -0700290 srcs: ["tools/avbctl/avbctl.cc"],
291}
292
293cc_library_host_static {
294 name: "libavb_ab_host",
295 defaults: ["avb_defaults"],
Chin-Ting Kuo3cf5c722019-09-16 11:38:01 +0800296 header_libs: [
297 "avb_headers",
298 ],
299 export_header_lib_headers: ["avb_headers"],
Tom Cherry8d225d82017-05-12 17:00:31 -0700300 cflags: [
301 "-fno-stack-protector",
David Zeuthen37f59462017-09-20 15:02:32 -0400302 "-DAVB_AB_I_UNDERSTAND_LIBAVB_AB_IS_DEPRECATED",
Tom Cherry8d225d82017-05-12 17:00:31 -0700303 ],
304 srcs: ["libavb_ab/avb_ab_flow.c"],
305}
306
Tianjie7f4e0002020-04-12 21:45:09 -0700307cc_library_static {
308 name: "libavb_aftl",
Dan Austin6bda9872020-01-22 19:14:15 -0800309 defaults: [
310 "avb_defaults",
ThiƩbaud Weksteen23dbe6e2020-05-15 15:52:02 +0200311 "avb_sources",
Andrew Scull725bff42021-04-29 20:39:42 +0000312 "avb_crypto_ops_impl_boringssl",
ThiƩbaud Weksteen23dbe6e2020-05-15 15:52:02 +0200313 ],
Tianjie7f4e0002020-04-12 21:45:09 -0700314 host_supported: true,
315 recovery_available: true,
Dan Austin6bda9872020-01-22 19:14:15 -0800316 header_libs: ["avb_headers"],
317 export_header_lib_headers: ["avb_headers"],
318 cflags: [
319 "-fno-stack-protector",
320 ],
321 srcs: [
ThiƩbaud Weksteen23dbe6e2020-05-15 15:52:02 +0200322 "libavb_aftl/avb_aftl_util.c",
323 "libavb_aftl/avb_aftl_validate.c",
324 "libavb_aftl/avb_aftl_verify.c",
Dan Austin6bda9872020-01-22 19:14:15 -0800325 ],
326}
327
ThiƩbaud Weksteenc5c42b52020-05-15 14:07:02 +0200328cc_fuzz {
329 name: "libavb_aftl_fuzzer",
330 defaults: ["avb_defaults"],
331 // The fuzzing entry point is declared and defined in the same file.
332 // Overwrite the behaviour introduced by avb_defaults.
333 cflags: [
334 "-Wno-missing-prototypes",
335 ],
336 srcs: [
337 "test/avb_aftl_fuzz.cc",
338 ],
ThiƩbaud Weksteen23dbe6e2020-05-15 15:52:02 +0200339 static_libs: [
340 "libavb",
341 "libavb_aftl",
342 ],
Andrew Scull725bff42021-04-29 20:39:42 +0000343 shared_libs: ["libcrypto"],
ThiƩbaud Weksteenc5c42b52020-05-15 14:07:02 +0200344 host_supported: true,
345 corpus: ["test/corpus/*"],
346 fuzz_config: {
ThiƩbaud Weksteen23dbe6e2020-05-15 15:52:02 +0200347 cc: [
348 "tweek@google.com",
349 "jpm@google.com",
350 ],
ThiƩbaud Weksteenc5c42b52020-05-15 14:07:02 +0200351 componentid: 685985,
ThiƩbaud Weksteen23dbe6e2020-05-15 15:52:02 +0200352 },
ThiƩbaud Weksteenc5c42b52020-05-15 14:07:02 +0200353}
354
Dan Austin6bda9872020-01-22 19:14:15 -0800355cc_library_host_static {
Tom Cherry8d225d82017-05-12 17:00:31 -0700356 name: "libavb_atx_host",
Andrew Scull725bff42021-04-29 20:39:42 +0000357 defaults: [
358 "avb_defaults",
359 "avb_crypto_ops_impl_boringssl",
360 ],
Chin-Ting Kuo3cf5c722019-09-16 11:38:01 +0800361 header_libs: [
362 "avb_headers",
363 ],
364 export_header_lib_headers: ["avb_headers"],
Tom Cherry8d225d82017-05-12 17:00:31 -0700365 cflags: [
366 "-fno-stack-protector",
367 ],
368 srcs: ["libavb_atx/avb_atx_validate.c"],
369}
370
371cc_library_host_static {
372 name: "libavb_host_sysdeps",
373 defaults: ["avb_defaults"],
Chin-Ting Kuo3cf5c722019-09-16 11:38:01 +0800374 header_libs: [
375 "avb_headers",
376 ],
377 export_header_lib_headers: ["avb_headers"],
Tom Cherry8d225d82017-05-12 17:00:31 -0700378 srcs: ["libavb/avb_sysdeps_posix.c"],
379}
380
Darren Krahn8160f362017-10-05 22:11:02 -0700381cc_library_host_static {
382 name: "libavb_things_example",
Andrew Scull725bff42021-04-29 20:39:42 +0000383 defaults: [
384 "avb_defaults",
385 "avb_crypto_ops_impl_boringssl",
386 ],
Chin-Ting Kuo3cf5c722019-09-16 11:38:01 +0800387 header_libs: [
388 "avb_headers",
389 ],
390 export_header_lib_headers: ["avb_headers"],
Darren Krahn8160f362017-10-05 22:11:02 -0700391 srcs: ["examples/things/avb_atx_slot_verify.c"],
392}
393
Andrew Scull725bff42021-04-29 20:39:42 +0000394cc_defaults {
395 name: "libavb_host_unittest_core",
Tom Cherry8d225d82017-05-12 17:00:31 -0700396 defaults: ["avb_defaults"],
397 required: [
398 "simg2img",
399 "img2simg",
400 "avbtool",
401 ],
Julien Desprez15e81d92021-01-21 11:29:14 -0800402 test_options: {
403 unit_test: true,
404 },
405 compile_multilib: "first",
Bryan Henryb24af102018-10-25 18:20:23 -0700406 data: [
407 "avbtool",
Jan Monschcd7c9132020-05-08 02:34:40 +0200408 "test/avbtool_signing_helper_test.py",
409 "test/avbtool_signing_helper_with_files_test.py",
Bryan Henryb24af102018-10-25 18:20:23 -0700410 "test/data/*",
411 ],
412 test_config: "test/libavb_host_unittest.xml",
Bryan Henryd7156cd2019-01-24 16:32:52 -0800413 test_suites: ["general-tests"],
Tom Cherry8d225d82017-05-12 17:00:31 -0700414 static_libs: [
415 "libavb",
416 "libavb_ab_host",
Tianjie7f4e0002020-04-12 21:45:09 -0700417 "libavb_aftl",
Tom Cherry8d225d82017-05-12 17:00:31 -0700418 "libavb_atx_host",
Darren Krahn8160f362017-10-05 22:11:02 -0700419 "libavb_things_example",
Tom Cherry8d225d82017-05-12 17:00:31 -0700420 "libgmock_host",
421 "libgtest_host",
422 ],
423 shared_libs: [
Bryan Henry573bb4c2018-12-01 11:42:18 -0800424 "libbase",
Tom Cherry8d225d82017-05-12 17:00:31 -0700425 "libchrome",
426 "libcrypto",
427 ],
David Zeuthen047ecf72017-06-28 14:10:55 -0400428 cflags: [
ThiƩbaud Weksteen23dbe6e2020-05-15 15:52:02 +0200429 "-Wno-missing-prototypes",
430 "-DAVB_AB_I_UNDERSTAND_LIBAVB_AB_IS_DEPRECATED",
David Zeuthen047ecf72017-06-28 14:10:55 -0400431 ],
Tom Cherry8d225d82017-05-12 17:00:31 -0700432 srcs: [
433 "test/avb_ab_flow_unittest.cc",
Jan Monscha86b6142020-02-17 12:44:41 +0100434 "test/avb_aftl_util_unittest.cc",
Dan Austin6bda9872020-01-22 19:14:15 -0800435 "test/avb_aftl_validate_unittest.cc",
Dan Austina4fc5952020-02-14 11:32:17 -0800436 "test/avb_aftl_verify_unittest.cc",
Tom Cherry8d225d82017-05-12 17:00:31 -0700437 "test/avb_atx_validate_unittest.cc",
Darren Krahn8160f362017-10-05 22:11:02 -0700438 "test/avb_atx_slot_verify_unittest.cc",
Andrew Scull725bff42021-04-29 20:39:42 +0000439 "test/avb_crypto_ops_unittest.cc",
Tom Cherry8d225d82017-05-12 17:00:31 -0700440 "test/avb_slot_verify_unittest.cc",
441 "test/avb_unittest_util.cc",
442 "test/avb_util_unittest.cc",
443 "test/avb_vbmeta_image_unittest.cc",
444 "test/avbtool_unittest.cc",
445 "test/fake_avb_ops.cc",
446 "test/avb_sysdeps_posix_testing.cc",
447 ],
Tom Cherry8d225d82017-05-12 17:00:31 -0700448}
449
Andrew Scull725bff42021-04-29 20:39:42 +0000450cc_test_host {
451 name: "libavb_host_unittest",
452 defaults: [
453 "avb_crypto_ops_impl_boringssl",
454 "libavb_host_unittest_core",
455 ],
456 data: [
457 ":img2simg",
458 ":simg2img",
459 ":fec",
460 ],
461}
462
463cc_test_host {
464 name: "libavb_host_unittest_sha",
465 defaults: [
466 "avb_crypto_ops_impl_sha",
467 "libavb_host_unittest_core",
468 ],
469 data: [
470 ":img2simg",
471 ":simg2img",
472 ":fec",
473 ],
474}
475
Tom Cherry8d225d82017-05-12 17:00:31 -0700476cc_library_host_static {
477 name: "libavb_host_user_code_test",
478 defaults: ["avb_defaults"],
David Zeuthen37f59462017-09-20 15:02:32 -0400479 cflags: [
480 "-DAVB_AB_I_UNDERSTAND_LIBAVB_AB_IS_DEPRECATED",
481 ],
Tom Cherry8d225d82017-05-12 17:00:31 -0700482 srcs: ["test/user_code_test.cc"],
483}
484
485cc_library {
486 name: "bootctrl.avb",
487 defaults: ["avb_defaults"],
488 relative_install_path: "hw",
489 static_libs: [
490 "libavb_user",
491 "libfs_mgr",
492 ],
493 shared_libs: [
494 "libbase",
Andrew Scull725bff42021-04-29 20:39:42 +0000495 "libcrypto",
Tom Cherry8d225d82017-05-12 17:00:31 -0700496 "libcutils",
497 ],
David Zeuthen37f59462017-09-20 15:02:32 -0400498 cflags: [
499 "-DAVB_AB_I_UNDERSTAND_LIBAVB_AB_IS_DEPRECATED",
500 ],
Tom Cherry8d225d82017-05-12 17:00:31 -0700501 srcs: ["boot_control/boot_control_avb.c"],
502}
Chin-Ting Kuo3cf5c722019-09-16 11:38:01 +0800503
504cc_library_headers {
505 name: "avb_headers",
506 host_supported: true,
Inseob Kimf1bca772021-06-14 11:53:04 +0900507 ramdisk_available: true,
Chin-Ting Kuo3cf5c722019-09-16 11:38:01 +0800508 recovery_available: true,
509 export_include_dirs: ["."],
510 target: {
511 windows: {
512 enabled: true,
513 },
514 },
515}