blob: 01ce29e46b86b130d01c5e1f26ffe4d4a10ff37a [file] [log] [blame]
Dan Willemsenf5a904e2018-10-23 01:02:44 -07001//
2// Copyright (C) 2015 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 Cross606913a2017-11-14 13:05:37 -080017// AIDL interface between libupdate_engine and framework.jar
18filegroup {
19 name: "libupdate_engine_aidl",
20 srcs: [
21 "binder_bindings/android/os/IUpdateEngine.aidl",
22 "binder_bindings/android/os/IUpdateEngineCallback.aidl",
23 ],
Dan Willemsenf5a904e2018-10-23 01:02:44 -070024 path: "binder_bindings",
25}
26
27cc_defaults {
28 name: "ue_defaults",
29
30 cflags: [
31 "-DUSE_BINDER=1",
32 "-DUSE_CHROME_NETWORK_PROXY=0",
33 "-DUSE_CHROME_KIOSK_APP=0",
34 "-DUSE_FEC=1",
35 "-DUSE_HWID_OVERRIDE=0",
36 "-DUSE_MTD=0",
37 "-DUSE_OMAHA=0",
38 "-D_FILE_OFFSET_BITS=64",
39 "-D_POSIX_C_SOURCE=199309L",
40 "-Wa,--noexecstack",
41 "-Wall",
42 "-Werror",
43 "-Wextra",
44 "-Wformat=2",
45 "-Wno-psabi",
46 "-Wno-unused-parameter",
47 "-ffunction-sections",
48 "-fstack-protector-strong",
49 "-fvisibility=hidden",
50 ],
51 cppflags: [
52 "-Wnon-virtual-dtor",
53 "-fno-strict-aliasing",
54 ],
55 include_dirs: ["system"],
56 local_include_dirs: ["client_library/include"],
57 static_libs: ["libgtest_prod"],
58 shared_libs: [
59 "libbrillo-stream",
60 "libbrillo",
61 "libchrome",
62 ],
63 ldflags: ["-Wl,--gc-sections"],
64
65 product_variables: {
66 pdk: {
67 enabled: false,
68 },
69 },
70
71 target: {
72 darwin: {
73 enabled: false,
74 },
75 },
76}
77
78// update_metadata-protos (type: static_library)
79// ========================================================
80// Protobufs.
81cc_defaults {
82 name: "update_metadata-protos_exports",
83
84 shared_libs: ["libprotobuf-cpp-lite"],
85}
86
87cc_library_static {
88 name: "update_metadata-protos",
89 host_supported: true,
90 recovery_available: true,
91
92 srcs: ["update_engine/update_metadata.proto"],
93 cflags: [
94 "-Wall",
95 "-Werror",
96 ],
97 proto: {
98 canonical_path_from_root: false,
99 export_proto_headers: true,
100 },
101}
102
103// libpayload_consumer (type: static_library)
104// ========================================================
105// The payload application component and common dependencies.
106cc_defaults {
107 name: "libpayload_consumer_exports",
108 defaults: ["update_metadata-protos_exports"],
109
110 static_libs: [
111 "update_metadata-protos",
112 "libxz",
113 "libbz",
114 "libbspatch",
115 "libbrotli",
116 "libfec_rs",
117 "libpuffpatch",
118 "libverity_tree",
119 ],
120 shared_libs: [
121 "libbase",
122 "libcrypto",
123 ],
124
125 target: {
126 android: {
127 shared_libs: ["libfec"],
128 },
129 },
130}
131
132cc_library_static {
133 name: "libpayload_consumer",
134 defaults: [
135 "ue_defaults",
136 "libpayload_consumer_exports",
137 ],
138 host_supported: true,
139 recovery_available: true,
140
141 srcs: [
142 "common/action_processor.cc",
143 "common/boot_control_stub.cc",
144 "common/clock.cc",
145 "common/constants.cc",
146 "common/cpu_limiter.cc",
147 "common/error_code_utils.cc",
148 "common/file_fetcher.cc",
149 "common/hash_calculator.cc",
150 "common/http_common.cc",
151 "common/http_fetcher.cc",
152 "common/hwid_override.cc",
153 "common/multi_range_http_fetcher.cc",
154 "common/platform_constants_android.cc",
155 "common/prefs.cc",
156 "common/proxy_resolver.cc",
157 "common/subprocess.cc",
158 "common/terminator.cc",
159 "common/utils.cc",
160 "payload_consumer/bzip_extent_writer.cc",
161 "payload_consumer/cached_file_descriptor.cc",
162 "payload_consumer/delta_performer.cc",
163 "payload_consumer/download_action.cc",
164 "payload_consumer/extent_reader.cc",
165 "payload_consumer/extent_writer.cc",
166 "payload_consumer/file_descriptor.cc",
167 "payload_consumer/file_descriptor_utils.cc",
168 "payload_consumer/file_writer.cc",
169 "payload_consumer/filesystem_verifier_action.cc",
170 "payload_consumer/install_plan.cc",
171 "payload_consumer/mount_history.cc",
172 "payload_consumer/payload_constants.cc",
173 "payload_consumer/payload_metadata.cc",
174 "payload_consumer/payload_verifier.cc",
175 "payload_consumer/postinstall_runner_action.cc",
176 "payload_consumer/verity_writer_android.cc",
177 "payload_consumer/xz_extent_writer.cc",
178 "payload_consumer/fec_file_descriptor.cc",
179 ],
180
181 target: {
182 host: {
183 cflags: [
184 "-UUSE_FEC",
185 "-DUSE_FEC=0",
186 ],
187 shared_libs: ["libfec"],
188 },
189 },
190}
191
192// libupdate_engine_boot_control (type: static_library)
193// ========================================================
194// A BootControl class implementation using Android's HIDL boot_control HAL.
195cc_defaults {
196 name: "libupdate_engine_boot_control_exports",
197 defaults: ["update_metadata-protos_exports"],
198
199 static_libs: ["update_metadata-protos"],
200 shared_libs: [
201 "libbootloader_message",
202 "libfs_mgr",
203 "libhwbinder",
204 "libhidlbase",
205 "liblp",
206 "libutils",
207 "android.hardware.boot@1.0",
208 ],
209}
210
211cc_library_static {
212 name: "libupdate_engine_boot_control",
213 defaults: [
214 "ue_defaults",
215 "libupdate_engine_boot_control_exports",
216 ],
217 recovery_available: true,
218
219 srcs: [
220 "boot_control_android.cc",
221 "dynamic_partition_control_android.cc",
222 ],
223}
224
225// libupdate_engine_android (type: static_library)
226// ========================================================
227// The main daemon static_library used in Android (non-Brillo). This only has a
228// loop to apply payloads provided by the upper layer via a Binder interface.
229cc_defaults {
230 name: "libupdate_engine_android_exports",
231 defaults: [
232 "ue_defaults",
233 "libpayload_consumer_exports",
234 "libupdate_engine_boot_control_exports",
235 ],
236
237 static_libs: [
238 "libpayload_consumer",
239 "libupdate_engine_boot_control",
240 ],
241 shared_libs: [
242 "libandroid_net",
243 "libbase",
244 "libbinder",
245 "libbinderwrapper",
246 "libbootloader_message",
247 "libbrillo-binder",
248 "libcurl",
249 "libcutils",
250 "liblog",
251 "libmetricslogger",
252 "libssl",
253 "libutils",
254 ],
255}
256
257cc_library_static {
258 name: "libupdate_engine_android",
259 defaults: [
260 "ue_defaults",
261 "libupdate_engine_android_exports",
262 ],
263
264 // TODO(deymo): Remove external/cros/system_api/dbus once the strings are moved
265 // out of the DBus interface.
266 include_dirs: ["external/cros/system_api/dbus"],
267
268 aidl: {
269 local_include_dirs: ["binder_bindings"],
270 export_aidl_headers: true,
271 },
272
273 srcs: [
274 ":libupdate_engine_aidl",
275 "binder_service_android.cc",
276 "certificate_checker.cc",
277 "daemon.cc",
278 "daemon_state_android.cc",
279 "hardware_android.cc",
280 "libcurl_http_fetcher.cc",
281 "metrics_reporter_android.cc",
282 "metrics_utils.cc",
283 "network_selector_android.cc",
284 "update_attempter_android.cc",
285 "update_boot_flags_action.cc",
286 "update_status_utils.cc",
287 ],
288}
289
290// update_engine (type: executable)
291// ========================================================
292// update_engine daemon.
293cc_binary {
294 name: "update_engine",
295 defaults: [
296 "ue_defaults",
297 "libupdate_engine_android_exports",
298 ],
299
300 static_libs: ["libupdate_engine_android"],
301 required: ["cacerts_google"],
302
303 srcs: ["main.cc"],
304 init_rc: ["update_engine.rc"],
305}
306
307// update_engine_sideload (type: executable)
308// ========================================================
309// A binary executable equivalent to update_engine daemon that installs an update
310// from a local file directly instead of running in the background. Used in
311// recovery image.
312cc_binary {
313 name: "update_engine_sideload",
314 defaults: [
315 "ue_defaults",
316 "update_metadata-protos_exports",
317 "libupdate_engine_boot_control_exports",
318 "libpayload_consumer_exports",
319 ],
320 recovery: true,
321
322 cflags: ["-D_UE_SIDELOAD"],
323 // TODO(deymo): Remove external/cros/system_api/dbus once the strings are moved
324 // out of the DBus interface.
325 include_dirs: ["external/cros/system_api/dbus"],
326
327 srcs: [
328 "hardware_android.cc",
329 "metrics_reporter_stub.cc",
330 "metrics_utils.cc",
331 "network_selector_stub.cc",
332 "sideload_main.cc",
333 "update_attempter_android.cc",
334 "update_boot_flags_action.cc",
335 "update_status_utils.cc",
336 ],
337
338 // Use commonly used shared libraries. libprotobuf-cpp-lite.so is filtered out,
339 // as it doesn't look beneficial to be installed separately due to its size. Note
340 // that we explicitly request their recovery variants, so that the expected files
341 // will be used and installed.
342 shared_libs: [
343 "libbase",
344 "liblog",
345 ],
346 static_libs: [
347 "libpayload_consumer",
348 "libupdate_engine_boot_control",
349 "update_metadata-protos",
350
351 // We add the static versions of the shared libraries that are not installed to
352 // recovery image due to size concerns. Need to include all the static library
353 // dependencies of these static libraries.
354 "libevent",
355 "libmodpb64",
356 "libgtest_prod",
357 "libprotobuf-cpp-lite",
358 "libbrillo-stream",
359 "libbrillo",
360 "libchrome",
361 ],
362 target: {
363 recovery: {
364 exclude_shared_libs: [
365 "libprotobuf-cpp-lite",
366 "libhwbinder",
367 "libbrillo-stream",
368 "libbrillo",
369 "libchrome",
370 ],
371 },
372 },
373
374 required: ["android.hardware.boot@1.0-impl-wrapper.recovery"],
375}
376
377// libupdate_engine_client (type: shared_library)
378// ========================================================
379cc_library_shared {
380 name: "libupdate_engine_client",
381
382 cflags: [
383 "-Wall",
384 "-Werror",
385 "-Wno-unused-parameter",
386 "-DUSE_BINDER=1",
387 ],
388 export_include_dirs: ["client_library/include"],
389 include_dirs: [
390 // TODO(deymo): Remove "external/cros/system_api/dbus" when dbus is not used.
391 "external/cros/system_api/dbus",
392 "system",
393 ],
394
395 aidl: {
396 local_include_dirs: ["binder_bindings"],
397 },
398
399 shared_libs: [
400 "libchrome",
401 "libbrillo",
402 "libbinder",
403 "libbrillo-binder",
404 "libutils",
405 ],
406
407 srcs: [
408 "binder_bindings/android/brillo/IUpdateEngine.aidl",
409 "binder_bindings/android/brillo/IUpdateEngineStatusCallback.aidl",
410 "client_library/client.cc",
411 "client_library/client_binder.cc",
412 "parcelable_update_engine_status.cc",
413 "update_status_utils.cc",
414 ],
415}
416
417// update_engine_client (type: executable)
418// ========================================================
419// update_engine console client.
420cc_binary {
421 name: "update_engine_client",
422 defaults: ["ue_defaults"],
423
424 // TODO(deymo): Remove external/cros/system_api/dbus once the strings are moved
425 // out of the DBus interface.
426 include_dirs: ["external/cros/system_api/dbus"],
427
428 shared_libs: [
429 "libbinder",
430 "libbinderwrapper",
431 "libbrillo-binder",
432 "libutils",
433 ],
434
435 aidl: {
436 local_include_dirs: ["binder_bindings"],
437 },
438
439 srcs: [
440 ":libupdate_engine_aidl",
441 "common/error_code_utils.cc",
442 "update_engine_client_android.cc",
443 "update_status_utils.cc",
444 ],
445}
446
447// libpayload_generator (type: static_library)
448// ========================================================
449// server-side code. This is used for delta_generator and unittests but not
450// for any client code.
451cc_defaults {
452 name: "libpayload_generator_exports",
453 defaults: [
454 "libpayload_consumer_exports",
455 "update_metadata-protos_exports",
456 ],
457
458 static_libs: [
459 "libavb",
460 "libbrotli",
461 "libbsdiff",
462 "libdivsufsort",
463 "libdivsufsort64",
464 "liblzma",
465 "libpayload_consumer",
466 "libpuffdiff",
467 "libverity_tree",
468 "update_metadata-protos",
469 ],
470 shared_libs: [
471 "libbase",
472 "libext2fs",
473 ],
474}
475
476cc_library_static {
477 name: "libpayload_generator",
478 defaults: [
479 "ue_defaults",
480 "libpayload_generator_exports",
481 ],
482 host_supported: true,
483
484 srcs: [
485 "payload_generator/ab_generator.cc",
486 "payload_generator/annotated_operation.cc",
487 "payload_generator/blob_file_writer.cc",
488 "payload_generator/block_mapping.cc",
489 "payload_generator/boot_img_filesystem.cc",
490 "payload_generator/bzip.cc",
491 "payload_generator/cycle_breaker.cc",
492 "payload_generator/deflate_utils.cc",
493 "payload_generator/delta_diff_generator.cc",
494 "payload_generator/delta_diff_utils.cc",
495 "payload_generator/ext2_filesystem.cc",
496 "payload_generator/extent_ranges.cc",
497 "payload_generator/extent_utils.cc",
498 "payload_generator/full_update_generator.cc",
499 "payload_generator/graph_types.cc",
500 "payload_generator/graph_utils.cc",
501 "payload_generator/inplace_generator.cc",
502 "payload_generator/mapfile_filesystem.cc",
503 "payload_generator/payload_file.cc",
504 "payload_generator/payload_generation_config_android.cc",
505 "payload_generator/payload_generation_config.cc",
506 "payload_generator/payload_signer.cc",
507 "payload_generator/raw_filesystem.cc",
508 "payload_generator/squashfs_filesystem.cc",
509 "payload_generator/tarjan.cc",
510 "payload_generator/topological_sort.cc",
511 "payload_generator/xz_android.cc",
512 ],
513}
514
515// delta_generator (type: executable)
516// ========================================================
517// server-side delta generator.
518cc_binary_host {
519 name: "delta_generator",
520 defaults: [
521 "ue_defaults",
522 "libpayload_generator_exports",
523 "libpayload_consumer_exports",
524 ],
525
526 static_libs: [
527 "libavb_host_sysdeps",
528 "libpayload_consumer",
529 "libpayload_generator",
530 ],
531
532 srcs: ["payload_generator/generate_delta_main.cc"],
533}
534
535cc_test {
536 name: "ue_unittest_delta_generator",
537 defaults: [
538 "ue_defaults",
539 "libpayload_generator_exports",
540 "libpayload_consumer_exports",
541 ],
542
543 static_libs: [
544 "libpayload_consumer",
545 "libpayload_generator",
546 ],
547
548 srcs: ["payload_generator/generate_delta_main.cc"],
549
550 gtest: false,
551 stem: "delta_generator",
552 relative_install_path: "update_engine_unittests",
553 no_named_install_directory: true,
554}
555
556// test_http_server (type: executable)
557// ========================================================
558// Test HTTP Server.
559cc_test {
560 name: "test_http_server",
561 defaults: ["ue_defaults"],
562 srcs: [
563 "common/http_common.cc",
564 "test_http_server.cc",
565 ],
566
567 gtest: false,
568 relative_install_path: "update_engine_unittests",
569 no_named_install_directory: true,
570}
571
572// test_subprocess (type: executable)
573// ========================================================
574// Test helper subprocess program.
575cc_test {
576 name: "test_subprocess",
577 defaults: ["ue_defaults"],
578 srcs: ["test_subprocess.cc"],
579
580 gtest: false,
581 relative_install_path: "update_engine_unittests",
582 no_named_install_directory: true,
583}
584
585// Public keys for unittests.
586// ========================================================
587genrule {
588 name: "ue_unittest_keys",
589 cmd: "openssl rsa -in $(location unittest_key.pem) -pubout -out $(location unittest_key.pub.pem) &&" +
590 "openssl rsa -in $(location unittest_key2.pem) -pubout -out $(location unittest_key2.pub.pem)",
591 srcs: [
592 "unittest_key.pem",
593 "unittest_key2.pem",
594 ],
595 out: [
596 "unittest_key.pub.pem",
597 "unittest_key2.pub.pem",
598 ],
599}
600
601// Sample images for unittests.
602// ========================================================
603// Extract sample image from the compressed sample_images.tar.bz2 file used by
604// the unittests.
605genrule {
606 name: "ue_unittest_disk_imgs",
607 cmd: "tar -jxf $(in) -C $(genDir)/gen disk_ext2_1k.img disk_ext2_4k.img disk_ext2_4k_empty.img disk_ext2_unittest.img",
608 srcs: ["sample_images/sample_images.tar.bz2"],
609 out: [
610 "gen/disk_ext2_1k.img",
611 "gen/disk_ext2_4k.img",
612 "gen/disk_ext2_4k_empty.img",
613 "gen/disk_ext2_unittest.img",
614 ],
615}
616
617// update_engine_unittests (type: executable)
618// ========================================================
619// Main unittest file.
620cc_test {
621 name: "update_engine_unittests",
622 defaults: [
623 "ue_defaults",
624 "libpayload_generator_exports",
625 "libupdate_engine_android_exports",
626 ],
627 required: [
628 "test_http_server",
629 "test_subprocess",
630 "ue_unittest_delta_generator",
631 ],
632
633 static_libs: [
634 "libpayload_generator",
635 "libbrillo-test-helpers",
636 "libgmock",
637 "libchrome_test_helpers",
638 "libupdate_engine_android",
639 ],
640 shared_libs: [
641 "libhidltransport",
642 ],
643
644 data: [
645 ":ue_unittest_disk_imgs",
646 ":ue_unittest_keys",
647 "unittest_key.pem",
648 "unittest_key2.pem",
649 "update_engine.conf",
650 ],
651
652 srcs: [
653 "boot_control_android_unittest.cc",
654 "certificate_checker_unittest.cc",
655 "common/action_pipe_unittest.cc",
656 "common/action_processor_unittest.cc",
657 "common/action_unittest.cc",
658 "common/cpu_limiter_unittest.cc",
659 "common/fake_prefs.cc",
660 "common/file_fetcher_unittest.cc",
661 "common/hash_calculator_unittest.cc",
662 "common/http_fetcher_unittest.cc",
663 "common/hwid_override_unittest.cc",
664 "common/mock_http_fetcher.cc",
665 "common/prefs_unittest.cc",
666 "common/proxy_resolver_unittest.cc",
667 "common/subprocess_unittest.cc",
668 "common/terminator_unittest.cc",
669 "common/test_utils.cc",
670 "common/utils_unittest.cc",
671 "payload_consumer/bzip_extent_writer_unittest.cc",
672 "payload_consumer/cached_file_descriptor_unittest.cc",
673 "payload_consumer/delta_performer_integration_test.cc",
674 "payload_consumer/delta_performer_unittest.cc",
675 "payload_consumer/extent_reader_unittest.cc",
676 "payload_consumer/extent_writer_unittest.cc",
677 "payload_consumer/fake_file_descriptor.cc",
678 "payload_consumer/file_descriptor_utils_unittest.cc",
679 "payload_consumer/file_writer_unittest.cc",
680 "payload_consumer/filesystem_verifier_action_unittest.cc",
681 "payload_consumer/postinstall_runner_action_unittest.cc",
682 "payload_consumer/verity_writer_android_unittest.cc",
683 "payload_consumer/xz_extent_writer_unittest.cc",
684 "payload_generator/ab_generator_unittest.cc",
685 "payload_generator/blob_file_writer_unittest.cc",
686 "payload_generator/block_mapping_unittest.cc",
687 "payload_generator/boot_img_filesystem_unittest.cc",
688 "payload_generator/cycle_breaker_unittest.cc",
689 "payload_generator/deflate_utils_unittest.cc",
690 "payload_generator/delta_diff_utils_unittest.cc",
691 "payload_generator/ext2_filesystem_unittest.cc",
692 "payload_generator/extent_ranges_unittest.cc",
693 "payload_generator/extent_utils_unittest.cc",
694 "payload_generator/fake_filesystem.cc",
695 "payload_generator/full_update_generator_unittest.cc",
696 "payload_generator/graph_utils_unittest.cc",
697 "payload_generator/inplace_generator_unittest.cc",
698 "payload_generator/mapfile_filesystem_unittest.cc",
699 "payload_generator/payload_file_unittest.cc",
700 "payload_generator/payload_generation_config_android_unittest.cc",
701 "payload_generator/payload_generation_config_unittest.cc",
702 "payload_generator/payload_signer_unittest.cc",
703 "payload_generator/squashfs_filesystem_unittest.cc",
704 "payload_generator/tarjan_unittest.cc",
705 "payload_generator/topological_sort_unittest.cc",
706 "payload_generator/zip_unittest.cc",
707 "testrunner.cc",
708 "update_attempter_android_unittest.cc",
709 ],
710}
711
712// Brillo update payload generation script
713// ========================================================
714cc_prebuilt_binary {
715 name: "brillo_update_payload",
716 device_supported: false,
717 host_supported: true,
718
719 srcs: ["scripts/brillo_update_payload"],
720 required: [
721 "delta_generator",
722 "shflags",
723 "simg2img",
724 ],
725
726 target: {
727 darwin: {
728 enabled: false,
729 },
730 },
Colin Cross606913a2017-11-14 13:05:37 -0800731}