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  'target_defaults': {
18    'variables': {
19      'deps': [
20        'libbrillo-<(libbase_ver)',
21        'libchrome-<(libbase_ver)',
22      ],
23      # The -DUSE_* flags are passed from platform2.py. We use sane defaults
24      # here when these USE flags are not defined. You can set the default value
25      # for the USE flag in the ebuild.
26      'USE_binder%': '0',
27      'USE_dbus%': '1',
28      'USE_hwid_override%': '0',
29      'USE_libcros%': '1',
30      'USE_mtd%': '0',
31      'USE_power_management%': '0',
32      'USE_buffet%': '0',
33    },
34    'cflags': [
35      '-g',
36      '-ffunction-sections',
37      '-Wall',
38      '-Wextra',
39      '-Werror',
40      '-Wno-unused-parameter',
41    ],
42    'cflags_cc': [
43      '-fno-strict-aliasing',
44      '-Wnon-virtual-dtor',
45    ],
46    'ldflags': [
47      '-Wl,--gc-sections',
48    ],
49    'defines': [
50      '__CHROMEOS__',
51      '_FILE_OFFSET_BITS=64',
52      '_POSIX_C_SOURCE=199309L',
53      'USE_BINDER=<(USE_binder)',
54      'USE_DBUS=<(USE_dbus)',
55      'USE_HWID_OVERRIDE=<(USE_hwid_override)',
56      'USE_LIBCROS=<(USE_libcros)',
57      'USE_MTD=<(USE_mtd)',
58      'USE_POWER_MANAGEMENT=<(USE_power_management)',
59      'USE_WEAVE=<(USE_buffet)',
60    ],
61    'include_dirs': [
62      # We need this include dir because we include all the local code as
63      # "update_engine/...".
64      '<(platform2_root)/../aosp/system',
65      '<(platform2_root)/../aosp/system/update_engine/client_library/include',
66    ],
67  },
68  'targets': [
69    # Protobufs.
70    {
71      'target_name': 'update_metadata-protos',
72      'type': 'static_library',
73      'variables': {
74        'proto_in_dir': '.',
75        'proto_out_dir': 'include/update_engine',
76        'exported_deps': [
77          'protobuf-lite',
78        ],
79        'deps': ['<@(exported_deps)'],
80      },
81      'all_dependent_settings': {
82        'variables': {
83          'deps': [
84            '<@(exported_deps)',
85          ],
86        },
87      },
88      'sources': [
89        'update_metadata.proto'
90      ],
91      'includes': ['../../../platform2/common-mk/protoc.gypi'],
92    },
93    # Chrome D-Bus bindings.
94    {
95      'target_name': 'update_engine-dbus-adaptor',
96      'type': 'none',
97      'variables': {
98        'dbus_adaptors_out_dir': 'include/dbus_bindings',
99        'dbus_xml_extension': 'dbus-xml',
100      },
101      'sources': [
102        'dbus_bindings/org.chromium.UpdateEngineInterface.dbus-xml',
103      ],
104      'includes': ['../../../platform2/common-mk/generate-dbus-adaptors.gypi'],
105    },
106    {
107      'target_name': 'update_engine-other-dbus-proxies',
108      'type': 'none',
109      'actions': [
110        {
111          'action_name': 'update_engine-dbus-libcros-client',
112          'variables': {
113            'mock_output_file': 'include/libcros/dbus-proxy-mocks.h',
114            'proxy_output_file': 'include/libcros/dbus-proxies.h'
115          },
116          'sources': [
117            'dbus_bindings/org.chromium.LibCrosService.dbus-xml',
118          ],
119          'includes': ['../../../platform2/common-mk/generate-dbus-proxies.gypi'],
120        },
121      ],
122    },
123    # The payload application component and common dependencies.
124    {
125      'target_name': 'libpayload_consumer',
126      'type': 'static_library',
127      'dependencies': [
128        'update_metadata-protos',
129      ],
130      #TODO(deymo): Remove unused dependencies once we stop including files
131      # from the root directory.
132      'variables': {
133        'exported_deps': [
134          'libcrypto',
135          'libcurl',
136          'libssl',
137          'xz-embedded',
138        ],
139        'deps': ['<@(exported_deps)'],
140      },
141      'all_dependent_settings': {
142        'variables': {
143          'deps': [
144            '<@(exported_deps)',
145          ],
146        },
147      },
148      'link_settings': {
149        'variables': {
150          'deps': [
151            '<@(exported_deps)',
152          ],
153        },
154        'libraries': [
155          '-lbz2',
156          '-lrt',
157        ],
158      },
159      'sources': [
160        'common/action_processor.cc',
161        'common/boot_control_stub.cc',
162        'common/certificate_checker.cc',
163        'common/clock.cc',
164        'common/constants.cc',
165        'common/cpu_limiter.cc',
166        'common/error_code_utils.cc',
167        'common/hash_calculator.cc',
168        'common/http_common.cc',
169        'common/http_fetcher.cc',
170        'common/hwid_override.cc',
171        'common/libcurl_http_fetcher.cc',
172        'common/multi_range_http_fetcher.cc',
173        'common/platform_constants_chromeos.cc',
174        'common/prefs.cc',
175        'common/subprocess.cc',
176        'common/terminator.cc',
177        'common/utils.cc',
178        'payload_consumer/bzip_extent_writer.cc',
179        'payload_consumer/delta_performer.cc',
180        'payload_consumer/download_action.cc',
181        'payload_consumer/extent_writer.cc',
182        'payload_consumer/file_descriptor.cc',
183        'payload_consumer/file_writer.cc',
184        'payload_consumer/filesystem_verifier_action.cc',
185        'payload_consumer/install_plan.cc',
186        'payload_consumer/payload_constants.cc',
187        'payload_consumer/payload_verifier.cc',
188        'payload_consumer/postinstall_runner_action.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        'update_engine-other-dbus-proxies',
214      ],
215      'variables': {
216        'exported_deps': [
217          'dbus-1',
218          'libdebugd-client',
219          'libsession_manager-client',
220          'libmetrics-<(libbase_ver)',
221          'libpower_manager-client',
222          'libupdate_engine-client',
223          'libshill-client',
224          'expat',
225        ],
226        'deps': ['<@(exported_deps)'],
227      },
228      'all_dependent_settings': {
229        'variables': {
230          'deps': [
231            '<@(exported_deps)',
232          ],
233        },
234      },
235      'link_settings': {
236        'variables': {
237          'deps': [
238            '<@(exported_deps)',
239          ],
240        },
241        'libraries': [
242          '-lbz2',
243          '-lpolicy-<(libbase_ver)',
244          '-lrootdev',
245          '-lrt',
246          '-lvboot_host',
247        ],
248      },
249      'sources': [
250        'boot_control_chromeos.cc',
251        'common_service.cc',
252        'connection_manager.cc',
253        'daemon.cc',
254        'dbus_service.cc',
255        'hardware_chromeos.cc',
256        'image_properties_chromeos.cc',
257        'libcros_proxy.cc',
258        'metrics.cc',
259        'metrics_utils.cc',
260        'omaha_request_action.cc',
261        'omaha_request_params.cc',
262        'omaha_response_handler_action.cc',
263        'p2p_manager.cc',
264        'payload_state.cc',
265        'proxy_resolver.cc',
266        'real_system_state.cc',
267        'shill_proxy.cc',
268        'update_attempter.cc',
269        'update_manager/boxed_value.cc',
270        'update_manager/chromeos_policy.cc',
271        'update_manager/default_policy.cc',
272        'update_manager/evaluation_context.cc',
273        'update_manager/policy.cc',
274        'update_manager/real_config_provider.cc',
275        'update_manager/real_device_policy_provider.cc',
276        'update_manager/real_random_provider.cc',
277        'update_manager/real_shill_provider.cc',
278        'update_manager/real_system_provider.cc',
279        'update_manager/real_time_provider.cc',
280        'update_manager/real_updater_provider.cc',
281        'update_manager/state_factory.cc',
282        'update_manager/update_manager.cc',
283        'update_status_utils.cc',
284        'weave_service_factory.cc',
285      ],
286      'conditions': [
287        ['USE_buffet == 1', {
288          'sources': [
289            'weave_service.cc',
290          ],
291          'variables': {
292            'exported_deps': [
293              'libweave-<(libbase_ver)',
294            ],
295          },
296        }],
297        ['USE_libcros == 1', {
298          'dependencies': [
299            'update_engine-other-dbus-proxies',
300          ],
301          'sources': [
302            'chrome_browser_proxy_resolver.cc',
303          ],
304        }],
305      ],
306    },
307    # update_engine daemon.
308    {
309      'target_name': 'update_engine',
310      'type': 'executable',
311      'dependencies': [
312        'libupdate_engine',
313      ],
314      'sources': [
315        'main.cc',
316      ],
317    },
318    # update_engine client library.
319    {
320      'target_name': 'libupdate_engine_client',
321      'type': 'static_library',
322      'variables': {
323        'deps': [
324          'dbus-1',
325          'libupdate_engine-client',
326        ],
327      },
328      'sources': [
329        'client_library/client.cc',
330        'client_library/client_dbus.cc',
331        'update_status_utils.cc',
332      ],
333      'include_dirs': [
334        'client_library/include',
335      ],
336    },
337    # update_engine console client.
338    {
339      'target_name': 'update_engine_client',
340      'type': 'executable',
341      'dependencies': [
342        'libupdate_engine_client',
343      ],
344      'sources': [
345        'common/error_code_utils.cc',
346        'update_engine_client.cc',
347     ],
348    },
349    # server-side code. This is used for delta_generator and unittests but not
350    # for any client code.
351    {
352      'target_name': 'libpayload_generator',
353      'type': 'static_library',
354      'dependencies': [
355        'libpayload_consumer',
356        'update_metadata-protos',
357      ],
358      'variables': {
359        'exported_deps': [
360          'ext2fs',
361        ],
362        'deps': ['<@(exported_deps)'],
363      },
364      'all_dependent_settings': {
365        'variables': {
366          'deps': [
367            '<@(exported_deps)',
368          ],
369        },
370      },
371      'link_settings': {
372        'variables': {
373          'deps': [
374            '<@(exported_deps)',
375          ],
376        },
377      },
378      'sources': [
379        'payload_generator/ab_generator.cc',
380        'payload_generator/annotated_operation.cc',
381        'payload_generator/blob_file_writer.cc',
382        'payload_generator/block_mapping.cc',
383        'payload_generator/bzip.cc',
384        'payload_generator/cycle_breaker.cc',
385        'payload_generator/delta_diff_generator.cc',
386        'payload_generator/delta_diff_utils.cc',
387        'payload_generator/ext2_filesystem.cc',
388        'payload_generator/extent_ranges.cc',
389        'payload_generator/extent_utils.cc',
390        'payload_generator/full_update_generator.cc',
391        'payload_generator/graph_types.cc',
392        'payload_generator/graph_utils.cc',
393        'payload_generator/inplace_generator.cc',
394        'payload_generator/payload_file.cc',
395        'payload_generator/payload_generation_config.cc',
396        'payload_generator/payload_signer.cc',
397        'payload_generator/raw_filesystem.cc',
398        'payload_generator/tarjan.cc',
399        'payload_generator/topological_sort.cc',
400        'payload_generator/xz_chromeos.cc',
401      ],
402    },
403    # server-side delta generator.
404    {
405      'target_name': 'delta_generator',
406      'type': 'executable',
407      'dependencies': [
408        'libpayload_consumer',
409        'libpayload_generator',
410      ],
411      'link_settings': {
412        'ldflags!': [
413          '-pie',
414        ],
415      },
416      'sources': [
417        'payload_generator/generate_delta_main.cc',
418      ],
419    },
420  ],
421  'conditions': [
422    ['USE_test == 1', {
423      'targets': [
424        # Public keys used for unit testing.
425        {
426          'target_name': 'update_engine-testkeys',
427          'type': 'none',
428          'variables': {
429            'openssl_pem_in_dir': '.',
430            'openssl_pem_out_dir': 'include/update_engine',
431          },
432          'sources': [
433            'unittest_key.pem',
434            'unittest_key2.pem',
435          ],
436          'includes': ['../../../platform2/common-mk/openssl_pem.gypi'],
437        },
438        # Unpacks sample images used for testing.
439        {
440          'target_name': 'update_engine-test_images',
441          'type': 'none',
442          'variables': {
443            'image_out_dir': '.',
444          },
445          'sources': [
446            'sample_images/sample_images.tar.bz2',
447          ],
448          'includes': ['tar_bunzip2.gypi'],
449        },
450        # Test HTTP Server.
451        {
452          'target_name': 'test_http_server',
453          'type': 'executable',
454          'sources': [
455            'common/http_common.cc',
456            'test_http_server.cc',
457          ],
458        },
459        # Main unittest file.
460        {
461          'target_name': 'update_engine_unittests',
462          'type': 'executable',
463          'includes': ['../../../platform2/common-mk/common_test.gypi'],
464          'variables': {
465            'deps': [
466              'libbrillo-test-<(libbase_ver)',
467              'libchrome-test-<(libbase_ver)',
468              'libdebugd-client-test',
469              'libpower_manager-client-test',
470              'libsession_manager-client-test',
471              'libshill-client-test',
472            ],
473          },
474          'dependencies': [
475            'libupdate_engine',
476            'libpayload_generator',
477          ],
478          'includes': ['../../../platform2/common-mk/common_test.gypi'],
479          'sources': [
480            'boot_control_chromeos_unittest.cc',
481            'common/action_pipe_unittest.cc',
482            'common/action_processor_unittest.cc',
483            'common/action_unittest.cc',
484            'common/certificate_checker_unittest.cc',
485            'common/cpu_limiter_unittest.cc',
486            'common/fake_prefs.cc',
487            'common/hash_calculator_unittest.cc',
488            'common/http_fetcher_unittest.cc',
489            'common/hwid_override_unittest.cc',
490            'common/mock_http_fetcher.cc',
491            'common/prefs_unittest.cc',
492            'common/subprocess_unittest.cc',
493            'common/terminator_unittest.cc',
494            'common/test_utils.cc',
495            'common/utils_unittest.cc',
496            'common_service_unittest.cc',
497            'connection_manager_unittest.cc',
498            'fake_shill_proxy.cc',
499            'fake_system_state.cc',
500            'metrics_utils_unittest.cc',
501            'omaha_request_action_unittest.cc',
502            'omaha_request_params_unittest.cc',
503            'omaha_response_handler_action_unittest.cc',
504            'p2p_manager_unittest.cc',
505            'payload_consumer/bzip_extent_writer_unittest.cc',
506            'payload_consumer/delta_performer_integration_test.cc',
507            'payload_consumer/delta_performer_unittest.cc',
508            'payload_consumer/download_action_unittest.cc',
509            'payload_consumer/extent_writer_unittest.cc',
510            'payload_consumer/file_writer_unittest.cc',
511            'payload_consumer/filesystem_verifier_action_unittest.cc',
512            'payload_consumer/postinstall_runner_action_unittest.cc',
513            'payload_consumer/xz_extent_writer_unittest.cc',
514            'payload_generator/ab_generator_unittest.cc',
515            'payload_generator/blob_file_writer_unittest.cc',
516            'payload_generator/block_mapping_unittest.cc',
517            'payload_generator/cycle_breaker_unittest.cc',
518            'payload_generator/delta_diff_utils_unittest.cc',
519            'payload_generator/ext2_filesystem_unittest.cc',
520            'payload_generator/extent_ranges_unittest.cc',
521            'payload_generator/extent_utils_unittest.cc',
522            'payload_generator/fake_filesystem.cc',
523            'payload_generator/full_update_generator_unittest.cc',
524            'payload_generator/graph_utils_unittest.cc',
525            'payload_generator/inplace_generator_unittest.cc',
526            'payload_generator/payload_file_unittest.cc',
527            'payload_generator/payload_generation_config_unittest.cc',
528            'payload_generator/payload_signer_unittest.cc',
529            'payload_generator/tarjan_unittest.cc',
530            'payload_generator/topological_sort_unittest.cc',
531            'payload_generator/zip_unittest.cc',
532            'payload_state_unittest.cc',
533            'update_attempter_unittest.cc',
534            'update_manager/boxed_value_unittest.cc',
535            'update_manager/chromeos_policy_unittest.cc',
536            'update_manager/evaluation_context_unittest.cc',
537            'update_manager/generic_variables_unittest.cc',
538            'update_manager/prng_unittest.cc',
539            'update_manager/real_config_provider_unittest.cc',
540            'update_manager/real_device_policy_provider_unittest.cc',
541            'update_manager/real_random_provider_unittest.cc',
542            'update_manager/real_shill_provider_unittest.cc',
543            'update_manager/real_system_provider_unittest.cc',
544            'update_manager/real_time_provider_unittest.cc',
545            'update_manager/real_updater_provider_unittest.cc',
546            'update_manager/umtest_utils.cc',
547            'update_manager/update_manager_unittest.cc',
548            'update_manager/variable_unittest.cc',
549            # Main entry point for runnning tests.
550            'testrunner.cc',
551          ],
552          'conditions': [
553            ['USE_libcros == 1', {
554              'sources': [
555                'chrome_browser_proxy_resolver_unittest.cc',
556              ],
557            }],
558          ],
559        },
560      ],
561    }],
562  ],
563}
564