summaryrefslogtreecommitdiffstats
path: root/chrome/app/policy/cloud_policy_codegen.gyp
blob: 1f93409dbd82e29b94d679be54cef7b883a89e19 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
# Copyright (c) 2011 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

{
  'variables': {
    'chromium_code': 1,
    'policy_out_dir': '<(SHARED_INTERMEDIATE_DIR)/policy',
    'protoc_out_dir': '<(SHARED_INTERMEDIATE_DIR)/protoc_out',
    'generate_policy_source_script_path':
        '<(DEPTH)/chrome/tools/build/generate_policy_source.py',
    'policy_constant_header_path':
        '<(policy_out_dir)/policy/policy_constants.h',
    'policy_constant_source_path':
        '<(policy_out_dir)/policy/policy_constants.cc',
    'configuration_policy_type_header_path':
        '<(policy_out_dir)/policy/configuration_policy_type.h',
    'protobuf_decoder_path':
        '<(policy_out_dir)/policy/cloud_policy_generated.cc',
    'cloud_policy_proto_path': '<(policy_out_dir)/policy/cloud_policy.proto',
    'proto_path_substr': 'chrome/browser/policy/proto',
    'proto_rel_path': '<(DEPTH)/<(proto_path_substr)',
  },
  'targets': [
    {
      'target_name': 'cloud_policy_code_generate',
      'type': 'none',
      'actions': [
        {
          'inputs': [
            'policy_templates.json',
            '<(generate_policy_source_script_path)',
          ],
          'outputs': [
            '<(policy_constant_header_path)',
            '<(policy_constant_source_path)',
            '<(configuration_policy_type_header_path)',
            '<(protobuf_decoder_path)',
            '<(cloud_policy_proto_path)',
          ],
          'action_name': 'generate_policy_source',
          'action': [
            'python',
            '<@(generate_policy_source_script_path)',
            '--policy-constants-header=<(policy_constant_header_path)',
            '--policy-constants-source=<(policy_constant_source_path)',
            '--policy-type-header=<(configuration_policy_type_header_path)',
            '--policy-protobuf=<(cloud_policy_proto_path)',
            '--protobuf-decoder=<(protobuf_decoder_path)',
            '<(OS)',
            'policy_templates.json',
          ],
          'message': 'Generating policy source',
        },
      ],
      'direct_dependent_settings': {
        'include_dirs': [
          '<(policy_out_dir)',
          '<(protoc_out_dir)',
        ],
      },
    },
    {
      'target_name': 'cloud_policy_proto_compile',
      'type': 'none',
      'actions': [
        {
          'action_name': 'compile_generated_proto',
          'inputs': [
            '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)protoc<(EXECUTABLE_SUFFIX)',
            '<(policy_out_dir)/policy/cloud_policy.proto',
          ],
          'outputs': [
            '<(PRODUCT_DIR)/pyproto/device_management_pb/cloud_policy_pb2.py',
            '<(protoc_out_dir)/<(proto_path_substr)/cloud_policy.pb.h',
            '<(protoc_out_dir)/<(proto_path_substr)/cloud_policy.pb.cc',
          ],
          'action': [
            '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)protoc<(EXECUTABLE_SUFFIX)',
            '--proto_path=<(policy_out_dir)/policy',
            '<(policy_out_dir)/policy/cloud_policy.proto',
            '--cpp_out=<(protoc_out_dir)/<(proto_path_substr)',
            '--python_out=<(PRODUCT_DIR)/pyproto/device_management_pb',
          ],
          'message': 'Compiling generated cloud policy protobuf',
        },
      ],
      'dependencies': [
        '<(DEPTH)/third_party/protobuf/protobuf.gyp:protoc#host',
        'cloud_policy_code_generate',
      ],
      'direct_dependent_settings': {
        'include_dirs': [
          '<(protoc_out_dir)',
        ]
      },
    },
    {
      'target_name': 'cloud_policy_backend_header_compile',
      'type': 'none',
      'sources': [
        '<(proto_rel_path)/chrome_device_policy.proto',
        '<(proto_rel_path)/device_management_backend.proto',
        '<(proto_rel_path)/device_management_local.proto',
        '<(proto_rel_path)/old_generic_format.proto',
      ],
      'rules': [
        {
          'rule_name': 'gen_proto',
          'extension': 'proto',
          'inputs': [
            '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)protoc<(EXECUTABLE_SUFFIX)',
          ],
          'outputs': [
            '<(PRODUCT_DIR)/pyproto/device_management_pb/<(RULE_INPUT_ROOT)_pb2.py',
            '<(protoc_out_dir)/<(proto_path_substr)/<(RULE_INPUT_ROOT).pb.h',
            '<(protoc_out_dir)/<(proto_path_substr)/<(RULE_INPUT_ROOT).pb.cc',
          ],
          'action': [
            '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)protoc<(EXECUTABLE_SUFFIX)',
            '--proto_path=<(proto_rel_path)',
            '<(proto_rel_path)/<(RULE_INPUT_NAME)',
            '--cpp_out=<(protoc_out_dir)/<(proto_path_substr)',
            '--python_out=<(PRODUCT_DIR)/pyproto/device_management_pb',
          ],
          'message': 'Generating C++ and Python code from <(RULE_INPUT_PATH)',
        },
      ],
      'dependencies': [
        '<(DEPTH)/third_party/protobuf/protobuf.gyp:protoc#host',
      ],
      'direct_dependent_settings': {
        'include_dirs': [
          '<(protoc_out_dir)',
        ]
      },
    },
    {
      'target_name': 'policy',
      'type': 'static_library',
      'hard_dependency': 1,
      'direct_dependent_settings': {
        'include_dirs': [
          '<(policy_out_dir)',
          '<(protoc_out_dir)',
        ],
      },
      'sources': [
        '<(policy_constant_header_path)',
        '<(policy_constant_source_path)',
        '<(configuration_policy_type_header_path)',
        '<(protobuf_decoder_path)',
        '<(protoc_out_dir)/<(proto_path_substr)/cloud_policy.pb.h',
        '<(protoc_out_dir)/<(proto_path_substr)/cloud_policy.pb.cc',
        '<(protoc_out_dir)/<(proto_path_substr)/old_generic_format.pb.h',
        '<(protoc_out_dir)/<(proto_path_substr)/old_generic_format.pb.cc',
        '<(DEPTH)/chrome/browser/policy/policy_map.h',
        '<(DEPTH)/chrome/browser/policy/policy_map.cc',
      ],
      'include_dirs': [
        '<(DEPTH)',
      ],
      'dependencies': [
        'cloud_policy_code_generate',
        'cloud_policy_proto_compile',
        'cloud_policy_backend_header_compile',
        '<(DEPTH)/base/base.gyp:base',
        '<(DEPTH)/third_party/protobuf/protobuf.gyp:protobuf_lite',
      ],
    },
  ],
  'conditions': [
    ['OS=="win"', {
      'targets': [
        {
          'target_name': 'policy_win64',
          'type': 'static_library',
          'hard_dependency': 1,
          'sources': [
            '<(policy_constant_header_path)',
            '<(policy_constant_source_path)',
            '<(configuration_policy_type_header_path)',
          ],
          'direct_dependent_settings':  {
            'include_dirs': [
              '<(policy_out_dir)'
            ],
          },
          'dependencies': [
            'cloud_policy_code_generate',
          ],
          'configurations': {
            'Common_Base': {
              'msvs_target_platform': 'x64',
            },
          },
        },
      ],
    }],
  ],  # 'conditions'
}