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. 4 5 import("//build/config/features.gni") 6 import("//third_party/protobuf/proto_library.gni") 7 import("//tools/grit/grit_rule.gni") 8 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 = [ ":policy_component" ] 18 } 19 group("policy_component_common") { 20 deps = [ ":policy_component" ] 21 } 22 } else { # Compile to separate libraries. 23 group("policy_component") { 24 deps = [ 25 ":policy_component_browser", 26 ":policy_component_common", 27 ] 28 } 29 component("policy_component_browser") { 30 deps = [ "//components/policy/core/browser" ] 31 } 32 component("policy_component_common") { 33 deps = [ "//components/policy/core/common" ] 34 } 35 } 36 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" 41 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 44 # and compiled. 45 cloud_policy_proto_path = "$policy_gen_dir/cloud_policy.proto" 46 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" 50 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" 54 55 action("cloud_policy_code_generate") { 56 script = "tools/generate_policy_source.py" 57 58 if (is_chromeos) { 59 chromeos_flag = "1" 60 } else { 61 chromeos_flag = "0" 62 } 63 64 inputs = [ 65 "resources/policy_templates.json", 66 ] 67 outputs = [ 68 constants_header_path, 69 constants_source_path, 70 protobuf_decoder_path, 71 chrome_settings_proto_path, 72 cloud_policy_proto_path, 73 ] 74 75 args = [ 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), 86 os, 87 chromeos_flag, 88 rebase_path("resources/policy_templates.json", root_build_dir), 89 ] 90 } 91 92 proto_library("cloud_policy_proto_generated_compile") { 93 sources = [ cloud_policy_proto_path ] 94 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" ] 99 100 deps = [ 101 ":cloud_policy_code_generate", 102 ] 103 } 104 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" 109 110 deps = [ 111 ":cloud_policy_code_generate", 112 ":cloud_policy_proto_generated_compile", 113 ] 114 } 115 116 static_library("policy") { 117 sources = [ 118 constants_header_path, 119 constants_source_path, 120 protobuf_decoder_path, 121 ] 122 123 defines = [ "POLICY_COMPONENT_IMPLEMENTATION" ] 124 125 deps = [ 126 ":cloud_policy_code_generate", 127 ":cloud_policy_proto_generated_compile", 128 "//base", 129 "//third_party/protobuf:protobuf_lite", 130 ] 131 } 132 133 group("test_support") { 134 deps = [ 135 ":chrome_settings_proto_generated_compile", 136 ":policy", 137 ] 138 } 139 140 static_library("policy_component_test_support") { 141 testonly = true 142 sources = [ 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", 167 ] 168 169 if (is_chromeos) { 170 sources -= [ 171 "core/common/cloud/mock_user_cloud_policy_store.cc", 172 "core/common/cloud/mock_user_cloud_policy_store.h", 173 ] 174 } 175 176 deps = [ 177 ":policy_component", 178 ":test_support", 179 "//components/policy/proto", 180 "//testing/gmock", 181 "//testing/gtest", 182 ] 183 } 184 } 185 186 #TODO(GYP) policy templates, chrome_manifest_bundle 187