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