blob: 2ee0b9e26bc7e28782e80da0df3e7028300ad07f [file] [log] [blame]
Keigo Oka0ede7bd2019-05-13 17:35:13 +09001#
2# Copyright (C) 2019 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
17import("//common-mk/generate-dbus-adaptors.gni")
18import("//common-mk/generate-dbus-proxies.gni")
19import("//common-mk/openssl_pem.gni")
20import("//common-mk/pkg_config.gni")
21import("//common-mk/proto_library.gni")
22import("//update_engine/tar_bunzip2.gni")
23
24group("all") {
25 deps = [
26 ":delta_generator",
27 ":libpayload_consumer",
28 ":libpayload_generator",
29 ":libupdate_engine",
30 ":libupdate_engine_client",
31 ":update_engine",
32 ":update_engine-dbus-adaptor",
33 ":update_engine-dbus-kiosk-app-client",
34 ":update_engine_client",
35 ":update_metadata-protos",
36 ]
37
38 if (use.test) {
39 deps += [
40 ":test_http_server",
41 ":test_subprocess",
42 ":update_engine-test_images",
43 ":update_engine-testkeys",
44 ":update_engine_test_libs",
45 ":update_engine_unittests",
46 ]
47 }
48
49 if (use.fuzzer) {
50 deps += [ ":update_engine_omaha_request_action_fuzzer" ]
51 }
52}
53
54pkg_config("target_defaults") {
55 cflags_cc = [
56 "-fno-strict-aliasing",
57 "-Wnon-virtual-dtor",
58 ]
59 cflags = [
60 "-g",
61 "-ffunction-sections",
62 "-Wall",
63 "-Wextra",
64 "-Werror",
65 "-Wno-unused-parameter",
66 ]
67 ldflags = [ "-Wl,--gc-sections" ]
68 defines = [
69 "__CHROMEOS__",
70 "_FILE_OFFSET_BITS=64",
71 "_POSIX_C_SOURCE=199309L",
Amin Hassanife052b22019-06-20 15:02:53 -070072 "USE_BINDER=0",
Keigo Oka0ede7bd2019-05-13 17:35:13 +090073 "USE_DBUS=${use.dbus}",
74 "USE_FEC=0",
75 "USE_HWID_OVERRIDE=${use.hwid_override}",
76 "USE_CHROME_KIOSK_APP=${use.chrome_kiosk_app}",
77 "USE_CHROME_NETWORK_PROXY=${use.chrome_network_proxy}",
78 "USE_MTD=${use.mtd}",
79 "USE_OMAHA=1",
80 "USE_SHILL=1",
81 ]
82 include_dirs = [
83 # We need this include dir because we include all the local code as
84 # "update_engine/...".
85 "${platform2_root}",
86 "${platform2_root}/update_engine/client_library/include",
87 ]
88 pkg_deps = [
89 "libbrillo-${libbase_ver}",
90 "libchrome-${libbase_ver}",
91
92 # system_api depends on protobuf (or protobuf-lite). It must appear
93 # before protobuf here or the linker flags won't be in the right
94 # order.
95 "system_api",
96 "protobuf-lite",
97 ]
98}
99
100# Protobufs.
101proto_library("update_metadata-protos") {
102 proto_in_dir = "."
103 proto_out_dir = "include/update_engine"
104 sources = [
105 "update_metadata.proto",
106 ]
107}
108
109# Chrome D-Bus bindings.
110generate_dbus_adaptors("update_engine-dbus-adaptor") {
111 dbus_adaptors_out_dir = "include/dbus_bindings"
112 sources = [
113 "dbus_bindings/org.chromium.UpdateEngineInterface.dbus-xml",
114 ]
115}
116
117generate_dbus_proxies("update_engine-dbus-kiosk-app-client") {
118 mock_output_file = "include/kiosk-app/dbus-proxy-mocks.h"
119 proxy_output_file = "include/kiosk-app/dbus-proxies.h"
120 sources = [
121 "dbus_bindings/org.chromium.KioskAppService.dbus-xml",
122 ]
123}
124
125# The payload application component and common dependencies.
126static_library("libpayload_consumer") {
127 sources = [
128 "common/action_processor.cc",
129 "common/boot_control_stub.cc",
130 "common/clock.cc",
131 "common/constants.cc",
132 "common/cpu_limiter.cc",
133 "common/error_code_utils.cc",
134 "common/hash_calculator.cc",
135 "common/http_common.cc",
136 "common/http_fetcher.cc",
137 "common/hwid_override.cc",
138 "common/multi_range_http_fetcher.cc",
139 "common/platform_constants_chromeos.cc",
140 "common/prefs.cc",
141 "common/proxy_resolver.cc",
142 "common/subprocess.cc",
143 "common/terminator.cc",
144 "common/utils.cc",
145 "payload_consumer/bzip_extent_writer.cc",
146 "payload_consumer/cached_file_descriptor.cc",
147 "payload_consumer/delta_performer.cc",
148 "payload_consumer/download_action.cc",
149 "payload_consumer/extent_reader.cc",
150 "payload_consumer/extent_writer.cc",
151 "payload_consumer/file_descriptor.cc",
152 "payload_consumer/file_descriptor_utils.cc",
153 "payload_consumer/file_writer.cc",
154 "payload_consumer/filesystem_verifier_action.cc",
155 "payload_consumer/install_plan.cc",
156 "payload_consumer/mount_history.cc",
157 "payload_consumer/payload_constants.cc",
158 "payload_consumer/payload_metadata.cc",
159 "payload_consumer/payload_verifier.cc",
160 "payload_consumer/postinstall_runner_action.cc",
161 "payload_consumer/verity_writer_stub.cc",
162 "payload_consumer/xz_extent_writer.cc",
163 ]
164 configs += [ ":target_defaults" ]
165 libs = [
166 "bz2",
167 "rt",
168 ]
169
170 # TODO(deymo): Remove unused dependencies once we stop including files
171 # from the root directory.
172 all_dependent_pkg_deps = [
173 "libcrypto",
174 "xz-embedded",
175 "libbspatch",
176 "libpuffpatch",
177 ]
178 deps = [
179 ":update_metadata-protos",
180 ]
181
182 if (use.mtd) {
183 sources += [ "payload_consumer/mtd_file_descriptor.cc" ]
184 libs += [ "mtdutils" ]
185 }
186}
187
188# The main daemon static_library with all the code used to check for updates
189# with Omaha and expose a DBus daemon.
190static_library("libupdate_engine") {
191 sources = [
192 "boot_control_chromeos.cc",
193 "certificate_checker.cc",
194 "common_service.cc",
195 "connection_manager.cc",
196 "connection_utils.cc",
197 "daemon.cc",
198 "dbus_connection.cc",
199 "dbus_service.cc",
200 "hardware_chromeos.cc",
201 "image_properties_chromeos.cc",
202 "libcurl_http_fetcher.cc",
203 "metrics_reporter_omaha.cc",
204 "metrics_utils.cc",
205 "omaha_request_action.cc",
206 "omaha_request_builder_xml.cc",
207 "omaha_request_params.cc",
208 "omaha_response_handler_action.cc",
209 "omaha_utils.cc",
210 "p2p_manager.cc",
211 "payload_state.cc",
212 "power_manager_chromeos.cc",
213 "real_system_state.cc",
214 "shill_proxy.cc",
215 "update_attempter.cc",
216 "update_boot_flags_action.cc",
217 "update_manager/boxed_value.cc",
218 "update_manager/chromeos_policy.cc",
219 "update_manager/default_policy.cc",
220 "update_manager/enough_slots_ab_updates_policy_impl.cc",
221 "update_manager/enterprise_device_policy_impl.cc",
222 "update_manager/evaluation_context.cc",
223 "update_manager/interactive_update_policy_impl.cc",
224 "update_manager/next_update_check_policy_impl.cc",
225 "update_manager/official_build_check_policy_impl.cc",
226 "update_manager/out_of_box_experience_policy_impl.cc",
227 "update_manager/policy.cc",
228 "update_manager/policy_test_utils.cc",
229 "update_manager/real_config_provider.cc",
230 "update_manager/real_device_policy_provider.cc",
231 "update_manager/real_random_provider.cc",
232 "update_manager/real_shill_provider.cc",
233 "update_manager/real_system_provider.cc",
234 "update_manager/real_time_provider.cc",
235 "update_manager/real_updater_provider.cc",
236 "update_manager/staging_utils.cc",
237 "update_manager/state_factory.cc",
238 "update_manager/update_manager.cc",
239 "update_manager/update_time_restrictions_policy_impl.cc",
240 "update_manager/weekly_time.cc",
241 "update_status_utils.cc",
242 ]
243 configs += [ ":target_defaults" ]
244 libs = [
245 "bz2",
246 "policy-${libbase_ver}",
247 "rootdev",
248 "rt",
249 ]
250 all_dependent_pkg_deps = [
251 "dbus-1",
252 "expat",
253 "libcurl",
254 "libdebugd-client",
255 "libmetrics-${libbase_ver}",
256 "libpower_manager-client",
257 "libsession_manager-client",
258 "libshill-client",
259 "libssl",
260 "libupdate_engine-client",
261 "vboot_host",
262 ]
263 deps = [
264 ":libpayload_consumer",
265 ":update_engine-dbus-adaptor",
266 ":update_metadata-protos",
267 ]
268
269 if (use.dlc) {
270 all_dependent_pkg_deps += [ "libdlcservice-client" ]
271 }
272
273 if (use.chrome_network_proxy) {
274 sources += [ "chrome_browser_proxy_resolver.cc" ]
275 }
276
277 if (use.chrome_kiosk_app) {
278 deps += [ ":update_engine-dbus-kiosk-app-client" ]
279 }
280
281 if (use.dlc) {
282 sources += [ "dlcservice_chromeos.cc" ]
283 } else {
284 sources += [ "common/dlcservice_stub.cc" ]
285 }
286}
287
288# update_engine daemon.
289executable("update_engine") {
290 sources = [
291 "main.cc",
292 ]
293 configs += [ ":target_defaults" ]
294 deps = [
295 ":libupdate_engine",
296 ]
297}
298
299# update_engine client library.
300static_library("libupdate_engine_client") {
301 sources = [
302 "client_library/client.cc",
303 "client_library/client_dbus.cc",
304 "update_status_utils.cc",
305 ]
306 include_dirs = [ "client_library/include" ]
307 configs += [ ":target_defaults" ]
308 pkg_deps = [
309 "dbus-1",
310 "libupdate_engine-client",
311 ]
312}
313
314# update_engine console client.
315executable("update_engine_client") {
316 sources = [
317 "common/error_code_utils.cc",
318 "omaha_utils.cc",
319 "update_engine_client.cc",
320 ]
321 configs += [ ":target_defaults" ]
322 deps = [
323 ":libupdate_engine_client",
324 ]
325}
326
327# server-side code. This is used for delta_generator and unittests but not
328# for any client code.
329static_library("libpayload_generator") {
330 sources = [
331 "common/file_fetcher.cc",
332 "payload_generator/ab_generator.cc",
333 "payload_generator/annotated_operation.cc",
334 "payload_generator/blob_file_writer.cc",
335 "payload_generator/block_mapping.cc",
336 "payload_generator/boot_img_filesystem.cc",
337 "payload_generator/bzip.cc",
338 "payload_generator/cycle_breaker.cc",
339 "payload_generator/deflate_utils.cc",
340 "payload_generator/delta_diff_generator.cc",
341 "payload_generator/delta_diff_utils.cc",
342 "payload_generator/ext2_filesystem.cc",
343 "payload_generator/extent_ranges.cc",
344 "payload_generator/extent_utils.cc",
345 "payload_generator/full_update_generator.cc",
346 "payload_generator/graph_types.cc",
347 "payload_generator/graph_utils.cc",
348 "payload_generator/inplace_generator.cc",
349 "payload_generator/mapfile_filesystem.cc",
350 "payload_generator/payload_file.cc",
351 "payload_generator/payload_generation_config.cc",
352 "payload_generator/payload_generation_config_chromeos.cc",
Amin Hassani79821002019-05-06 17:40:49 -0700353 "payload_generator/payload_properties.cc",
Keigo Oka0ede7bd2019-05-13 17:35:13 +0900354 "payload_generator/payload_signer.cc",
355 "payload_generator/raw_filesystem.cc",
356 "payload_generator/squashfs_filesystem.cc",
357 "payload_generator/tarjan.cc",
358 "payload_generator/topological_sort.cc",
359 "payload_generator/xz_chromeos.cc",
360 ]
361 configs += [ ":target_defaults" ]
362 all_dependent_pkg_deps = [
363 "ext2fs",
364 "libbsdiff",
365 "libpuffdiff",
366 "liblzma",
367 ]
368 deps = [
369 ":libpayload_consumer",
370 ":update_metadata-protos",
371 ]
372}
373
374# server-side delta generator.
375executable("delta_generator") {
376 sources = [
377 "payload_generator/generate_delta_main.cc",
378 ]
379 configs += [ ":target_defaults" ]
380 configs -= [ "//common-mk:pie" ]
381 deps = [
382 ":libpayload_consumer",
383 ":libpayload_generator",
384 ]
385}
386
387if (use.test || use.fuzzer) {
388 static_library("update_engine_test_libs") {
389 sources = [
390 "common/fake_prefs.cc",
391 "common/mock_http_fetcher.cc",
392 "common/test_utils.cc",
393 "fake_shill_proxy.cc",
394 "fake_system_state.cc",
395 "payload_consumer/fake_file_descriptor.cc",
396 "payload_generator/fake_filesystem.cc",
397 "update_manager/umtest_utils.cc",
398 ]
399 all_dependent_configs = [ "//common-mk:test" ]
400 configs += [ ":target_defaults" ]
401 pkg_deps = [ "libshill-client-test" ]
402 deps = [
403 ":libupdate_engine",
404 ]
405 }
406}
407
408if (use.test) {
409 # Public keys used for unit testing.
410 genopenssl_key("update_engine-testkeys") {
411 openssl_pem_in_dir = "."
412 openssl_pem_out_dir = "include/update_engine"
413 sources = [
414 "unittest_key.pem",
415 "unittest_key2.pem",
416 ]
417 }
418
419 # Unpacks sample images used for testing.
420 tar_bunzip2("update_engine-test_images") {
421 image_out_dir = "."
422 sources = [
423 "sample_images/sample_images.tar.bz2",
424 ]
425 }
426
427 # Test HTTP Server.
428 executable("test_http_server") {
429 sources = [
430 "common/http_common.cc",
431 "test_http_server.cc",
432 ]
433 configs += [ ":target_defaults" ]
434 }
435
436 # Test subprocess helper.
437 executable("test_subprocess") {
438 sources = [
439 "test_subprocess.cc",
440 ]
441 configs += [ ":target_defaults" ]
442 }
443
444 # Main unittest file.
445 executable("update_engine_unittests") {
446 sources = [
447 "boot_control_chromeos_unittest.cc",
448 "certificate_checker_unittest.cc",
449 "common/action_pipe_unittest.cc",
450 "common/action_processor_unittest.cc",
451 "common/action_unittest.cc",
452 "common/cpu_limiter_unittest.cc",
453 "common/hash_calculator_unittest.cc",
454 "common/http_fetcher_unittest.cc",
455 "common/hwid_override_unittest.cc",
456 "common/prefs_unittest.cc",
457 "common/proxy_resolver_unittest.cc",
458 "common/subprocess_unittest.cc",
459 "common/terminator_unittest.cc",
460 "common/utils_unittest.cc",
461 "common_service_unittest.cc",
462 "connection_manager_unittest.cc",
463 "hardware_chromeos_unittest.cc",
464 "image_properties_chromeos_unittest.cc",
465 "metrics_reporter_omaha_unittest.cc",
466 "metrics_utils_unittest.cc",
467 "omaha_request_action_unittest.cc",
468 "omaha_request_builder_xml_unittest.cc",
469 "omaha_request_params_unittest.cc",
470 "omaha_response_handler_action_unittest.cc",
471 "omaha_utils_unittest.cc",
472 "p2p_manager_unittest.cc",
473 "payload_consumer/bzip_extent_writer_unittest.cc",
474 "payload_consumer/cached_file_descriptor_unittest.cc",
475 "payload_consumer/delta_performer_integration_test.cc",
476 "payload_consumer/delta_performer_unittest.cc",
477 "payload_consumer/download_action_unittest.cc",
478 "payload_consumer/extent_reader_unittest.cc",
479 "payload_consumer/extent_writer_unittest.cc",
480 "payload_consumer/file_descriptor_utils_unittest.cc",
481 "payload_consumer/file_writer_unittest.cc",
482 "payload_consumer/filesystem_verifier_action_unittest.cc",
483 "payload_consumer/postinstall_runner_action_unittest.cc",
484 "payload_consumer/xz_extent_writer_unittest.cc",
485 "payload_generator/ab_generator_unittest.cc",
486 "payload_generator/blob_file_writer_unittest.cc",
487 "payload_generator/block_mapping_unittest.cc",
488 "payload_generator/boot_img_filesystem_unittest.cc",
489 "payload_generator/cycle_breaker_unittest.cc",
490 "payload_generator/deflate_utils_unittest.cc",
491 "payload_generator/delta_diff_utils_unittest.cc",
492 "payload_generator/ext2_filesystem_unittest.cc",
493 "payload_generator/extent_ranges_unittest.cc",
494 "payload_generator/extent_utils_unittest.cc",
495 "payload_generator/full_update_generator_unittest.cc",
496 "payload_generator/graph_utils_unittest.cc",
497 "payload_generator/inplace_generator_unittest.cc",
498 "payload_generator/mapfile_filesystem_unittest.cc",
499 "payload_generator/payload_file_unittest.cc",
500 "payload_generator/payload_generation_config_unittest.cc",
501 "payload_generator/payload_signer_unittest.cc",
502 "payload_generator/squashfs_filesystem_unittest.cc",
503 "payload_generator/tarjan_unittest.cc",
504 "payload_generator/topological_sort_unittest.cc",
505 "payload_generator/zip_unittest.cc",
506 "payload_state_unittest.cc",
507 "testrunner.cc",
508 "update_attempter_unittest.cc",
509 "update_boot_flags_action_unittest.cc",
510 "update_manager/boxed_value_unittest.cc",
511 "update_manager/chromeos_policy_unittest.cc",
512 "update_manager/evaluation_context_unittest.cc",
513 "update_manager/generic_variables_unittest.cc",
514 "update_manager/prng_unittest.cc",
515 "update_manager/real_device_policy_provider_unittest.cc",
516 "update_manager/real_random_provider_unittest.cc",
517 "update_manager/real_shill_provider_unittest.cc",
518 "update_manager/real_system_provider_unittest.cc",
519 "update_manager/real_time_provider_unittest.cc",
520 "update_manager/real_updater_provider_unittest.cc",
521 "update_manager/staging_utils_unittest.cc",
522 "update_manager/update_manager_unittest.cc",
523 "update_manager/update_time_restrictions_policy_impl_unittest.cc",
524 "update_manager/variable_unittest.cc",
525 "update_manager/weekly_time_unittest.cc",
526 ]
527 configs += [ ":target_defaults" ]
528 pkg_deps = [
529 "libbrillo-test-${libbase_ver}",
530 "libchrome-test-${libbase_ver}",
531 "libdebugd-client-test",
532 "libpower_manager-client-test",
533 "libsession_manager-client-test",
534 "libshill-client-test",
535 ]
536 deps = [
537 ":libpayload_generator",
538 ":libupdate_engine",
539 ":update_engine_test_libs",
540 ]
541 }
542}
543
544# Fuzzer target.
545if (use.fuzzer) {
546 executable("update_engine_omaha_request_action_fuzzer") {
547 sources = [
548 "omaha_request_action_fuzzer.cc",
549 ]
550 configs += [
551 "//common-mk/common_fuzzer",
552 ":target_defaults",
553 ]
554 pkg_deps = [
555 "libbrillo-test-${libbase_ver}",
556 "libchrome-test-${libbase_ver}",
557 ]
558 deps = [
559 ":libupdate_engine",
560 ":update_engine_test_libs",
561 ]
562 }
563}