1# Copyright 2016 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 5import("//build/config/locales.gni") 6import("//chrome/browser/buildflags.gni") 7import("//chrome/common/features.gni") 8import("//chromeos/components/media_app_ui/media_app_ui.gni") 9import("//extensions/buildflags/buildflags.gni") 10import("//ui/base/ui_features.gni") 11import("chrome_repack_locales.gni") 12 13# Generates a rule to repack a set of resources, substituting a given string 14# in for the percentage (e.g. "100", "200"). It generates the repacked files in 15# the "gen" directory, and then introduces a copy rule to copy it to the root 16# build directory. 17# 18# Argument: 19# percent [required] 20# String to substitute for the percentage. 21template("chrome_repack_percent") { 22 percent = invoker.percent 23 24 repack(target_name) { 25 forward_variables_from(invoker, 26 [ 27 "copy_data_to_bundle", 28 "repack_whitelist", 29 "visibility", 30 ]) 31 32 # All sources should also have deps for completeness. 33 sources = [ 34 "$root_gen_dir/chrome/renderer_resources_${percent}_percent.pak", 35 "$root_gen_dir/chrome/theme_resources_${percent}_percent.pak", 36 "$root_gen_dir/components/components_resources_${percent}_percent.pak", 37 "$root_gen_dir/content/app/resources/content_resources_${percent}_percent.pak", 38 "$root_gen_dir/third_party/blink/public/resources/blink_scaled_resources_${percent}_percent.pak", 39 "$root_gen_dir/ui/resources/ui_resources_${percent}_percent.pak", 40 ] 41 42 deps = [ 43 "//chrome/app/theme:theme_resources", 44 "//chrome/renderer:resources", 45 "//components/resources", 46 "//components/strings", 47 "//content/app/resources", 48 "//net:net_resources", 49 "//third_party/blink/public:scaled_resources_${percent}_percent", 50 "//ui/resources", 51 ] 52 53 if (defined(invoker.deps)) { 54 deps += invoker.deps 55 } 56 57 if (toolkit_views) { 58 sources += [ "$root_gen_dir/ui/views/resources/views_resources_${percent}_percent.pak" ] 59 deps += [ "//ui/views/resources" ] 60 } 61 if (is_chromeos) { 62 sources += [ 63 "$root_gen_dir/ash/app_list/resources/app_list_resources_${percent}_percent.pak", 64 "$root_gen_dir/ash/login/resources/login_resources_${percent}_percent.pak", 65 "$root_gen_dir/ui/chromeos/resources/ui_chromeos_resources_${percent}_percent.pak", 66 ] 67 deps += [ 68 "//ash/app_list/resources", 69 "//ash/login/resources", 70 "//ui/chromeos/resources", 71 ] 72 } 73 if (enable_extensions) { 74 sources += [ "$root_gen_dir/extensions/extensions_browser_resources_${percent}_percent.pak" ] 75 deps += [ "//extensions:extensions_browser_resources" ] 76 } 77 78 output = "${invoker.output_dir}/chrome_${percent}_percent.pak" 79 } 80} 81 82template("chrome_extra_paks") { 83 repack(target_name) { 84 forward_variables_from(invoker, 85 [ 86 "copy_data_to_bundle", 87 "repack_whitelist", 88 "visibility", 89 ]) 90 output = "${invoker.output_dir}/resources.pak" 91 sources = [ 92 "$root_gen_dir/chrome/browser_resources.pak", 93 "$root_gen_dir/chrome/chrome_unscaled_resources.pak", 94 "$root_gen_dir/chrome/common_resources.pak", 95 "$root_gen_dir/components/autofill/core/browser/autofill_address_rewriter_resources.pak", 96 "$root_gen_dir/components/components_resources.pak", 97 "$root_gen_dir/content/browser/tracing/tracing_resources.pak", 98 "$root_gen_dir/content/content_resources.pak", 99 "$root_gen_dir/mojo/public/js/mojo_bindings_resources.pak", 100 "$root_gen_dir/net/net_resources.pak", 101 "$root_gen_dir/third_party/blink/public/resources/blink_resources.pak", 102 "$root_gen_dir/ui/resources/webui_resources.pak", 103 ] 104 deps = [ 105 "//chrome/app/theme:chrome_unscaled_resources", 106 "//chrome/browser:resources", 107 "//chrome/common:resources", 108 "//components/autofill/core/browser:autofill_address_rewriter_resources", 109 "//components/resources", 110 "//content:content_resources", 111 "//content/browser/tracing:resources", 112 "//mojo/public/js:resources", 113 "//net:net_resources", 114 "//third_party/blink/public:resources", 115 "//ui/resources", 116 ] 117 if (defined(invoker.deps)) { 118 deps += invoker.deps 119 } 120 if (defined(invoker.additional_paks)) { 121 sources += invoker.additional_paks 122 } 123 124 if (!is_android) { 125 # New paks should be added here by default. 126 sources += [ 127 "$root_gen_dir/chrome/bookmarks_resources.pak", 128 "$root_gen_dir/chrome/component_extension_resources.pak", 129 "$root_gen_dir/chrome/dev_ui_resources.pak", 130 "$root_gen_dir/chrome/downloads_resources.pak", 131 "$root_gen_dir/chrome/gaia_auth_host_resources.pak", 132 "$root_gen_dir/chrome/history_resources.pak", 133 "$root_gen_dir/chrome/local_ntp_resources.pak", 134 "$root_gen_dir/chrome/new_tab_page_resources.pak", 135 "$root_gen_dir/chrome/settings_resources.pak", 136 "$root_gen_dir/content/browser/devtools/devtools_resources.pak", 137 "$root_gen_dir/headless/headless_lib_resources.pak", 138 ] 139 deps += [ 140 "//chrome/browser/resources:bookmarks_resources", 141 "//chrome/browser/resources:component_extension_resources", 142 "//chrome/browser/resources:dev_ui_paks", 143 "//chrome/browser/resources:downloads_resources", 144 "//chrome/browser/resources:gaia_auth_host_resources", 145 "//chrome/browser/resources:history_resources", 146 "//chrome/browser/resources:local_ntp_resources", 147 "//chrome/browser/resources:new_tab_page_resources", 148 "//chrome/browser/resources:settings_resources", 149 "//content/browser/devtools:devtools_resources", 150 "//headless:resources", 151 ] 152 } 153 if (use_qt) { 154 sources -= [ 155 "$root_gen_dir/content/browser/tracing/tracing_resources.pak", 156 ] 157 deps -= [ 158 "//content/browser/tracing:resources", 159 ] 160 } 161 162 if (is_chromeos) { 163 sources += [ 164 "$root_gen_dir/ash/public/cpp/resources/ash_public_unscaled_resources.pak", 165 "$root_gen_dir/chrome/browser/supervised_user/supervised_user_unscaled_resources.pak", 166 "$root_gen_dir/chrome/camera_resources.pak", 167 "$root_gen_dir/chrome/cellular_setup_resources.pak", 168 "$root_gen_dir/chrome/multidevice_setup_resources.pak", 169 "$root_gen_dir/chrome/os_settings_resources.pak", 170 "$root_gen_dir/chromeos/chromeos_help_app_bundle_resources.pak", 171 "$root_gen_dir/chromeos/chromeos_help_app_resources.pak", 172 "$root_gen_dir/chromeos/chromeos_media_app_bundle_resources.pak", 173 "$root_gen_dir/chromeos/chromeos_media_app_resources.pak", 174 "$root_gen_dir/chromeos/chromeos_print_management_resources.pak", 175 "$root_gen_dir/chromeos/chromeos_resources.pak", 176 "$root_gen_dir/third_party/ink/ink_resources.pak", 177 "$root_gen_dir/ui/file_manager/file_manager_resources.pak", 178 ] 179 deps += [ 180 "//ash/public/cpp/resources:ash_public_unscaled_resources", 181 "//chrome/browser/resources:os_settings_resources", 182 "//chrome/browser/resources/chromeos:camera_resources", 183 "//chrome/browser/resources/chromeos:cellular_setup_resources", 184 "//chrome/browser/resources/chromeos:multidevice_setup_resources", 185 "//chrome/browser/supervised_user:supervised_user_unscaled_resources", 186 "//chromeos/resources", 187 "//chromeos/resources:help_app_bundle_resources", 188 "//chromeos/resources:help_app_resources", 189 "//chromeos/resources:media_app_bundle_resources", 190 "//chromeos/resources:media_app_resources", 191 "//chromeos/resources:print_management_resources", 192 "//third_party/ink:ink_resources", 193 "//ui/file_manager:resources", 194 ] 195 196 if (!is_official_build) { 197 sources += [ 198 "$root_gen_dir/chromeos/chromeos_sample_system_web_app_resources.pak", 199 ] 200 deps += [ "//chromeos/resources:sample_system_web_app_resources" ] 201 } 202 } 203 if (!is_android && !is_chromeos) { 204 sources += [ "$root_gen_dir/chrome/welcome_resources.pak" ] 205 deps += [ "//chrome/browser/resources:welcome_resources" ] 206 } 207 if (enable_extensions) { 208 sources += [ 209 "$root_gen_dir/chrome/extensions_resources.pak", 210 "$root_gen_dir/chrome/sync_file_system_internals_resources.pak", 211 "$root_gen_dir/extensions/extensions_renderer_resources.pak", 212 "$root_gen_dir/extensions/extensions_resources.pak", 213 ] 214 deps += [ 215 "//chrome/browser/resources:extensions_resources", 216 "//chrome/browser/resources:sync_file_system_internals_resources", 217 "//extensions:extensions_resources", 218 ] 219 } 220 if (enable_print_preview) { 221 sources += [ "$root_gen_dir/chrome/print_preview_resources.pak" ] 222 deps += [ "//chrome/browser/resources:print_preview_resources" ] 223 } 224 if (enable_webui_tab_strip) { 225 sources += [ "$root_gen_dir/chrome/tab_strip_resources.pak" ] 226 deps += [ "//chrome/browser/resources:tab_strip_resources" ] 227 } 228 if (enable_kaleidoscope) { 229 sources += [ "$root_gen_dir/chrome/browser/media/kaleidoscope/internal/kaleidoscope_resources.pak" ] 230 deps += [ "//chrome/browser/media/kaleidoscope/internal:kaleidoscope_resources_grit" ] 231 } 232 } 233} 234 235# Defines repack() targets used by Chrome. Specifically: 236# * chrome_100_percent.pak 237# * chrome_200_percent.pak (optionally) 238# * resources.pak 239# * locale .pak files 240# 241# Parameters: 242# output_dir [required]: Directory to output .pak files. Locale .pak files 243# will always be place in $output_dir/locales 244# additional_extra_paks: List of extra .pak sources for resources.pak. 245# locale_whitelist: if set, override repack_whitelist for locale .pak files. 246# copy_data_to_bundle: 247# deps: 248# output_dir: 249# public_deps: 250# repack_whitelist: 251# visibility: 252# Normal meanings. 253# 254template("chrome_paks") { 255 chrome_repack_percent("${target_name}_100_percent") { 256 percent = "100" 257 forward_variables_from(invoker, 258 [ 259 "copy_data_to_bundle", 260 "deps", 261 "output_dir", 262 "repack_whitelist", 263 "visibility", 264 ]) 265 } 266 267 if (enable_hidpi) { 268 chrome_repack_percent("${target_name}_200_percent") { 269 percent = "200" 270 forward_variables_from(invoker, 271 [ 272 "copy_data_to_bundle", 273 "deps", 274 "output_dir", 275 "repack_whitelist", 276 "visibility", 277 ]) 278 } 279 } 280 281 chrome_extra_paks("${target_name}_extra") { 282 forward_variables_from(invoker, 283 [ 284 "copy_data_to_bundle", 285 "deps", 286 "output_dir", 287 "repack_whitelist", 288 "visibility", 289 ]) 290 if (defined(invoker.additional_extra_paks)) { 291 additional_paks = invoker.additional_extra_paks 292 } 293 } 294 295 chrome_repack_locales("${target_name}_locales") { 296 forward_variables_from(invoker, 297 [ 298 "copy_data_to_bundle", 299 "deps", 300 "visibility", 301 ]) 302 if (defined(invoker.locale_whitelist)) { 303 repack_whitelist = invoker.locale_whitelist 304 } else if (defined(invoker.repack_whitelist)) { 305 repack_whitelist = invoker.repack_whitelist 306 } 307 308 input_locales = locales 309 output_dir = "${invoker.output_dir}/locales" 310 311 if (is_mac) { 312 output_locales = locales_as_mac_outputs 313 } else { 314 output_locales = locales 315 } 316 } 317 318 group(target_name) { 319 forward_variables_from(invoker, [ "deps" ]) 320 public_deps = [ 321 ":${target_name}_100_percent", 322 ":${target_name}_extra", 323 ":${target_name}_locales", 324 ] 325 if (enable_hidpi) { 326 public_deps += [ ":${target_name}_200_percent" ] 327 } 328 if (!defined(invoker.copy_data_to_bundle) || !invoker.copy_data_to_bundle) { 329 data_deps = public_deps 330 } 331 if (defined(invoker.public_deps)) { 332 public_deps += invoker.public_deps 333 } 334 } 335} 336