blob: 4e303dca2d4a4c9282a16a607661cda076d5e5ea [file] [log] [blame]
# Copyright 2016 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/config/locales.gni")
import("//chrome/common/features.gni")
import("//extensions/features/features.gni")
import("//ui/base/ui_features.gni")
import("chrome_repack_locales.gni")
# Generates a rule to repack a set of resources, substituting a given string
# in for the percentage (e.g. "100", "200"). It generates the repacked files in
# the "gen" directory, and then introduces a copy rule to copy it to the root
# build directory.
#
# Argument:
# percent [required]
# String to substitute for the percentage.
template("chrome_repack_percent") {
percent = invoker.percent
repack(target_name) {
forward_variables_from(invoker,
[
"copy_data_to_bundle",
"repack_whitelist",
"visibility",
])
# All sources should also have deps for completeness.
sources = [
"$root_gen_dir/blink/public/resources/blink_image_resources_${percent}_percent.pak",
"$root_gen_dir/chrome/renderer_resources_${percent}_percent.pak",
"$root_gen_dir/chrome/theme_resources_${percent}_percent.pak",
"$root_gen_dir/components/components_resources_${percent}_percent.pak",
"$root_gen_dir/content/app/resources/content_resources_${percent}_percent.pak",
"$root_gen_dir/ui/resources/ui_resources_${percent}_percent.pak",
]
deps = [
"//chrome/app/theme:theme_resources",
"//chrome/renderer:resources",
"//components/resources",
"//components/strings",
"//content/app/resources",
"//net:net_resources",
"//third_party/WebKit/public:image_resources",
"//ui/resources",
]
if (defined(invoker.deps)) {
deps += invoker.deps
}
if (use_ash) {
sources +=
[ "$root_gen_dir/ash/resources/ash_resources_${percent}_percent.pak" ]
deps += [ "//ash/resources" ]
}
if (toolkit_views) {
sources += [ "$root_gen_dir/ui/views/resources/views_resources_${percent}_percent.pak" ]
deps += [ "//ui/views/resources" ]
}
if (is_chromeos) {
sources += [ "$root_gen_dir/ui/chromeos/resources/ui_chromeos_resources_${percent}_percent.pak" ]
deps += [ "//ui/chromeos/resources" ]
}
if (enable_extensions) {
sources += [ "$root_gen_dir/extensions/extensions_browser_resources_${percent}_percent.pak" ]
deps += [ "//extensions:extensions_browser_resources" ]
}
if (enable_app_list) {
sources += [ "$root_gen_dir/ui/app_list/resources/app_list_resources_${percent}_percent.pak" ]
deps += [ "//ui/app_list/resources" ]
}
output = "${invoker.output_dir}/chrome_${percent}_percent.pak"
}
}
template("chrome_extra_paks") {
repack(target_name) {
forward_variables_from(invoker,
[
"copy_data_to_bundle",
"repack_whitelist",
"visibility",
])
output = "${invoker.output_dir}/resources.pak"
sources = [
"$root_gen_dir/blink/public/resources/blink_resources.pak",
"$root_gen_dir/chrome/browser_resources.pak",
"$root_gen_dir/chrome/chrome_unscaled_resources.pak",
"$root_gen_dir/chrome/common_resources.pak",
"$root_gen_dir/chrome/invalidations_resources.pak",
"$root_gen_dir/chrome/net_internals_resources.pak",
"$root_gen_dir/chrome/password_manager_internals_resources.pak",
"$root_gen_dir/chrome/policy_resources.pak",
"$root_gen_dir/chrome/quota_internals_resources.pak",
"$root_gen_dir/chrome/task_scheduler_internals_resources.pak",
"$root_gen_dir/chrome/translate_internals_resources.pak",
"$root_gen_dir/components/components_resources.pak",
"$root_gen_dir/content/browser/tracing/tracing_resources.pak",
"$root_gen_dir/content/content_resources.pak",
"$root_gen_dir/net/net_resources.pak",
"$root_gen_dir/ui/resources/webui_resources.pak",
]
deps = [
"//chrome/app/theme:chrome_unscaled_resources",
"//chrome/browser:resources",
"//chrome/browser/resources:invalidations_resources",
"//chrome/browser/resources:net_internals_resources",
"//chrome/browser/resources:password_manager_internals_resources",
"//chrome/browser/resources:policy_resources",
"//chrome/browser/resources:quota_internals_resources",
"//chrome/browser/resources:task_scheduler_internals_resources",
"//chrome/browser/resources:translate_internals_resources",
"//chrome/common:resources",
"//components/resources",
"//content:resources",
"//content/browser/tracing:resources",
"//net:net_resources",
"//third_party/WebKit/public:resources",
"//ui/resources",
]
if (defined(invoker.deps)) {
deps += invoker.deps
}
if (defined(invoker.additional_paks)) {
sources += invoker.additional_paks
}
if (!is_android) {
# New paks should be added here by default.
sources += [
"$root_gen_dir/chrome/component_extension_resources.pak",
"$root_gen_dir/chrome/options_resources.pak",
"$root_gen_dir/chrome/settings_resources.pak",
"$root_gen_dir/chrome/sync_file_system_internals_resources.pak",
"$root_gen_dir/content/browser/devtools/devtools_resources.pak",
]
deps += [
"//chrome/browser/resources:component_extension_resources",
"//chrome/browser/resources:options_resources",
"//chrome/browser/resources:settings_resources",
"//chrome/browser/resources:sync_file_system_internals_resources",
"//content/browser/devtools:devtools_resources",
]
}
if (is_chromeos) {
sources += [
"$root_gen_dir/components/chrome_apps/chrome_apps_resources.pak",
"$root_gen_dir/ui/file_manager/file_manager_resources.pak",
]
deps += [
"//components/chrome_apps:resources",
"//ui/file_manager:resources",
]
}
if (is_linux || is_mac) {
sources += [ "$root_gen_dir/headless/headless_lib_resources.pak" ]
deps += [ "//headless:resources" ]
}
if (enable_extensions) {
sources += [
"$root_gen_dir/extensions/extensions_renderer_resources.pak",
"$root_gen_dir/extensions/extensions_resources.pak",
]
deps += [ "//extensions:extensions_resources" ]
}
if (is_android) {
sources += [ "$root_gen_dir/chrome/webapks_ui_resources.pak" ]
deps += [ "//chrome/browser/resources:webapks_ui_resources" ]
}
}
}
# Defines repack() targets used by Chrome. Specifically:
# * chrome_100_percent.pak
# * chrome_200_percent.pak (optionally)
# * resources.pak
# * locale .pak files
#
# Paramters:
# output_dir [required]: Directory to output .pak files. Locale .pak files
# will always be place in $output_dir/locales
# additional_extra_paks: List of extra .pak sources for resources.pak.
# additional_locale_source_patterns: additional_source_patterns for
# chrome_repack_locales().
# copy_data_to_bundle:
# deps:
# output_dir:
# public_deps:
# repack_whitelist:
# visibility:
# Normal meanings.
#
template("chrome_paks") {
chrome_repack_percent("${target_name}_100_percent") {
percent = "100"
forward_variables_from(invoker,
[
"copy_data_to_bundle",
"deps",
"output_dir",
"repack_whitelist",
"visibility",
])
}
if (enable_hidpi) {
chrome_repack_percent("${target_name}_200_percent") {
percent = "200"
forward_variables_from(invoker,
[
"copy_data_to_bundle",
"deps",
"output_dir",
"repack_whitelist",
"visibility",
])
}
}
chrome_extra_paks("${target_name}_extra") {
forward_variables_from(invoker,
[
"copy_data_to_bundle",
"deps",
"output_dir",
"repack_whitelist",
"visibility",
])
if (defined(invoker.additional_extra_paks)) {
additional_paks = invoker.additional_extra_paks
}
}
chrome_repack_locales("${target_name}_locales") {
forward_variables_from(invoker,
[
"copy_data_to_bundle",
"deps",
"repack_whitelist",
"visibility",
])
if (defined(invoker.additional_locale_source_patterns)) {
additional_source_patterns = invoker.additional_locale_source_patterns
}
input_locales = locales
output_dir = "${invoker.output_dir}/locales"
if (is_mac) {
output_locales = locales_as_mac_outputs
} else {
output_locales = locales
}
}
group(target_name) {
forward_variables_from(invoker, [ "deps" ])
public_deps = [
":${target_name}_100_percent",
":${target_name}_extra",
":${target_name}_locales",
]
if (enable_hidpi) {
public_deps += [ ":${target_name}_200_percent" ]
}
if (defined(invoker.public_deps)) {
public_deps += invoker.public_deps
}
}
}