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") {
12 "//components/policy/core/browser",
13 "//components/policy/core/common",
16 group("policy_component_browser") {
21 group("policy_component_common") {
26 } else { # Compile to separate libraries.
27 group("policy_component") {
29 ":policy_component_browser",
30 ":policy_component_common",
33 component("policy_component_browser") {
35 "//components/policy/core/browser",
38 component("policy_component_common") {
40 "//components/policy/core/common",
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
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"
68 "$android_resources_gen_dir/values-v21/restriction_values.xml"
70 action("cloud_policy_code_generate") {
71 script = "tools/generate_policy_source.py"
80 "resources/policy_templates.json",
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,
92 if (current_os != "android") {
94 app_restrictions_path,
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),
116 rebase_path("resources/policy_templates.json", root_build_dir),
120 proto_library("cloud_policy_proto_generated_compile") {
122 cloud_policy_proto_path,
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" ]
131 ":cloud_policy_code_generate",
135 # This target builds the "full" protobuf, used for tests only.
136 proto_library("chrome_settings_proto_generated_compile") {
138 chrome_settings_proto_path,
140 proto_out_dir = "policy/proto"
143 ":cloud_policy_code_generate",
144 ":cloud_policy_proto_generated_compile",
148 static_library("policy") {
150 constants_header_path,
151 constants_source_path,
152 protobuf_decoder_path,
155 defines = [ "POLICY_COMPONENT_IMPLEMENTATION" ]
158 ":cloud_policy_code_generate",
159 ":cloud_policy_proto_generated_compile",
161 "//third_party/protobuf:protobuf_lite",
165 group("test_support") {
167 ":chrome_settings_proto_generated_compile",
172 static_library("policy_component_test_support") {
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 "core/common/remote_commands/testing_remote_commands_server.cc",
204 "core/common/remote_commands/testing_remote_commands_server.h",
209 "core/common/cloud/mock_user_cloud_policy_store.cc",
210 "core/common/cloud/mock_user_cloud_policy_store.h",
217 "//components/policy/proto",
223 #TODO(GYP) policy templates, chrome_manifest_bundle