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