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