ServiceWorker: Consolidate version manipulation functions in SWProviderContext
[chromium-blink-merge.git] / components / policy.gypi
blob7e0533a4e795378636eb32fa46649c3ae5d8809c
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/mock_configuration_policy_provider.cc',
315             'policy/core/common/mock_configuration_policy_provider.h',
316             'policy/core/common/mock_policy_service.cc',
317             'policy/core/common/mock_policy_service.h',
318             'policy/core/common/policy_test_utils.cc',
319             'policy/core/common/policy_test_utils.h',
320             'policy/core/common/preferences_mock_mac.cc',
321             'policy/core/common/preferences_mock_mac.h',
322           ],
323           'conditions': [
324             ['chromeos==1', {
325               'sources!': [
326                 'policy/core/common/cloud/mock_user_cloud_policy_store.cc',
327                 'policy/core/common/cloud/mock_user_cloud_policy_store.h',
328               ],
329             }],
330           ],
331         },
332       ],
333     }],
334     ['OS=="win" and target_arch=="ia32" and configuration_policy==1', {
335       'targets': [
336         {
337           'target_name': 'policy_win64',
338           'type': 'static_library',
339           'hard_dependency': 1,
340           'sources': [
341             '<(policy_constant_header_path)',
342             '<(policy_constant_source_path)',
343           ],
344           'include_dirs': [
345             '<(DEPTH)',
346           ],
347           'direct_dependent_settings':  {
348             'include_dirs': [
349               '<(policy_out_dir)'
350             ],
351           },
352           'dependencies': [
353             'cloud_policy_code_generate',
354           ],
355           'configurations': {
356             'Common_Base': {
357               'msvs_target_platform': 'x64',
358             },
359           },
360         },
361       ],
362     }],
363     ['OS=="win" or OS=="mac" or OS=="linux"', {
364       'targets': [
365         {
366           # policy_templates has different inputs and outputs, so it can't use
367           # the rules of chrome_strings
368           'target_name': 'policy_templates',
369           'type': 'none',
370           'variables': {
371             'grit_grd_file': 'policy/resources/policy_templates.grd',
372             'grit_info_cmd': [
373               'python',
374               '<(DEPTH)/tools/grit/grit_info.py',
375               '<@(grit_defines)',
376             ],
377           },
378           'includes': [
379             '../build/grit_target.gypi',
380           ],
381           'actions': [
382             {
383               'action_name': 'policy_templates',
384               'includes': [
385                 '../build/grit_action.gypi',
386               ],
387             },
388           ],
389         },
390       ],
391     }],
392     ['OS=="mac"', {
393       'targets': [
394         {
395           # This is the bundle of the manifest file of Chrome.
396           # It contains the manifest file and its string tables.
397           'target_name': 'chrome_manifest_bundle',
398           'type': 'loadable_module',
399           'mac_bundle': 1,
400           'product_extension': 'manifest',
401           'product_name': '<(mac_bundle_id)',
402           'variables': {
403             # This avoids stripping debugging symbols from the target, which
404             # would fail because there is no binary code here.
405             'mac_strip': 0,
406           },
407           'dependencies': [
408              # Provides app-Manifest.plist and its string tables:
409             'policy_templates',
410           ],
411           'actions': [
412             {
413               'action_name': 'Copy MCX manifest file to manifest bundle',
414               'inputs': [
415                 '<(grit_out_dir)/app/policy/mac/app-Manifest.plist',
416               ],
417               'outputs': [
418                 '<(INTERMEDIATE_DIR)/app_manifest/<(mac_bundle_id).manifest',
419               ],
420               'action': [
421                 # Use plutil -convert xml1 to put the plist into Apple's
422                 # canonical format. As a side effect, this ensures that the
423                 # plist is well-formed.
424                 'plutil',
425                 '-convert',
426                 'xml1',
427                 '<@(_inputs)',
428                 '-o',
429                 '<@(_outputs)',
430               ],
431               'message':
432                   'Copying the MCX policy manifest file to the manifest bundle',
433               'process_outputs_as_mac_bundle_resources': 1,
434             },
435             {
436               'action_name':
437                   'Copy Localizable.strings files to manifest bundle',
438               'variables': {
439                 'input_path': '<(grit_out_dir)/app/policy/mac/strings',
440                 # Directory to collect the Localizable.strings files before
441                 # they are copied to the bundle.
442                 'output_path': '<(INTERMEDIATE_DIR)/app_manifest',
443                 # The reason we are not enumerating all the locales is that
444                 # the translations would eat up 3.5MB disk space in the
445                 # application bundle:
446                 'available_locales': 'en',
447               },
448               'inputs': [
449                 # TODO: remove this helper when we have loops in GYP
450                 '>!@(<(apply_locales_cmd) -d \'<(input_path)/ZZLOCALE.lproj/Localizable.strings\' <(available_locales))',
451               ],
452               'outputs': [
453                 # TODO: remove this helper when we have loops in GYP
454                 '>!@(<(apply_locales_cmd) -d \'<(output_path)/ZZLOCALE.lproj/Localizable.strings\' <(available_locales))',
455               ],
456               'action': [
457                 'cp', '-R',
458                 '<(input_path)/',
459                 '<(output_path)',
460               ],
461               'message':
462                   'Copy the Localizable.strings files to the manifest bundle',
463               'process_outputs_as_mac_bundle_resources': 1,
464             },
465           ],
466         },
467       ],
468     }],
469   ],