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