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") {
17 deps = [ ":policy_component" ]
19 group("policy_component_common") {
20 deps = [ ":policy_component" ]
22 } else { # Compile to separate libraries.
23 group("policy_component") {
25 ":policy_component_browser",
26 ":policy_component_common",
29 component("policy_component_browser") {
30 deps = [ "//components/policy/core/browser" ]
32 component("policy_component_common") {
33 deps = [ "//components/policy/core/common" ]
37 if (enable_configuration_policy) {
38 # TODO(brettw) this component should use target_gen_dir instead but the GYP
39 # build puts everything into the following directory. We do the same for now.
40 policy_gen_dir = "$root_gen_dir/policy"
42 # This protobuf is equivalent to chrome_settings.proto but shares messages
43 # for policies of the same type, so that less classes have to be generated
45 cloud_policy_proto_path = "$policy_gen_dir/cloud_policy.proto"
47 # This is the "full" protobuf, which defines one protobuf message per
48 # policy. It is also the format currently used by the server.
49 chrome_settings_proto_path = "$policy_gen_dir/chrome_settings.proto"
51 constants_header_path = "$policy_gen_dir/policy_constants.h"
52 constants_source_path = "$policy_gen_dir/policy_constants.cc"
53 protobuf_decoder_path = "$policy_gen_dir/cloud_policy_generated.cc"
55 action("cloud_policy_code_generate") {
56 script = "tools/generate_policy_source.py"
65 "resources/policy_templates.json",
68 constants_header_path,
69 constants_source_path,
70 protobuf_decoder_path,
71 chrome_settings_proto_path,
72 cloud_policy_proto_path,
76 "--policy-constants-header=" +
77 rebase_path(constants_header_path, root_build_dir),
78 "--policy-constants-source=" +
79 rebase_path(constants_source_path, root_build_dir),
80 "--chrome-settings-protobuf=" +
81 rebase_path(chrome_settings_proto_path, root_build_dir),
82 "--cloud-policy-protobuf=" +
83 rebase_path(cloud_policy_proto_path, root_build_dir),
84 "--cloud-policy-decoder=" +
85 rebase_path(protobuf_decoder_path, root_build_dir),
88 rebase_path("resources/policy_templates.json", root_build_dir),
92 proto_library("cloud_policy_proto_generated_compile") {
93 sources = [ cloud_policy_proto_path ]
95 proto_out_dir = "policy/proto"
96 cc_generator_options = "dllexport_decl=POLICY_PROTO_EXPORT:"
97 cc_include = "components/policy/policy_proto_export.h"
98 defines = [ "POLICY_PROTO_COMPILATION" ]
101 ":cloud_policy_code_generate",
105 # This target builds the "full" protobuf, used for tests only.
106 proto_library("chrome_settings_proto_generated_compile") {
107 sources = [ chrome_settings_proto_path ]
108 proto_out_dir = "policy/proto"
111 ":cloud_policy_code_generate",
112 ":cloud_policy_proto_generated_compile",
116 static_library("policy") {
118 constants_header_path,
119 constants_source_path,
120 protobuf_decoder_path,
123 defines = [ "POLICY_COMPONENT_IMPLEMENTATION" ]
126 ":cloud_policy_code_generate",
127 ":cloud_policy_proto_generated_compile",
129 "//third_party/protobuf:protobuf_lite",
133 group("test_support") {
135 ":chrome_settings_proto_generated_compile",
140 static_library("policy_component_test_support") {
143 "core/browser/configuration_policy_pref_store_test.cc",
144 "core/browser/configuration_policy_pref_store_test.h",
145 "core/common/cloud/mock_cloud_external_data_manager.cc",
146 "core/common/cloud/mock_cloud_external_data_manager.h",
147 "core/common/cloud/mock_cloud_policy_client.cc",
148 "core/common/cloud/mock_cloud_policy_client.h",
149 "core/common/cloud/mock_cloud_policy_store.cc",
150 "core/common/cloud/mock_cloud_policy_store.h",
151 "core/common/cloud/mock_device_management_service.cc",
152 "core/common/cloud/mock_device_management_service.h",
153 "core/common/cloud/mock_user_cloud_policy_store.cc",
154 "core/common/cloud/mock_user_cloud_policy_store.h",
155 "core/common/cloud/policy_builder.cc",
156 "core/common/cloud/policy_builder.h",
157 "core/common/configuration_policy_provider_test.cc",
158 "core/common/configuration_policy_provider_test.h",
159 "core/common/mock_configuration_policy_provider.cc",
160 "core/common/mock_configuration_policy_provider.h",
161 "core/common/mock_policy_service.cc",
162 "core/common/mock_policy_service.h",
163 "core/common/policy_test_utils.cc",
164 "core/common/policy_test_utils.h",
165 "core/common/preferences_mock_mac.cc",
166 "core/common/preferences_mock_mac.h",
171 "core/common/cloud/mock_user_cloud_policy_store.cc",
172 "core/common/cloud/mock_user_cloud_policy_store.h",
179 "//components/policy/proto",
186 #TODO(GYP) policy templates, chrome_manifest_bundle