Rename GetIconID to GetIconId
[chromium-blink-merge.git] / components / policy.gypi
blobd032ace8f37f5c555af4fb2b0762410c3fa38fa7
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           'conditions': [
66             ['OS=="android"', {
67               'dependencies': ['policy_jni_headers']},
68             ],
69           ],
70         },
71       ],
72     }, {  # component=="shared_library"
73       'targets': [
74         {
75           # GN version: //components/policy:policy_component
76           'target_name': 'policy_component',
77           'type': 'shared_library',
78           'includes': [
79             'policy/policy_common.gypi',
80             'policy/policy_browser.gypi',
81           ],
82         },
83         {
84           # GN version: //components/policy:policy_component_common
85           'target_name': 'policy_component_common',
86           'type': 'none',
87           'dependencies': [
88             'policy_component',
89           ],
90           'conditions': [
91             ['OS=="android"', {
92               'dependencies': ['policy_jni_headers']},
93             ],
94           ],
95         },
96         {
97           # GN version: //components/policy:policy_component_browser
98           'target_name': 'policy_component_browser',
99           'type': 'none',
100           'dependencies': [
101             'policy_component',
102           ],
103         },
104       ],
105     }],
106     ['configuration_policy==1', {
107       'targets': [
108         {
109           # GN version: //components/policy:cloud_policy_code_generate
110           'target_name': 'cloud_policy_code_generate',
111           'type': 'none',
112           'actions': [
113             {
114               'inputs': [
115                 'policy/resources/policy_templates.json',
116                 '<(DEPTH)/chrome/VERSION',
117                 '<(generate_policy_source_script_path)',
118               ],
119               'outputs': [
120                 '<(policy_constant_header_path)',
121                 '<(policy_constant_source_path)',
122                 '<(protobuf_decoder_path)',
123                 '<(chrome_settings_proto_path)',
124                 '<(cloud_policy_proto_path)',
125                 '<(app_restrictions_path)',
126               ],
127               'action_name': 'generate_policy_source',
128               'action': [
129                 'python',
130                 '<@(generate_policy_source_script_path)',
131                 '--policy-constants-header=<(policy_constant_header_path)',
132                 '--policy-constants-source=<(policy_constant_source_path)',
133                 '--chrome-settings-protobuf=<(chrome_settings_proto_path)',
134                 '--cloud-policy-protobuf=<(cloud_policy_proto_path)',
135                 '--cloud-policy-decoder=<(protobuf_decoder_path)',
136                 '--app-restrictions-definition=<(app_restrictions_path)',
137                 '<(DEPTH)/chrome/VERSION',
138                 '<(OS)',
139                 '<(chromeos)',
140                 'policy/resources/policy_templates.json',
141               ],
142               'message': 'Generating policy source',
143               'conditions': [
144                 ['OS!="android"', {
145                   'outputs!': [
146                     '<(app_restrictions_path)',
147                   ],
148                 }],
149               ],
150             },
151           ],
152           'direct_dependent_settings': {
153             'include_dirs': [
154               '<(policy_out_dir)',
155               '<(protoc_out_dir)',
156             ],
157           },
158         },
159         {
160           # GN version: //components/policy:cloud_policy_proto_generated_compile
161           'target_name': 'cloud_policy_proto_generated_compile',
162           'type': '<(component)',
163           'sources': [
164             '<(cloud_policy_proto_path)',
165           ],
166           'variables': {
167             'proto_in_dir': '<(policy_out_dir)/policy',
168             'proto_out_dir': 'policy/proto',
169             'cc_generator_options': 'dllexport_decl=POLICY_PROTO_EXPORT:',
170             'cc_include': 'components/policy/policy_proto_export.h',
171           },
172           'dependencies': [
173             'cloud_policy_code_generate',
174           ],
175           'includes': [
176             '../build/protoc.gypi',
177           ],
178           'defines': [
179             'POLICY_PROTO_COMPILATION',
180           ],
181           # TODO(jschuh): crbug.com/167187 fix size_t to int truncations.
182           'msvs_disabled_warnings': [4267, ],
183         },
184         {
185           # This target builds the "full" protobuf, used for tests only.
186           # GN version: //components/policy:chrome_settings_proto_generated_compile
187           'target_name': 'chrome_settings_proto_generated_compile',
188           'type': 'static_library',
189           'sources': [
190             '<(chrome_settings_proto_path)',
191           ],
192           'variables': {
193             'proto_in_dir': '<(policy_out_dir)/policy',
194             'proto_out_dir': 'policy/proto',
195           },
196           'dependencies': [
197             'cloud_policy_code_generate',
198             'cloud_policy_proto_generated_compile',
199           ],
200           'includes': [
201             '../build/protoc.gypi',
202           ],
203         },
204         {
205           # GN version: //components/policy
206           'target_name': 'policy',
207           'type': 'static_library',
208           'hard_dependency': 1,
209           'direct_dependent_settings': {
210             'include_dirs': [
211               '<(policy_out_dir)',
212               '<(protoc_out_dir)',
213             ],
214           },
215           'sources': [
216             '<(policy_constant_header_path)',
217             '<(policy_constant_source_path)',
218             '<(protobuf_decoder_path)',
219           ],
220           'include_dirs': [
221             '<(DEPTH)',
222           ],
223           'dependencies': [
224             'cloud_policy_code_generate',
225             'cloud_policy_proto_generated_compile',
226             '<(DEPTH)/base/base.gyp:base',
227             '<(DEPTH)/third_party/protobuf/protobuf.gyp:protobuf_lite',
228           ],
229           'defines': [
230             'POLICY_COMPONENT_IMPLEMENTATION',
231           ],
232         },
233         {
234           # GN version: //components/policy/proto
235           'target_name': 'cloud_policy_proto',
236           'type': '<(component)',
237           'sources': [
238             'policy/proto/chrome_extension_policy.proto',
239             'policy/proto/device_management_backend.proto',
240             'policy/proto/device_management_local.proto',
241             'policy/proto/policy_signing_key.proto',
242           ],
243           'variables': {
244             'proto_in_dir': 'policy/proto',
245             'proto_out_dir': 'policy/proto',
246             'cc_generator_options': 'dllexport_decl=POLICY_PROTO_EXPORT:',
247             'cc_include': 'components/policy/policy_proto_export.h',
248           },
249           'includes': [
250             '../build/protoc.gypi',
251           ],
252           'conditions': [
253             ['OS=="android" or OS=="ios"', {
254               'sources!': [
255                 'policy/proto/chrome_extension_policy.proto',
256               ],
257             }],
258             ['chromeos==0', {
259               'sources!': [
260                 'policy/proto/device_management_local.proto',
261               ],
262             }],
263           ],
264           'defines': [
265             'POLICY_PROTO_COMPILATION',
266           ],
267         },
268         {
269           # GN version: //components/policy:test_support
270           'target_name': 'policy_test_support',
271           'type': 'none',
272           'hard_dependency': 1,
273           'direct_dependent_settings': {
274             'include_dirs': [
275               '<(policy_out_dir)',
276               '<(protoc_out_dir)',
277             ],
278           },
279           'dependencies': [
280             'chrome_settings_proto_generated_compile',
281             'policy',
282           ],
283         },
284         {
285           # GN version: //components/policy:policy_component_test_support
286           'target_name': 'policy_component_test_support',
287           'type': 'static_library',
288           # This must be undefined so that POLICY_EXPORT works correctly in
289           # the static_library build.
290           'defines!': [
291             'POLICY_COMPONENT_IMPLEMENTATION',
292           ],
293           'dependencies': [
294             'cloud_policy_proto',
295             'policy_component',
296             'policy_test_support',
297             '../testing/gmock.gyp:gmock',
298             '../testing/gtest.gyp:gtest',
299           ],
300           'include_dirs': [
301             '..',
302           ],
303           'sources': [
304             'policy/core/browser/configuration_policy_pref_store_test.cc',
305             'policy/core/browser/configuration_policy_pref_store_test.h',
306             'policy/core/common/cloud/mock_cloud_external_data_manager.cc',
307             'policy/core/common/cloud/mock_cloud_external_data_manager.h',
308             'policy/core/common/cloud/mock_cloud_policy_client.cc',
309             'policy/core/common/cloud/mock_cloud_policy_client.h',
310             'policy/core/common/cloud/mock_cloud_policy_store.cc',
311             'policy/core/common/cloud/mock_cloud_policy_store.h',
312             'policy/core/common/cloud/mock_device_management_service.cc',
313             'policy/core/common/cloud/mock_device_management_service.h',
314             'policy/core/common/cloud/mock_user_cloud_policy_store.cc',
315             'policy/core/common/cloud/mock_user_cloud_policy_store.h',
316             'policy/core/common/cloud/policy_builder.cc',
317             'policy/core/common/cloud/policy_builder.h',
318             'policy/core/common/configuration_policy_provider_test.cc',
319             'policy/core/common/configuration_policy_provider_test.h',
320             'policy/core/common/fake_async_policy_loader.cc',
321             'policy/core/common/fake_async_policy_loader.h',
322             'policy/core/common/mock_configuration_policy_provider.cc',
323             'policy/core/common/mock_configuration_policy_provider.h',
324             'policy/core/common/mock_policy_service.cc',
325             'policy/core/common/mock_policy_service.h',
326             'policy/core/common/policy_test_utils.cc',
327             'policy/core/common/policy_test_utils.h',
328             'policy/core/common/preferences_mock_mac.cc',
329             'policy/core/common/preferences_mock_mac.h',
330             'policy/core/common/remote_commands/test_remote_command_job.cc',
331             'policy/core/common/remote_commands/test_remote_command_job.h',
332             'policy/core/common/remote_commands/testing_remote_commands_server.cc',
333             'policy/core/common/remote_commands/testing_remote_commands_server.h',
334           ],
335           'conditions': [
336             ['OS=="android"', {
337               'sources!': [
338                 'policy/core/common/fake_async_policy_loader.cc',
339                 'policy/core/common/fake_async_policy_loader.h',
340               ],
341             }],
342             ['chromeos==1', {
343               'sources!': [
344                 'policy/core/common/cloud/mock_user_cloud_policy_store.cc',
345                 'policy/core/common/cloud/mock_user_cloud_policy_store.h',
346               ],
347             }],
348           ],
349         },
350       ],
351     }],
352     ['OS=="android"',
353      {
354       'targets' : [
355         {
356           'target_name' : 'policy_jni_headers',
357           'type': 'none',
358           'sources': [ 
359             'policy/android/java/src/org/chromium/policy/CombinedPolicyProvider.java',
360             'policy/android/java/src/org/chromium/policy/PolicyConverter.java',
361            ],
362           'variables': {
363             'jni_gen_package': 'policy',
364            },
365           'includes': [ '../build/jni_generator.gypi' ],
366          },
367        ],
368     }],
369     ['OS=="android" and configuration_policy==1', {
370       'targets': [
371         {
372           'target_name': 'app_restrictions_resources',
373           'type': 'none',
374           'variables': {
375             'resources_zip': '<(PRODUCT_DIR)/res.java/<(_target_name).zip',
376             'input_resources_dir':
377             '<(SHARED_INTERMEDIATE_DIR)/chrome/app/policy/android',
378             'create_zip_script': '../build/android/gyp/zip.py',
379           },
380           'copies': [
381             {
382               'destination': '<(input_resources_dir)/xml-v21/',
383               'files': [
384                 '<(SHARED_INTERMEDIATE_DIR)/policy/app_restrictions.xml'
385               ],
386             },
387           ],
388           'actions': [
389             {
390               'action_name': 'create_resources_zip',
391               'inputs': [
392                 '<(create_zip_script)',
393                 '<(input_resources_dir)/xml-v21/app_restrictions.xml',
394                 '<(input_resources_dir)/values-v21/restriction_values.xml',
395               ],
396               'outputs': [
397                 '<(resources_zip)'
398               ],
399               'action': [
400                 'python', '<(create_zip_script)',
401                 '--input-dir', '<(input_resources_dir)',
402                 '--output', '<(resources_zip)',
403               ],
404             }
405           ],
406           'all_dependent_settings': {
407             'variables': {
408               'additional_input_paths': ['<(resources_zip)'],
409               'dependencies_res_zip_paths': ['<(resources_zip)'],
410             },
411           },
412         },
413         {
414           # GN: //components/policy/android:policy_java
415           'target_name': 'policy_java',
416           'type': 'none',
417           'dependencies': [
418             '../base/base.gyp:base_java',
419           ],
420           'variables': {
421             'java_in_dir': 'policy/android/java',
422           },
423           'includes': [ '../build/java.gypi' ],
424         },
425       ],
426     }],
427     ['OS=="win" and target_arch=="ia32" and configuration_policy==1', {
428       'targets': [
429         {
430           'target_name': 'policy_win64',
431           'type': 'static_library',
432           'hard_dependency': 1,
433           'sources': [
434             '<(policy_constant_header_path)',
435             '<(policy_constant_source_path)',
436           ],
437           'include_dirs': [
438             '<(DEPTH)',
439           ],
440           'direct_dependent_settings':  {
441             'include_dirs': [
442               '<(policy_out_dir)'
443             ],
444           },
445           'dependencies': [
446             'cloud_policy_code_generate',
447           ],
448           'configurations': {
449             'Common_Base': {
450               'msvs_target_platform': 'x64',
451             },
452           },
453         },
454       ],
455     }],
456     ['OS!="ios"', {
457       'targets': [
458         {
459           # policy_templates has different inputs and outputs, so it can't use
460           # the rules of chrome_strings
461           'target_name': 'policy_templates',
462           'type': 'none',
463           'variables': {
464             'grit_grd_file': 'policy/resources/policy_templates.grd',
465             'grit_info_cmd': [
466               'python',
467               '<(DEPTH)/tools/grit/grit_info.py',
468               '<@(grit_defines)',
469             ],
470           },
471           'includes': [
472             '../build/grit_target.gypi',
473           ],
474           'actions': [
475             {
476               'action_name': 'policy_templates',
477               'includes': [
478                 '../build/grit_action.gypi',
479               ],
480             },
481           ],
482         },
483       ],
484     }],
485     ['OS=="mac"', {
486       'targets': [
487         {
488           # This is the bundle of the manifest file of Chrome.
489           # It contains the manifest file and its string tables.
490           'target_name': 'chrome_manifest_bundle',
491           'type': 'loadable_module',
492           'mac_bundle': 1,
493           'product_extension': 'manifest',
494           'product_name': '<(mac_bundle_id)',
495           'variables': {
496             # This avoids stripping debugging symbols from the target, which
497             # would fail because there is no binary code here.
498             'mac_strip': 0,
499           },
500           'dependencies': [
501              # Provides app-Manifest.plist and its string tables:
502             'policy_templates',
503           ],
504           'actions': [
505             {
506               'action_name': 'Copy MCX manifest file to manifest bundle',
507               'inputs': [
508                 '<(grit_out_dir)/app/policy/mac/app-Manifest.plist',
509               ],
510               'outputs': [
511                 '<(INTERMEDIATE_DIR)/app_manifest/<(mac_bundle_id).manifest',
512               ],
513               'action': [
514                 # Use plutil -convert xml1 to put the plist into Apple's
515                 # canonical format. As a side effect, this ensures that the
516                 # plist is well-formed.
517                 'plutil',
518                 '-convert',
519                 'xml1',
520                 '<@(_inputs)',
521                 '-o',
522                 '<@(_outputs)',
523               ],
524               'message':
525                   'Copying the MCX policy manifest file to the manifest bundle',
526               'process_outputs_as_mac_bundle_resources': 1,
527             },
528             {
529               'action_name':
530                   'Copy Localizable.strings files to manifest bundle',
531               'variables': {
532                 'input_path': '<(grit_out_dir)/app/policy/mac/strings',
533                 # Directory to collect the Localizable.strings files before
534                 # they are copied to the bundle.
535                 'output_path': '<(INTERMEDIATE_DIR)/app_manifest',
536                 # The reason we are not enumerating all the locales is that
537                 # the translations would eat up 3.5MB disk space in the
538                 # application bundle:
539                 'available_locales': 'en',
540               },
541               'inputs': [
542                 # TODO: remove this helper when we have loops in GYP
543                 '>!@(<(apply_locales_cmd) -d \'<(input_path)/ZZLOCALE.lproj/Localizable.strings\' <(available_locales))',
544               ],
545               'outputs': [
546                 # TODO: remove this helper when we have loops in GYP
547                 '>!@(<(apply_locales_cmd) -d \'<(output_path)/ZZLOCALE.lproj/Localizable.strings\' <(available_locales))',
548               ],
549               'action': [
550                 'cp', '-R',
551                 '<(input_path)/',
552                 '<(output_path)',
553               ],
554               'message':
555                   'Copy the Localizable.strings files to the manifest bundle',
556               'process_outputs_as_mac_bundle_resources': 1,
557             },
558           ],
559         },
560       ],
561     }],
562   ],