Clean dead code w.r.t already-deleted multi-threat-block interstitial.
[chromium-blink-merge.git] / components / policy / BUILD.gn
bloba708c2a63a24223dbf6d26a8f137292bf2638a47
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("resources/policy_templates.gni")
7 import("//third_party/protobuf/proto_library.gni")
8 import("//tools/grit/grit_rule.gni")
10 if (is_component_build) {
11   component("policy_component") {
12     deps = [
13       "//components/policy/core/browser",
14       "//components/policy/core/common",
15     ]
16   }
17   group("policy_component_browser") {
18     deps = [
19       ":policy_component",
20     ]
21   }
22   group("policy_component_common") {
23     deps = [
24       ":policy_component",
25     ]
26   }
27 } else {  # Compile to separate libraries.
28   group("policy_component") {
29     deps = [
30       ":policy_component_browser",
31       ":policy_component_common",
32     ]
33   }
34   component("policy_component_browser") {
35     deps = [
36       "//components/policy/core/browser",
37     ]
38   }
39   component("policy_component_common") {
40     deps = [
41       "//components/policy/core/common",
42     ]
43   }
46 if (enable_configuration_policy) {
47   # TODO(brettw) this component should use target_gen_dir instead but the GYP
48   # build puts everything into the following directory. We do the same for now.
49   policy_gen_dir = "$root_gen_dir/policy"
51   # This protobuf is equivalent to chrome_settings.proto but shares messages
52   # for policies of the same type, so that less classes have to be generated
53   # and compiled.
54   cloud_policy_proto_path = "$policy_gen_dir/cloud_policy.proto"
56   # This is the "full" protobuf, which defines one protobuf message per
57   # policy. It is also the format currently used by the server.
58   chrome_settings_proto_path = "$policy_gen_dir/chrome_settings.proto"
60   constants_header_path = "$policy_gen_dir/policy_constants.h"
61   constants_source_path = "$policy_gen_dir/policy_constants.cc"
62   protobuf_decoder_path = "$policy_gen_dir/cloud_policy_generated.cc"
63   app_restrictions_path = "$policy_gen_dir/app_restrictions.xml"
65   action("cloud_policy_code_generate") {
66     script = "tools/generate_policy_source.py"
68     if (is_chromeos) {
69       chromeos_flag = "1"
70     } else {
71       chromeos_flag = "0"
72     }
74     inputs = [
75       "resources/policy_templates.json",
76     ]
77     outputs = [
78       constants_header_path,
79       constants_source_path,
80       protobuf_decoder_path,
81       chrome_settings_proto_path,
82       cloud_policy_proto_path,
83       app_restrictions_path,
84     ]
86     if (target_os != "android") {
87       outputs -= [ app_restrictions_path ]
88     }
90     args = [
91       "--policy-constants-header=" +
92           rebase_path(constants_header_path, root_build_dir),
93       "--policy-constants-source=" +
94           rebase_path(constants_source_path, root_build_dir),
95       "--chrome-settings-protobuf=" +
96           rebase_path(chrome_settings_proto_path, root_build_dir),
97       "--cloud-policy-protobuf=" +
98           rebase_path(cloud_policy_proto_path, root_build_dir),
99       "--cloud-policy-decoder=" +
100           rebase_path(protobuf_decoder_path, root_build_dir),
101       "--app-restrictions-definition=" +
102           rebase_path(app_restrictions_path, root_build_dir),
103       target_os,
104       chromeos_flag,
105       rebase_path("resources/policy_templates.json", root_build_dir),
106     ]
107   }
109   grit("policy_templates") {
110     source = "resources/policy_templates.grd"
111     use_qualified_include = true
112     output_dir = "$root_gen_dir/chrome"
113     outputs = policy_templates_doc_outputs
114     if (is_android) {
115       outputs += policy_templates_android_outputs
116     }
117     if (is_linux) {
118       outputs += policy_templates_linux_outputs
119     }
120     if (is_mac) {
121       outputs += policy_templates_mac_outputs
123       # TODO(knn) : Move this out once more targets use this.
124       if (is_chrome_branded) {
125         mac_bundle_id = "com.google.Chrome"
126       } else {
127         mac_bundle_id = "org.chromium.Chromium"
128       }
129       defines = [ "mac_bundle_id=$mac_bundle_id" ]
130     }
131     if (is_win) {
132       outputs += policy_templates_windows_outputs
133     }
134   }
136   proto_library("cloud_policy_proto_generated_compile") {
137     sources = [
138       cloud_policy_proto_path,
139     ]
141     proto_out_dir = "policy/proto"
142     cc_generator_options = "dllexport_decl=POLICY_PROTO_EXPORT:"
143     cc_include = "components/policy/policy_proto_export.h"
144     defines = [ "POLICY_PROTO_COMPILATION" ]
146     deps = [
147       ":cloud_policy_code_generate",
148     ]
149   }
151   # This target builds the "full" protobuf, used for tests only.
152   proto_library("chrome_settings_proto_generated_compile") {
153     sources = [
154       chrome_settings_proto_path,
155     ]
156     proto_out_dir = "policy/proto"
158     deps = [
159       ":cloud_policy_code_generate",
160       ":cloud_policy_proto_generated_compile",
161     ]
162   }
164   # The dependencies here are kind of messed up.
165   #
166   # //components/policy/core/browser and .../common depend on this target,
167   # and require it to be compiled with POLICY_COMPONENT_IMPLEMENTATION to
168   # export the necessary symbols in a component build. But other targets like
169   # //chrome/browser also depend on this target, which in component build
170   # ends up in another shared library, but with the IMPLEMENTATION flag set
171   # incorrectly.
172   #
173   # This only reason this works is that this target is a shared library and
174   # the compilation units that this depends on in policy/core/common happen to
175   # not be brought in in the "bad" case. This needs serious untangling, maybe
176   # these files can just be put into policy/core/common?
177   static_library("policy") {
178     sources = [
179       constants_header_path,
180       constants_source_path,
181       protobuf_decoder_path,
182     ]
184     defines = [ "POLICY_COMPONENT_IMPLEMENTATION" ]
186     deps = [
187       ":cloud_policy_code_generate",
188       ":cloud_policy_proto_generated_compile",
189       "//base",
190       "//third_party/protobuf:protobuf_lite",
191     ]
192   }
194   group("test_support") {
195     deps = [
196       ":chrome_settings_proto_generated_compile",
197       ":policy",
198       "//components/policy/core/common",
199     ]
200   }
202   static_library("policy_component_test_support") {
203     testonly = true
204     sources = [
205       "core/browser/configuration_policy_pref_store_test.cc",
206       "core/browser/configuration_policy_pref_store_test.h",
207       "core/common/cloud/mock_cloud_external_data_manager.cc",
208       "core/common/cloud/mock_cloud_external_data_manager.h",
209       "core/common/cloud/mock_cloud_policy_client.cc",
210       "core/common/cloud/mock_cloud_policy_client.h",
211       "core/common/cloud/mock_cloud_policy_store.cc",
212       "core/common/cloud/mock_cloud_policy_store.h",
213       "core/common/cloud/mock_device_management_service.cc",
214       "core/common/cloud/mock_device_management_service.h",
215       "core/common/cloud/mock_user_cloud_policy_store.cc",
216       "core/common/cloud/mock_user_cloud_policy_store.h",
217       "core/common/cloud/policy_builder.cc",
218       "core/common/cloud/policy_builder.h",
219       "core/common/configuration_policy_provider_test.cc",
220       "core/common/configuration_policy_provider_test.h",
221       "core/common/fake_async_policy_loader.cc",
222       "core/common/fake_async_policy_loader.h",
223       "core/common/mock_configuration_policy_provider.cc",
224       "core/common/mock_configuration_policy_provider.h",
225       "core/common/mock_policy_service.cc",
226       "core/common/mock_policy_service.h",
227       "core/common/policy_test_utils.cc",
228       "core/common/policy_test_utils.h",
229       "core/common/preferences_mock_mac.cc",
230       "core/common/preferences_mock_mac.h",
231       "core/common/remote_commands/test_remote_command_job.cc",
232       "core/common/remote_commands/test_remote_command_job.h",
233       "core/common/remote_commands/testing_remote_commands_server.cc",
234       "core/common/remote_commands/testing_remote_commands_server.h",
235     ]
237     if (is_chromeos) {
238       sources -= [
239         "core/common/cloud/mock_user_cloud_policy_store.cc",
240         "core/common/cloud/mock_user_cloud_policy_store.h",
241       ]
242     }
244     deps = [
245       ":policy_component",
246       ":test_support",
247       "//components/policy/proto",
248       "//testing/gmock",
249       "//testing/gtest",
250     ]
251   }
253   if (is_android) {
254     import("//build/config/android/rules.gni")
255     group("app_restrictions_resources") {
256       resources_zip = "res.java/$target_name.zip"
257       generated_resources_dir = "$root_gen_dir/chrome/app/policy/android"
259       copy("${target_name}__consolidate_resources") {
260         sources = [
261           "$root_gen_dir/policy/app_restrictions.xml",
262         ]
263         outputs = [
264           "$generated_resources_dir/xml-v21/app_restrictions.xml",
265         ]
266         deps = [
267           ":policy_templates",
268         ]
269       }
271       # TODO(471115): The write_build_config template is in
272       # //build/config/android/internal_rules.gni and is not meant for external
273       # use. The public rules (in rules.gni) should be updated to support what
274       # we are doing here.
275       build_config_path = "$target_gen_dir/$target_name.build_config"
276       write_build_config("${target_name}__build_config") {
277         build_config = build_config_path
278         resources_zip = "$root_build_dir/$resources_zip"
279         type = "android_resources"
280       }
282       action("${target_name}__create_zip") {
283         script = "//build/android/gn/zip.py"
284         outputs = [
285           "$root_build_dir/$resources_zip",
286         ]
287         generated_resources =
288             [ "$generated_resources_dir/xml-v21/app_restrictions.xml" ] +
289             policy_templates_android_outputs
290         inputs = generated_resources
291         rebased_inputs = rebase_path(generated_resources, root_build_dir)
292         rebased_resources_dir =
293             rebase_path(generated_resources_dir, root_build_dir)
294         args = [
295           "--inputs=$rebased_inputs",
296           "--output=$resources_zip",
297           "--base-dir=$rebased_resources_dir",
298         ]
299       }
301       deps = [
302         ":${target_name}__consolidate_resources",
303         ":${target_name}__build_config",
304         ":${target_name}__create_zip",
305       ]
306     }
307   }
309 #TODO(GYP) chrome_manifest_bundle