Replace usage of cloud_storage in archive_info_unittest.
[chromium-blink-merge.git] / components / policy / BUILD.gn
blobc8266dea07a3f8582ad32ff99ac22f2b8ca198a4
1 # Copyright 2014 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.
5 import("//build/config/features.gni")
6 import("//third_party/protobuf/proto_library.gni")
7 import("//tools/grit/grit_rule.gni")
9 if (is_component_build) {
10   component("policy_component") {
11     deps = [
12       "//components/policy/core/browser",
13       "//components/policy/core/common",
14     ]
15   }
16   group("policy_component_browser") {
17     deps = [
18       ":policy_component",
19     ]
20   }
21   group("policy_component_common") {
22     deps = [
23       ":policy_component",
24     ]
25   }
26 } else {  # Compile to separate libraries.
27   group("policy_component") {
28     deps = [
29       ":policy_component_browser",
30       ":policy_component_common",
31     ]
32   }
33   component("policy_component_browser") {
34     deps = [
35       "//components/policy/core/browser",
36     ]
37   }
38   component("policy_component_common") {
39     deps = [
40       "//components/policy/core/common",
41     ]
42   }
45 if (enable_configuration_policy) {
46   # TODO(brettw) this component should use target_gen_dir instead but the GYP
47   # build puts everything into the following directory. We do the same for now.
48   policy_gen_dir = "$root_gen_dir/policy"
50   # Directory for generating Android App Restrictions resources
51   android_resources_gen_dir = "$policy_gen_dir/android_resources"
53   # This protobuf is equivalent to chrome_settings.proto but shares messages
54   # for policies of the same type, so that less classes have to be generated
55   # and compiled.
56   cloud_policy_proto_path = "$policy_gen_dir/cloud_policy.proto"
58   # This is the "full" protobuf, which defines one protobuf message per
59   # policy. It is also the format currently used by the server.
60   chrome_settings_proto_path = "$policy_gen_dir/chrome_settings.proto"
62   constants_header_path = "$policy_gen_dir/policy_constants.h"
63   constants_source_path = "$policy_gen_dir/policy_constants.cc"
64   protobuf_decoder_path = "$policy_gen_dir/cloud_policy_generated.cc"
65   app_restrictions_path =
66       "$android_resources_gen_dir/xml-v21/app_restrictions.xml"
67   app_resources_path =
68       "$android_resources_gen_dir/values-v21/restriction_values.xml"
70   action("cloud_policy_code_generate") {
71     script = "tools/generate_policy_source.py"
73     if (is_chromeos) {
74       chromeos_flag = "1"
75     } else {
76       chromeos_flag = "0"
77     }
79     inputs = [
80       "resources/policy_templates.json",
81     ]
82     outputs = [
83       constants_header_path,
84       constants_source_path,
85       protobuf_decoder_path,
86       chrome_settings_proto_path,
87       cloud_policy_proto_path,
88       app_restrictions_path,
89       app_resources_path,
90     ]
92     if (current_os != "android") {
93       outputs -= [
94         app_restrictions_path,
95         app_resources_path,
96       ]
97     }
99     args = [
100       "--policy-constants-header=" +
101           rebase_path(constants_header_path, root_build_dir),
102       "--policy-constants-source=" +
103           rebase_path(constants_source_path, root_build_dir),
104       "--chrome-settings-protobuf=" +
105           rebase_path(chrome_settings_proto_path, root_build_dir),
106       "--cloud-policy-protobuf=" +
107           rebase_path(cloud_policy_proto_path, root_build_dir),
108       "--cloud-policy-decoder=" +
109           rebase_path(protobuf_decoder_path, root_build_dir),
110       "--app-restrictions-definition=" +
111           rebase_path(app_restrictions_path, root_build_dir),
112       "--app-restrictions-resources=" +
113           rebase_path(app_resources_path, root_build_dir),
114       current_os,
115       chromeos_flag,
116       rebase_path("resources/policy_templates.json", root_build_dir),
117     ]
118   }
120   proto_library("cloud_policy_proto_generated_compile") {
121     sources = [
122       cloud_policy_proto_path,
123     ]
125     proto_out_dir = "policy/proto"
126     cc_generator_options = "dllexport_decl=POLICY_PROTO_EXPORT:"
127     cc_include = "components/policy/policy_proto_export.h"
128     defines = [ "POLICY_PROTO_COMPILATION" ]
130     deps = [
131       ":cloud_policy_code_generate",
132     ]
133   }
135   # This target builds the "full" protobuf, used for tests only.
136   proto_library("chrome_settings_proto_generated_compile") {
137     sources = [
138       chrome_settings_proto_path,
139     ]
140     proto_out_dir = "policy/proto"
142     deps = [
143       ":cloud_policy_code_generate",
144       ":cloud_policy_proto_generated_compile",
145     ]
146   }
148   static_library("policy") {
149     sources = [
150       constants_header_path,
151       constants_source_path,
152       protobuf_decoder_path,
153     ]
155     defines = [ "POLICY_COMPONENT_IMPLEMENTATION" ]
157     deps = [
158       ":cloud_policy_code_generate",
159       ":cloud_policy_proto_generated_compile",
160       "//base",
161       "//third_party/protobuf:protobuf_lite",
162     ]
163   }
165   group("test_support") {
166     deps = [
167       ":chrome_settings_proto_generated_compile",
168       ":policy",
169     ]
170   }
172   static_library("policy_component_test_support") {
173     testonly = true
174     sources = [
175       "core/browser/configuration_policy_pref_store_test.cc",
176       "core/browser/configuration_policy_pref_store_test.h",
177       "core/common/cloud/mock_cloud_external_data_manager.cc",
178       "core/common/cloud/mock_cloud_external_data_manager.h",
179       "core/common/cloud/mock_cloud_policy_client.cc",
180       "core/common/cloud/mock_cloud_policy_client.h",
181       "core/common/cloud/mock_cloud_policy_store.cc",
182       "core/common/cloud/mock_cloud_policy_store.h",
183       "core/common/cloud/mock_device_management_service.cc",
184       "core/common/cloud/mock_device_management_service.h",
185       "core/common/cloud/mock_user_cloud_policy_store.cc",
186       "core/common/cloud/mock_user_cloud_policy_store.h",
187       "core/common/cloud/policy_builder.cc",
188       "core/common/cloud/policy_builder.h",
189       "core/common/configuration_policy_provider_test.cc",
190       "core/common/configuration_policy_provider_test.h",
191       "core/common/fake_async_policy_loader.cc",
192       "core/common/fake_async_policy_loader.h",
193       "core/common/mock_configuration_policy_provider.cc",
194       "core/common/mock_configuration_policy_provider.h",
195       "core/common/mock_policy_service.cc",
196       "core/common/mock_policy_service.h",
197       "core/common/policy_test_utils.cc",
198       "core/common/policy_test_utils.h",
199       "core/common/preferences_mock_mac.cc",
200       "core/common/preferences_mock_mac.h",
201       "core/common/remote_commands/test_remote_command_job.cc",
202       "core/common/remote_commands/test_remote_command_job.h",
203     ]
205     if (is_chromeos) {
206       sources -= [
207         "core/common/cloud/mock_user_cloud_policy_store.cc",
208         "core/common/cloud/mock_user_cloud_policy_store.h",
209       ]
210     }
212     deps = [
213       ":policy_component",
214       ":test_support",
215       "//components/policy/proto",
216       "//testing/gmock",
217       "//testing/gtest",
218     ]
219   }
221 #TODO(GYP) policy templates, chrome_manifest_bundle