Skip to content

Commit

Permalink
Reland of Enable whitelisting for targets other than libchrome.
Browse files Browse the repository at this point in the history
Reverted in:
https://codereview.chromium.org/2348643002/

Reason for revert:
Fixed gn gen errror

This will allow monochrome to easily define its own set of the same
targets with a different resource whitelist

TBR=brettw@chromium.org,miu@chromium.org
BUG=641032

Review-Url: https://codereview.chromium.org/2344063002
Cr-Commit-Position: refs/heads/master@{#419074}
  • Loading branch information
agrieve authored and Commit bot committed Sep 16, 2016
1 parent 864df70 commit 26cf657
Show file tree
Hide file tree
Showing 3 changed files with 256 additions and 217 deletions.
242 changes: 33 additions & 209 deletions chrome/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,13 @@ import("//build/config/sanitizers/sanitizers.gni")
import("//build/config/ui.gni")
import("//build/config/win/console_app.gni")
import("//build/config/win/manifest.gni")
import("//chrome/chrome_repack_locales.gni")
import("//chrome/chrome_paks.gni")
import("//chrome/common/features.gni")
import("//chrome/version.gni")
import("//third_party/widevine/cdm/widevine.gni")
import("//ui/base/ui_features.gni")
import("//v8/gni/v8.gni")

if (enable_resource_whitelist_generation) {
android_resource_whitelist = "$root_gen_dir/chrome/resource_whitelist.txt"
}

if (is_android) {
import("//build/config/android/rules.gni")
} else if (is_mac) {
Expand All @@ -36,6 +32,10 @@ if (is_android) {
import("//third_party/icu/config.gni")
}

if (enable_resource_whitelist_generation) {
chrome_resource_whitelist = "$target_gen_dir/chrome_resource_whitelist.txt"
}

if (is_win) {
action("reorder_imports") {
script = "//build/win/reorder-imports.py"
Expand Down Expand Up @@ -996,7 +996,7 @@ if (is_win) {
":chrome_framework_helpers",
":chrome_framework_plugins",
":chrome_framework_resources",
":repack_locales_pack",
":packed_resources",
":widevine_cdm_library",
"//build/config/sanitizers:deps",
"//chrome/app/nibs:chrome_xibs",
Expand Down Expand Up @@ -1339,100 +1339,42 @@ if (is_chrome_branded && !is_android) {
}
}

group("packed_resources") {
public_deps = [
":repack_chrome_100_percent",
":repack_locales_pack",
]

if (is_chrome_branded && !is_mac && !is_android) {
public_deps += [ ":default_apps" ]
}

if (enable_hidpi) {
public_deps += [ ":repack_chrome_200_percent" ]
chrome_paks("packed_resources") {
if (is_mac) {
output_dir = "$root_gen_dir/repack"
copy_data_to_bundle = true
} else {
output_dir = root_out_dir
}
}

repack("packed_extra_resources") {
visibility = [ "./*" ]
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/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: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 (is_android) {
sources += [ "$root_gen_dir/android_webview/aw_resources.pak" ]
deps += [ "//android_webview:generate_aw_resources" ]
} else { # Non-Android.
# New paks should be added here by default.
sources += [
"$root_gen_dir/blink/devtools_resources.pak",
"$root_gen_dir/chrome/component_extension_resources.pak",
"$root_gen_dir/chrome/options_resources.pak",
"$root_gen_dir/chrome/quota_internals_resources.pak",
"$root_gen_dir/chrome/settings_resources.pak",
"$root_gen_dir/chrome/sync_file_system_internals_resources.pak",
]
deps += [
"//chrome/browser/resources:component_extension_resources",
"//chrome/browser/resources:options_resources",
"//chrome/browser/resources:quota_internals_resources",
"//chrome/browser/resources:settings_resources",
"//chrome/browser/resources:sync_file_system_internals_resources",
"//content/browser/devtools:devtools_resources",
if (enable_resource_whitelist_generation) {
repack_whitelist = chrome_resource_whitelist
deps = [
"//chrome:resource_whitelist",
]
}
if (is_chromeos) {
sources += [ "$root_gen_dir/ui/file_manager/file_manager_resources.pak" ]
deps += [ "//ui/file_manager:resources" ]
}
if (enable_extensions) {
sources += [
"$root_gen_dir/extensions/extensions_renderer_resources.pak",
"$root_gen_dir/extensions/extensions_resources.pak",

if (is_chrome_branded && !is_mac && !is_android) {
public_deps = [
":default_apps",
]
deps += [ "//extensions:extensions_resources" ]
}
}

chrome_extra_paks("packed_extra_resources") {
if (is_mac) {
output = "$root_gen_dir/repack/resources.pak"
output_dir = "$root_gen_dir/repack"
copy_data_to_bundle = true
} else {
output = "$root_out_dir/resources.pak"
output_dir = root_out_dir
}

copy_data_to_bundle = is_mac
if (enable_resource_whitelist_generation) {
repack_whitelist = android_resource_whitelist
deps += [ ":resource_whitelist" ]
repack_whitelist = chrome_resource_whitelist
deps = [
":resource_whitelist",
]
}
}

Expand All @@ -1449,127 +1391,6 @@ repack("browser_tests_pak") {
]
}

# Collects per-locale grit files from many sources into global per-locale files.
chrome_repack_locales("repack_locales_pack") {
visibility = [ ":*" ]

input_locales = locales
copy_data_to_bundle = is_mac

if (is_mac) {
output_locales = locales_as_mac_outputs
} else {
output_locales = locales
}

if (enable_resource_whitelist_generation) {
repack_whitelist = android_resource_whitelist
deps = [
":resource_whitelist",
]
}
}

# 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.
#
# It's not clear why this two-step dance is necessary as opposed to just
# generating the file in the destination. However, this is what the GYP build
# does, and for maintenance purposes, this keeps the same files in the same
# place between the two builds when possible.
#
# Argument:
# percent [required]
# String to substitute for the percentage.
template("chrome_repack_percent") {
percent = invoker.percent

repack_name = "${target_name}_repack"
repack_output_file = "$root_gen_dir/repack/chrome_${percent}_percent.pak"

copy_name = target_name

repack(repack_name) {
visibility = [ ":$copy_name" ]

# 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 (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 = repack_output_file
copy_data_to_bundle = is_mac

if (enable_resource_whitelist_generation) {
repack_whitelist = android_resource_whitelist
deps += [ ":resource_whitelist" ]
}
}

copy(copy_name) {
visibility = [ ":*" ]
deps = [
":$repack_name",
]
sources = [
repack_output_file,
]
outputs = [
"$root_build_dir/chrome_${percent}_percent.pak",
]
}
}

chrome_repack_percent("repack_chrome_100_percent") {
percent = "100"
}

if (enable_hidpi) {
chrome_repack_percent("repack_chrome_200_percent") {
percent = "200"
}
}

# GYP version: chrome/chrome_resources.gyp:chrome_strings
group("strings") {
public_deps = [
Expand Down Expand Up @@ -1659,6 +1480,9 @@ if (is_android) {

if (enable_resource_whitelist_generation) {
action("resource_whitelist") {
assert(is_android,
"Resource whitelist currently implemented only on Android")

deps = [
"//chrome/android:chrome",
]
Expand All @@ -1669,7 +1493,7 @@ if (enable_resource_whitelist_generation) {
_infile,
]

_outfile = android_resource_whitelist
_outfile = chrome_resource_whitelist
outputs = [
_outfile,
]
Expand Down
Loading

0 comments on commit 26cf657

Please sign in to comment.