Initial RemoteCommandService
[chromium-blink-merge.git] / components / policy.gypi
blobd6ae095078a9d79b8d82902f93f65525ef7b71f8
1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
6   'includes': [
7     # Included to get 'mac_bundle_id' and other variables.
8     '../build/chrome_settings.gypi',
9   ],
10   'variables': {
11     'chromium_code': 1,
12     'grit_out_dir': '<(SHARED_INTERMEDIATE_DIR)/chrome',
13     'policy_out_dir': '<(SHARED_INTERMEDIATE_DIR)/policy',
14     'protoc_out_dir': '<(SHARED_INTERMEDIATE_DIR)/protoc_out',
15     'android_resources_out_dir': '<(policy_out_dir)/android_resources',
16     'generate_policy_source_script_path':
17         'policy/tools/generate_policy_source.py',
18     'policy_constant_header_path':
19         '<(policy_out_dir)/policy/policy_constants.h',
20     'policy_constant_source_path':
21         '<(policy_out_dir)/policy/policy_constants.cc',
22     'protobuf_decoder_path':
23         '<(policy_out_dir)/policy/cloud_policy_generated.cc',
24     'app_restrictions_path':
25         '<(android_resources_out_dir)/xml-v21/app_restrictions.xml',
26     'app_resources_path':
27         '<(android_resources_out_dir)/values-v21/restriction_values.xml',
28     # This is the "full" protobuf, which defines one protobuf message per
29     # policy. It is also the format currently used by the server.
30     'chrome_settings_proto_path':
31         '<(policy_out_dir)/policy/chrome_settings.proto',
32     # This protobuf is equivalent to chrome_settings.proto but shares messages
33     # for policies of the same type, so that less classes have to be generated
34     # and compiled.
35     'cloud_policy_proto_path':
36         '<(policy_out_dir)/policy/cloud_policy.proto',
37   },
38   'conditions': [
39     ['component=="static_library"', {
40       'targets': [
41         {
42           # GN version: //components/policy:policy_component
43           'target_name': 'policy_component',
44           'type': 'none',
45           'dependencies': [
46             'policy_component_common',
47             'policy_component_browser',
48           ],
49         },
50         {
51           # GN version: //components/policy:policy_component_common
52           'target_name': 'policy_component_common',
53           'type': 'static_library',
54           'includes': [
55             'policy/policy_common.gypi',
56           ],
57         },
58         {
59           # GN version: //components/policy:policy_component_browser
60           'target_name': 'policy_component_browser',
61           'type': 'static_library',
62           'dependencies': [
63             'policy_component_common',
64           ],
65           'includes': [
66             'policy/policy_browser.gypi',
67           ],
68         },
69       ],
70     }, {  # component=="shared_library"
71       'targets': [
72         {
73           # GN version: //components/policy:policy_component
74           'target_name': 'policy_component',
75           'type': 'shared_library',
76           'includes': [
77             'policy/policy_common.gypi',
78             'policy/policy_browser.gypi',
79           ],
80         },
81         {
82           # GN version: //components/policy:policy_component_common
83           'target_name': 'policy_component_common',
84           'type': 'none',
85           'dependencies': [
86             'policy_component',
87           ],
88         },
89         {
90           # GN version: //components/policy:policy_component_browser
91           'target_name': 'policy_component_browser',
92           'type': 'none',
93           'dependencies': [
94             'policy_component',
95           ],
96         },
97       ],
98     }],
99     ['configuration_policy==1', {
100       'targets': [
101         {
102           # GN version: //components/policy:cloud_policy_code_generate
103           'target_name': 'cloud_policy_code_generate',
104           'type': 'none',
105           'actions': [
106             {
107               'inputs': [
108                 'policy/resources/policy_templates.json',
109                 '<(generate_policy_source_script_path)',
110               ],
111               'outputs': [
112                 '<(policy_constant_header_path)',
113                 '<(policy_constant_source_path)',
114                 '<(protobuf_decoder_path)',
115                 '<(chrome_settings_proto_path)',
116                 '<(cloud_policy_proto_path)',
117                 '<(app_restrictions_path)',
118                 '<(app_resources_path)',
119               ],
120               'action_name': 'generate_policy_source',
121               'action': [
122                 'python',
123                 '<@(generate_policy_source_script_path)',
124                 '--policy-constants-header=<(policy_constant_header_path)',
125                 '--policy-constants-source=<(policy_constant_source_path)',
126                 '--chrome-settings-protobuf=<(chrome_settings_proto_path)',
127                 '--cloud-policy-protobuf=<(cloud_policy_proto_path)',
128                 '--cloud-policy-decoder=<(protobuf_decoder_path)',
129                 '--app-restrictions-definition=<(app_restrictions_path)',
130                 '--app-restrictions-resources=<(app_resources_path)',
131                 '<(OS)',
132                 '<(chromeos)',
133                 'policy/resources/policy_templates.json',
134               ],
135               'message': 'Generating policy source',
136               'conditions': [
137                 ['OS!="android"', {
138                   'outputs!': [
139                     '<(app_restrictions_path)',
140                     '<(app_resources_path)',
141                   ],
142                 }],
143               ],
144             },
145           ],
146           'direct_dependent_settings': {
147             'include_dirs': [
148               '<(policy_out_dir)',
149               '<(protoc_out_dir)',
150             ],
151           },
152         },
153         {
154           # GN version: //components/policy:cloud_policy_proto_generated_compile
155           'target_name': 'cloud_policy_proto_generated_compile',
156           'type': '<(component)',
157           'sources': [
158             '<(cloud_policy_proto_path)',
159           ],
160           'variables': {
161             'proto_in_dir': '<(policy_out_dir)/policy',
162             'proto_out_dir': 'policy/proto',
163             'cc_generator_options': 'dllexport_decl=POLICY_PROTO_EXPORT:',
164             'cc_include': 'components/policy/policy_proto_export.h',
165           },
166           'dependencies': [
167             'cloud_policy_code_generate',
168           ],
169           'includes': [
170             '../build/protoc.gypi',
171           ],
172           'defines': [
173             'POLICY_PROTO_COMPILATION',
174           ],
175           # TODO(jschuh): crbug.com/167187 fix size_t to int truncations.
176           'msvs_disabled_warnings': [4267, ],
177         },
178         {
179           # This target builds the "full" protobuf, used for tests only.
180           # GN version: //components/policy:chrome_settings_proto_generated_compile
181           'target_name': 'chrome_settings_proto_generated_compile',
182           'type': 'static_library',
183           'sources': [
184             '<(chrome_settings_proto_path)',
185           ],
186           'variables': {
187             'proto_in_dir': '<(policy_out_dir)/policy',
188             'proto_out_dir': 'policy/proto',
189           },
190           'dependencies': [
191             'cloud_policy_code_generate',
192             'cloud_policy_proto_generated_compile',
193           ],
194           'includes': [
195             '../build/protoc.gypi',
196           ],
197         },
198         {
199           # GN version: //components/policy
200           'target_name': 'policy',
201           'type': 'static_library',
202           'hard_dependency': 1,
203           'direct_dependent_settings': {
204             'include_dirs': [
205               '<(policy_out_dir)',
206               '<(protoc_out_dir)',
207             ],
208           },
209           'sources': [
210             '<(policy_constant_header_path)',
211             '<(policy_constant_source_path)',
212             '<(protobuf_decoder_path)',
213           ],
214           'include_dirs': [
215             '<(DEPTH)',
216           ],
217           'dependencies': [
218             'cloud_policy_code_generate',
219             'cloud_policy_proto_generated_compile',
220             '<(DEPTH)/base/base.gyp:base',
221             '<(DEPTH)/third_party/protobuf/protobuf.gyp:protobuf_lite',
222           ],
223           'defines': [
224             'POLICY_COMPONENT_IMPLEMENTATION',
225           ],
226         },
227         {
228           # GN version: //components/policy/proto
229           'target_name': 'cloud_policy_proto',
230           'type': '<(component)',
231           'sources': [
232             'policy/proto/chrome_extension_policy.proto',
233             'policy/proto/device_management_backend.proto',
234             'policy/proto/device_management_local.proto',
235             'policy/proto/policy_signing_key.proto',
236           ],
237           'variables': {
238             'proto_in_dir': 'policy/proto',
239             'proto_out_dir': 'policy/proto',
240             'cc_generator_options': 'dllexport_decl=POLICY_PROTO_EXPORT:',
241             'cc_include': 'components/policy/policy_proto_export.h',
242           },
243           'includes': [
244             '../build/protoc.gypi',
245           ],
246           'conditions': [
247             ['OS=="android" or OS=="ios"', {
248               'sources!': [
249                 'policy/proto/chrome_extension_policy.proto',
250               ],
251             }],
252             ['chromeos==0', {
253               'sources!': [
254                 'policy/proto/device_management_local.proto',
255               ],
256             }],
257           ],
258           'defines': [
259             'POLICY_PROTO_COMPILATION',
260           ],
261         },
262         {
263           # GN version: //components/policy:test_support
264           'target_name': 'policy_test_support',
265           'type': 'none',
266           'hard_dependency': 1,
267           'direct_dependent_settings': {
268             'include_dirs': [
269               '<(policy_out_dir)',
270               '<(protoc_out_dir)',
271             ],
272           },
273           'dependencies': [
274             'chrome_settings_proto_generated_compile',
275             'policy',
276           ],
277         },
278         {
279           # GN version: //components/policy:policy_component_test_support
280           'target_name': 'policy_component_test_support',
281           'type': 'static_library',
282           # This must be undefined so that POLICY_EXPORT works correctly in
283           # the static_library build.
284           'defines!': [
285             'POLICY_COMPONENT_IMPLEMENTATION',
286           ],
287           'dependencies': [
288             'cloud_policy_proto',
289             'policy_component',
290             'policy_test_support',
291             '../testing/gmock.gyp:gmock',
292             '../testing/gtest.gyp:gtest',
293           ],
294           'include_dirs': [
295             '..',
296           ],
297           'sources': [
298             'policy/core/browser/configuration_policy_pref_store_test.cc',
299             'policy/core/browser/configuration_policy_pref_store_test.h',
300             'policy/core/common/cloud/mock_cloud_external_data_manager.cc',
301             'policy/core/common/cloud/mock_cloud_external_data_manager.h',
302             'policy/core/common/cloud/mock_cloud_policy_client.cc',
303             'policy/core/common/cloud/mock_cloud_policy_client.h',
304             'policy/core/common/cloud/mock_cloud_policy_store.cc',
305             'policy/core/common/cloud/mock_cloud_policy_store.h',
306             'policy/core/common/cloud/mock_device_management_service.cc',
307             'policy/core/common/cloud/mock_device_management_service.h',
308             'policy/core/common/cloud/mock_user_cloud_policy_store.cc',
309             'policy/core/common/cloud/mock_user_cloud_policy_store.h',
310             'policy/core/common/cloud/policy_builder.cc',
311             'policy/core/common/cloud/policy_builder.h',
312             'policy/core/common/configuration_policy_provider_test.cc',
313             'policy/core/common/configuration_policy_provider_test.h',
314             'policy/core/common/fake_async_policy_loader.cc',
315             'policy/core/common/fake_async_policy_loader.h',
316             'policy/core/common/mock_configuration_policy_provider.cc',
317             'policy/core/common/mock_configuration_policy_provider.h',
318             'policy/core/common/mock_policy_service.cc',
319             'policy/core/common/mock_policy_service.h',
320             'policy/core/common/policy_test_utils.cc',
321             'policy/core/common/policy_test_utils.h',
322             'policy/core/common/preferences_mock_mac.cc',
323             'policy/core/common/preferences_mock_mac.h',
324             'policy/core/common/remote_commands/test_remote_command_job.cc',
325             'policy/core/common/remote_commands/test_remote_command_job.h',
326             'policy/core/common/remote_commands/testing_remote_commands_server.cc',
327             'policy/core/common/remote_commands/testing_remote_commands_server.h',
328           ],
329           'conditions': [
330             ['OS=="android"', {
331               'sources!': [
332                 'policy/core/common/fake_async_policy_loader.cc',
333                 'policy/core/common/fake_async_policy_loader.h',
334               ],
335             }],
336             ['chromeos==1', {
337               'sources!': [
338                 'policy/core/common/cloud/mock_user_cloud_policy_store.cc',
339                 'policy/core/common/cloud/mock_user_cloud_policy_store.h',
340               ],
341             }],
342           ],
343         },
344       ],
345     }],
346     ['OS=="win" and target_arch=="ia32" and configuration_policy==1', {
347       'targets': [
348         {
349           'target_name': 'policy_win64',
350           'type': 'static_library',
351           'hard_dependency': 1,
352           'sources': [
353             '<(policy_constant_header_path)',
354             '<(policy_constant_source_path)',
355           ],
356           'include_dirs': [
357             '<(DEPTH)',
358           ],
359           'direct_dependent_settings':  {
360             'include_dirs': [
361               '<(policy_out_dir)'
362             ],
363           },
364           'dependencies': [
365             'cloud_policy_code_generate',
366           ],
367           'configurations': {
368             'Common_Base': {
369               'msvs_target_platform': 'x64',
370             },
371           },
372         },
373       ],
374     }],
375     ['OS=="win" or OS=="mac" or OS=="linux"', {
376       'targets': [
377         {
378           # policy_templates has different inputs and outputs, so it can't use
379           # the rules of chrome_strings
380           'target_name': 'policy_templates',
381           'type': 'none',
382           'variables': {
383             'grit_grd_file': 'policy/resources/policy_templates.grd',
384             'grit_info_cmd': [
385               'python',
386               '<(DEPTH)/tools/grit/grit_info.py',
387               '<@(grit_defines)',
388             ],
389           },
390           'includes': [
391             '../build/grit_target.gypi',
392           ],
393           'actions': [
394             {
395               'action_name': 'policy_templates',
396               'includes': [
397                 '../build/grit_action.gypi',
398               ],
399             },
400           ],
401         },
402       ],
403     }],
404     ['OS=="mac"', {
405       'targets': [
406         {
407           # This is the bundle of the manifest file of Chrome.
408           # It contains the manifest file and its string tables.
409           'target_name': 'chrome_manifest_bundle',
410           'type': 'loadable_module',
411           'mac_bundle': 1,
412           'product_extension': 'manifest',
413           'product_name': '<(mac_bundle_id)',
414           'variables': {
415             # This avoids stripping debugging symbols from the target, which
416             # would fail because there is no binary code here.
417             'mac_strip': 0,
418           },
419           'dependencies': [
420              # Provides app-Manifest.plist and its string tables:
421             'policy_templates',
422           ],
423           'actions': [
424             {
425               'action_name': 'Copy MCX manifest file to manifest bundle',
426               'inputs': [
427                 '<(grit_out_dir)/app/policy/mac/app-Manifest.plist',
428               ],
429               'outputs': [
430                 '<(INTERMEDIATE_DIR)/app_manifest/<(mac_bundle_id).manifest',
431               ],
432               'action': [
433                 # Use plutil -convert xml1 to put the plist into Apple's
434                 # canonical format. As a side effect, this ensures that the
435                 # plist is well-formed.
436                 'plutil',
437                 '-convert',
438                 'xml1',
439                 '<@(_inputs)',
440                 '-o',
441                 '<@(_outputs)',
442               ],
443               'message':
444                   'Copying the MCX policy manifest file to the manifest bundle',
445               'process_outputs_as_mac_bundle_resources': 1,
446             },
447             {
448               'action_name':
449                   'Copy Localizable.strings files to manifest bundle',
450               'variables': {
451                 'input_path': '<(grit_out_dir)/app/policy/mac/strings',
452                 # Directory to collect the Localizable.strings files before
453                 # they are copied to the bundle.
454                 'output_path': '<(INTERMEDIATE_DIR)/app_manifest',
455                 # The reason we are not enumerating all the locales is that
456                 # the translations would eat up 3.5MB disk space in the
457                 # application bundle:
458                 'available_locales': 'en',
459               },
460               'inputs': [
461                 # TODO: remove this helper when we have loops in GYP
462                 '>!@(<(apply_locales_cmd) -d \'<(input_path)/ZZLOCALE.lproj/Localizable.strings\' <(available_locales))',
463               ],
464               'outputs': [
465                 # TODO: remove this helper when we have loops in GYP
466                 '>!@(<(apply_locales_cmd) -d \'<(output_path)/ZZLOCALE.lproj/Localizable.strings\' <(available_locales))',
467               ],
468               'action': [
469                 'cp', '-R',
470                 '<(input_path)/',
471                 '<(output_path)',
472               ],
473               'message':
474                   'Copy the Localizable.strings files to the manifest bundle',
475               'process_outputs_as_mac_bundle_resources': 1,
476             },
477           ],
478         },
479       ],
480     }],
481   ],