agrieve | a6085a6a | 2016-09-16 17:48:10 | [diff] [blame] | 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 | |
| 5 | import("//build/config/locales.gni") |
brettw | d1bc9da | 2016-10-14 19:04:24 | [diff] [blame] | 6 | import("//chrome/common/features.gni") |
Scott Violet | c8240b0 | 2018-03-08 22:03:59 | [diff] [blame] | 7 | import("//extensions/buildflags/buildflags.gni") |
agrieve | 5fce4ef | 2016-09-21 17:21:59 | [diff] [blame] | 8 | import("//ui/base/ui_features.gni") |
agrieve | a6085a6a | 2016-09-16 17:48:10 | [diff] [blame] | 9 | import("chrome_repack_locales.gni") |
| 10 | |
| 11 | # Generates a rule to repack a set of resources, substituting a given string |
| 12 | # in for the percentage (e.g. "100", "200"). It generates the repacked files in |
| 13 | # the "gen" directory, and then introduces a copy rule to copy it to the root |
| 14 | # build directory. |
| 15 | # |
| 16 | # Argument: |
| 17 | # percent [required] |
| 18 | # String to substitute for the percentage. |
| 19 | template("chrome_repack_percent") { |
| 20 | percent = invoker.percent |
| 21 | |
| 22 | repack(target_name) { |
| 23 | forward_variables_from(invoker, |
| 24 | [ |
| 25 | "copy_data_to_bundle", |
| 26 | "repack_whitelist", |
| 27 | "visibility", |
| 28 | ]) |
| 29 | |
| 30 | # All sources should also have deps for completeness. |
| 31 | sources = [ |
agrieve | a6085a6a | 2016-09-16 17:48:10 | [diff] [blame] | 32 | "$root_gen_dir/chrome/renderer_resources_${percent}_percent.pak", |
| 33 | "$root_gen_dir/chrome/theme_resources_${percent}_percent.pak", |
| 34 | "$root_gen_dir/components/components_resources_${percent}_percent.pak", |
| 35 | "$root_gen_dir/content/app/resources/content_resources_${percent}_percent.pak", |
Blink Reformat | a30d423 | 2018-04-07 15:31:06 | [diff] [blame] | 36 | "$root_gen_dir/third_party/blink/public/resources/blink_scaled_resources_${percent}_percent.pak", |
agrieve | a6085a6a | 2016-09-16 17:48:10 | [diff] [blame] | 37 | "$root_gen_dir/ui/resources/ui_resources_${percent}_percent.pak", |
| 38 | ] |
| 39 | |
| 40 | deps = [ |
| 41 | "//chrome/app/theme:theme_resources", |
| 42 | "//chrome/renderer:resources", |
| 43 | "//components/resources", |
| 44 | "//components/strings", |
| 45 | "//content/app/resources", |
| 46 | "//net:net_resources", |
Blink Reformat | a30d423 | 2018-04-07 15:31:06 | [diff] [blame] | 47 | "//third_party/blink/public:scaled_resources_${percent}_percent", |
agrieve | a6085a6a | 2016-09-16 17:48:10 | [diff] [blame] | 48 | "//ui/resources", |
| 49 | ] |
| 50 | |
| 51 | if (defined(invoker.deps)) { |
| 52 | deps += invoker.deps |
| 53 | } |
| 54 | |
agrieve | a6085a6a | 2016-09-16 17:48:10 | [diff] [blame] | 55 | if (toolkit_views) { |
| 56 | sources += [ "$root_gen_dir/ui/views/resources/views_resources_${percent}_percent.pak" ] |
| 57 | deps += [ "//ui/views/resources" ] |
| 58 | } |
| 59 | if (is_chromeos) { |
James Cook | f8a2bf7 | 2017-10-16 18:51:39 | [diff] [blame] | 60 | sources += [ |
wutao | cd13722f | 2018-02-21 22:00:35 | [diff] [blame] | 61 | "$root_gen_dir/ash/components/resources/ash_components_resources_${percent}_percent.pak", |
Sarah Hu | f5f60fe | 2018-07-31 21:28:58 | [diff] [blame] | 62 | "$root_gen_dir/ash/login/resources/login_resources_${percent}_percent.pak", |
James Cook | f8a2bf7 | 2017-10-16 18:51:39 | [diff] [blame] | 63 | "$root_gen_dir/ui/chromeos/resources/ui_chromeos_resources_${percent}_percent.pak", |
| 64 | ] |
| 65 | deps += [ |
wutao | cd13722f | 2018-02-21 22:00:35 | [diff] [blame] | 66 | "//ash/components/resources", |
Sarah Hu | f5f60fe | 2018-07-31 21:28:58 | [diff] [blame] | 67 | "//ash/login/resources", |
James Cook | f8a2bf7 | 2017-10-16 18:51:39 | [diff] [blame] | 68 | "//ui/chromeos/resources", |
| 69 | ] |
agrieve | a6085a6a | 2016-09-16 17:48:10 | [diff] [blame] | 70 | } |
| 71 | if (enable_extensions) { |
| 72 | sources += [ "$root_gen_dir/extensions/extensions_browser_resources_${percent}_percent.pak" ] |
| 73 | deps += [ "//extensions:extensions_browser_resources" ] |
| 74 | } |
| 75 | if (enable_app_list) { |
Jiaquan He | 68b28e2 | 2018-06-12 06:58:09 | [diff] [blame] | 76 | sources += [ "$root_gen_dir/ash/app_list/resources/app_list_resources_${percent}_percent.pak" ] |
| 77 | deps += [ "//ash/app_list/resources" ] |
agrieve | a6085a6a | 2016-09-16 17:48:10 | [diff] [blame] | 78 | } |
| 79 | |
| 80 | output = "${invoker.output_dir}/chrome_${percent}_percent.pak" |
| 81 | } |
| 82 | } |
| 83 | |
agrieve | a6085a6a | 2016-09-16 17:48:10 | [diff] [blame] | 84 | template("chrome_extra_paks") { |
| 85 | repack(target_name) { |
| 86 | forward_variables_from(invoker, |
| 87 | [ |
| 88 | "copy_data_to_bundle", |
| 89 | "repack_whitelist", |
| 90 | "visibility", |
| 91 | ]) |
| 92 | output = "${invoker.output_dir}/resources.pak" |
| 93 | sources = [ |
agrieve | a6085a6a | 2016-09-16 17:48:10 | [diff] [blame] | 94 | "$root_gen_dir/chrome/browser_resources.pak", |
| 95 | "$root_gen_dir/chrome/chrome_unscaled_resources.pak", |
| 96 | "$root_gen_dir/chrome/common_resources.pak", |
| 97 | "$root_gen_dir/chrome/invalidations_resources.pak", |
| 98 | "$root_gen_dir/chrome/net_internals_resources.pak", |
michaeln | 832a543 | 2017-02-02 03:46:30 | [diff] [blame] | 99 | "$root_gen_dir/chrome/quota_internals_resources.pak", |
robliao | 71aed69 | 2016-09-27 17:40:25 | [diff] [blame] | 100 | "$root_gen_dir/chrome/task_scheduler_internals_resources.pak", |
agrieve | a6085a6a | 2016-09-16 17:48:10 | [diff] [blame] | 101 | "$root_gen_dir/chrome/translate_internals_resources.pak", |
| 102 | "$root_gen_dir/components/components_resources.pak", |
| 103 | "$root_gen_dir/content/browser/tracing/tracing_resources.pak", |
| 104 | "$root_gen_dir/content/content_resources.pak", |
Yuzhu Shen | 2efe4277 | 2017-11-11 02:01:09 | [diff] [blame] | 105 | "$root_gen_dir/mojo/public/js/mojo_bindings_resources.pak", |
agrieve | a6085a6a | 2016-09-16 17:48:10 | [diff] [blame] | 106 | "$root_gen_dir/net/net_resources.pak", |
Blink Reformat | a30d423 | 2018-04-07 15:31:06 | [diff] [blame] | 107 | "$root_gen_dir/third_party/blink/public/resources/blink_resources.pak", |
agrieve | a6085a6a | 2016-09-16 17:48:10 | [diff] [blame] | 108 | "$root_gen_dir/ui/resources/webui_resources.pak", |
| 109 | ] |
| 110 | deps = [ |
| 111 | "//chrome/app/theme:chrome_unscaled_resources", |
| 112 | "//chrome/browser:resources", |
| 113 | "//chrome/browser/resources:invalidations_resources", |
| 114 | "//chrome/browser/resources:net_internals_resources", |
michaeln | 832a543 | 2017-02-02 03:46:30 | [diff] [blame] | 115 | "//chrome/browser/resources:quota_internals_resources", |
robliao | 71aed69 | 2016-09-27 17:40:25 | [diff] [blame] | 116 | "//chrome/browser/resources:task_scheduler_internals_resources", |
agrieve | a6085a6a | 2016-09-16 17:48:10 | [diff] [blame] | 117 | "//chrome/browser/resources:translate_internals_resources", |
| 118 | "//chrome/common:resources", |
| 119 | "//components/resources", |
| 120 | "//content:resources", |
| 121 | "//content/browser/tracing:resources", |
Yuzhu Shen | 2efe4277 | 2017-11-11 02:01:09 | [diff] [blame] | 122 | "//mojo/public/js:resources", |
agrieve | a6085a6a | 2016-09-16 17:48:10 | [diff] [blame] | 123 | "//net:net_resources", |
Blink Reformat | a30d423 | 2018-04-07 15:31:06 | [diff] [blame] | 124 | "//third_party/blink/public:resources", |
agrieve | a6085a6a | 2016-09-16 17:48:10 | [diff] [blame] | 125 | "//ui/resources", |
| 126 | ] |
| 127 | if (defined(invoker.deps)) { |
| 128 | deps += invoker.deps |
| 129 | } |
agrieve | 5fce4ef | 2016-09-21 17:21:59 | [diff] [blame] | 130 | if (defined(invoker.additional_paks)) { |
| 131 | sources += invoker.additional_paks |
| 132 | } |
agrieve | a6085a6a | 2016-09-16 17:48:10 | [diff] [blame] | 133 | |
thestig | 6b471b0e | 2017-05-26 17:41:52 | [diff] [blame] | 134 | if (is_android) { |
| 135 | sources += [ "$root_gen_dir/chrome/webapks_ui_resources.pak" ] |
| 136 | deps += [ "//chrome/browser/resources:webapks_ui_resources" ] |
| 137 | } else { |
agrieve | a6085a6a | 2016-09-16 17:48:10 | [diff] [blame] | 138 | # New paks should be added here by default. |
| 139 | sources += [ |
agrieve | a6085a6a | 2016-09-16 17:48:10 | [diff] [blame] | 140 | "$root_gen_dir/chrome/component_extension_resources.pak", |
Kyle Milka | 07a0ef0 | 2018-11-09 22:18:09 | [diff] [blame] | 141 | "$root_gen_dir/chrome/local_ntp_resources.pak", |
agrieve | a6085a6a | 2016-09-16 17:48:10 | [diff] [blame] | 142 | "$root_gen_dir/chrome/settings_resources.pak", |
thakis | 300faa7 | 2017-02-28 23:59:43 | [diff] [blame] | 143 | "$root_gen_dir/content/browser/devtools/devtools_resources.pak", |
dvallet | 7bbfe9f | 2017-05-16 05:41:13 | [diff] [blame] | 144 | "$root_gen_dir/headless/headless_lib_resources.pak", |
agrieve | a6085a6a | 2016-09-16 17:48:10 | [diff] [blame] | 145 | ] |
| 146 | deps += [ |
| 147 | "//chrome/browser/resources:component_extension_resources", |
Kyle Milka | 07a0ef0 | 2018-11-09 22:18:09 | [diff] [blame] | 148 | "//chrome/browser/resources:local_ntp_resources", |
agrieve | a6085a6a | 2016-09-16 17:48:10 | [diff] [blame] | 149 | "//chrome/browser/resources:settings_resources", |
agrieve | a6085a6a | 2016-09-16 17:48:10 | [diff] [blame] | 150 | "//content/browser/devtools:devtools_resources", |
dvallet | 7bbfe9f | 2017-05-16 05:41:13 | [diff] [blame] | 151 | "//headless:resources", |
agrieve | a6085a6a | 2016-09-16 17:48:10 | [diff] [blame] | 152 | ] |
| 153 | } |
| 154 | if (is_chromeos) { |
fukino | 27d65fa | 2016-12-07 04:44:37 | [diff] [blame] | 155 | sources += [ |
wutao | e5856b5 | 2018-04-20 18:54:08 | [diff] [blame] | 156 | "$root_gen_dir/ash/public/cpp/resources/ash_public_unscaled_resources.pak", |
Kyle Horimoto | 80c66e4 | 2018-03-23 00:23:10 | [diff] [blame] | 157 | "$root_gen_dir/chrome/multidevice_setup_resources.pak", |
Kyle Horimoto | 940d7df | 2018-03-17 01:00:23 | [diff] [blame] | 158 | "$root_gen_dir/chromeos/chromeos_resources.pak", |
dstockwell | 000c2fd | 2019-01-09 10:33:33 | [diff] [blame] | 159 | "$root_gen_dir/third_party/ink/ink_resources.pak", |
fukino | 27d65fa | 2016-12-07 04:44:37 | [diff] [blame] | 160 | "$root_gen_dir/ui/file_manager/file_manager_resources.pak", |
| 161 | ] |
| 162 | deps += [ |
wutao | e5856b5 | 2018-04-20 18:54:08 | [diff] [blame] | 163 | "//ash/public/cpp/resources:ash_public_unscaled_resources", |
Kyle Horimoto | 80c66e4 | 2018-03-23 00:23:10 | [diff] [blame] | 164 | "//chrome/browser/resources/chromeos:multidevice_setup_resources", |
Kyle Horimoto | 940d7df | 2018-03-17 01:00:23 | [diff] [blame] | 165 | "//chromeos/resources", |
dstockwell | 000c2fd | 2019-01-09 10:33:33 | [diff] [blame] | 166 | "//third_party/ink:ink_resources", |
fukino | 27d65fa | 2016-12-07 04:44:37 | [diff] [blame] | 167 | "//ui/file_manager:resources", |
| 168 | ] |
agrieve | a6085a6a | 2016-09-16 17:48:10 | [diff] [blame] | 169 | } |
dpapad | b1f8e9a | 2018-10-18 21:36:08 | [diff] [blame] | 170 | if (!is_android && !is_chromeos) { |
| 171 | sources += [ "$root_gen_dir/chrome/onboarding_welcome_resources.pak" ] |
| 172 | deps += [ "//chrome/browser/resources:onboarding_welcome_resources" ] |
| 173 | } |
agrieve | a6085a6a | 2016-09-16 17:48:10 | [diff] [blame] | 174 | if (enable_extensions) { |
| 175 | sources += [ |
dpapad | 100ff11 | 2017-10-04 20:05:27 | [diff] [blame] | 176 | "$root_gen_dir/chrome/extensions_resources.pak", |
thestig | 6b471b0e | 2017-05-26 17:41:52 | [diff] [blame] | 177 | "$root_gen_dir/chrome/sync_file_system_internals_resources.pak", |
agrieve | a6085a6a | 2016-09-16 17:48:10 | [diff] [blame] | 178 | "$root_gen_dir/extensions/extensions_renderer_resources.pak", |
| 179 | "$root_gen_dir/extensions/extensions_resources.pak", |
| 180 | ] |
thestig | 6b471b0e | 2017-05-26 17:41:52 | [diff] [blame] | 181 | deps += [ |
dpapad | 100ff11 | 2017-10-04 20:05:27 | [diff] [blame] | 182 | "//chrome/browser/resources:extensions_resources", |
thestig | 6b471b0e | 2017-05-26 17:41:52 | [diff] [blame] | 183 | "//chrome/browser/resources:sync_file_system_internals_resources", |
| 184 | "//extensions:extensions_resources", |
| 185 | ] |
gonzalon | 87192d77 | 2017-02-07 22:31:10 | [diff] [blame] | 186 | } |
dpapad | 18bff08 | 2017-10-26 02:19:51 | [diff] [blame] | 187 | if (enable_print_preview) { |
| 188 | sources += [ "$root_gen_dir/chrome/print_preview_resources.pak" ] |
| 189 | deps += [ "//chrome/browser/resources:print_preview_resources" ] |
| 190 | } |
agrieve | a6085a6a | 2016-09-16 17:48:10 | [diff] [blame] | 191 | } |
| 192 | } |
agrieve | 5fce4ef | 2016-09-21 17:21:59 | [diff] [blame] | 193 | |
| 194 | # Defines repack() targets used by Chrome. Specifically: |
| 195 | # * chrome_100_percent.pak |
| 196 | # * chrome_200_percent.pak (optionally) |
| 197 | # * resources.pak |
| 198 | # * locale .pak files |
| 199 | # |
| 200 | # Paramters: |
| 201 | # output_dir [required]: Directory to output .pak files. Locale .pak files |
| 202 | # will always be place in $output_dir/locales |
| 203 | # additional_extra_paks: List of extra .pak sources for resources.pak. |
zpeng | 368afac8 | 2017-07-17 18:47:45 | [diff] [blame] | 204 | # locale_whitelist: if set, override repack_whitelist for locale .pak files. |
agrieve | 5fce4ef | 2016-09-21 17:21:59 | [diff] [blame] | 205 | # copy_data_to_bundle: |
| 206 | # deps: |
| 207 | # output_dir: |
| 208 | # public_deps: |
| 209 | # repack_whitelist: |
| 210 | # visibility: |
| 211 | # Normal meanings. |
| 212 | # |
| 213 | template("chrome_paks") { |
| 214 | chrome_repack_percent("${target_name}_100_percent") { |
| 215 | percent = "100" |
| 216 | forward_variables_from(invoker, |
| 217 | [ |
| 218 | "copy_data_to_bundle", |
| 219 | "deps", |
| 220 | "output_dir", |
| 221 | "repack_whitelist", |
| 222 | "visibility", |
| 223 | ]) |
| 224 | } |
| 225 | |
| 226 | if (enable_hidpi) { |
| 227 | chrome_repack_percent("${target_name}_200_percent") { |
| 228 | percent = "200" |
| 229 | forward_variables_from(invoker, |
| 230 | [ |
| 231 | "copy_data_to_bundle", |
| 232 | "deps", |
| 233 | "output_dir", |
| 234 | "repack_whitelist", |
| 235 | "visibility", |
| 236 | ]) |
| 237 | } |
| 238 | } |
| 239 | |
| 240 | chrome_extra_paks("${target_name}_extra") { |
| 241 | forward_variables_from(invoker, |
| 242 | [ |
| 243 | "copy_data_to_bundle", |
| 244 | "deps", |
| 245 | "output_dir", |
| 246 | "repack_whitelist", |
| 247 | "visibility", |
| 248 | ]) |
| 249 | if (defined(invoker.additional_extra_paks)) { |
| 250 | additional_paks = invoker.additional_extra_paks |
| 251 | } |
| 252 | } |
| 253 | |
zpeng | 368afac8 | 2017-07-17 18:47:45 | [diff] [blame] | 254 | chrome_repack_locales("${target_name}_locales") { |
| 255 | forward_variables_from(invoker, |
| 256 | [ |
| 257 | "copy_data_to_bundle", |
| 258 | "deps", |
| 259 | "visibility", |
| 260 | ]) |
| 261 | if (defined(invoker.locale_whitelist)) { |
| 262 | repack_whitelist = invoker.locale_whitelist |
| 263 | } else if (defined(invoker.repack_whitelist)) { |
| 264 | repack_whitelist = invoker.repack_whitelist |
| 265 | } |
thestig | 6b471b0e | 2017-05-26 17:41:52 | [diff] [blame] | 266 | |
zpeng | 368afac8 | 2017-07-17 18:47:45 | [diff] [blame] | 267 | input_locales = locales |
| 268 | output_dir = "${invoker.output_dir}/locales" |
thestig | 6b471b0e | 2017-05-26 17:41:52 | [diff] [blame] | 269 | |
zpeng | 368afac8 | 2017-07-17 18:47:45 | [diff] [blame] | 270 | if (is_mac) { |
| 271 | output_locales = locales_as_mac_outputs |
| 272 | } else { |
| 273 | output_locales = locales |
agrieve | 5fce4ef | 2016-09-21 17:21:59 | [diff] [blame] | 274 | } |
| 275 | } |
| 276 | |
| 277 | group(target_name) { |
| 278 | forward_variables_from(invoker, [ "deps" ]) |
| 279 | public_deps = [ |
| 280 | ":${target_name}_100_percent", |
| 281 | ":${target_name}_extra", |
zpeng | 368afac8 | 2017-07-17 18:47:45 | [diff] [blame] | 282 | ":${target_name}_locales", |
agrieve | 5fce4ef | 2016-09-21 17:21:59 | [diff] [blame] | 283 | ] |
| 284 | if (enable_hidpi) { |
| 285 | public_deps += [ ":${target_name}_200_percent" ] |
| 286 | } |
| 287 | if (defined(invoker.public_deps)) { |
| 288 | public_deps += invoker.public_deps |
| 289 | } |
| 290 | } |
| 291 | } |