build: [gn] simplify resource pak build
This commit is contained in:
parent
ea16445be7
commit
76a62b44dc
4 changed files with 202 additions and 40 deletions
45
BUILD.gn
45
BUILD.gn
|
@ -5,6 +5,7 @@ import("build/asar.gni")
|
||||||
import("build/npm.gni")
|
import("build/npm.gni")
|
||||||
import("//pdf/features.gni")
|
import("//pdf/features.gni")
|
||||||
import("//build/config/win/manifest.gni")
|
import("//build/config/win/manifest.gni")
|
||||||
|
import("electron_paks.gni")
|
||||||
|
|
||||||
if (is_mac) {
|
if (is_mac) {
|
||||||
import("//build/config/mac/rules.gni")
|
import("//build/config/mac/rules.gni")
|
||||||
|
@ -360,6 +361,15 @@ static_library("electron_lib") {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
electron_paks("packed_resources") {
|
||||||
|
if (is_mac) {
|
||||||
|
output_dir = "$root_gen_dir/electron_repack"
|
||||||
|
copy_data_to_bundle = true
|
||||||
|
} else {
|
||||||
|
output_dir = root_out_dir
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (is_mac) {
|
if (is_mac) {
|
||||||
electron_framework_name = electron_product_name + " Framework"
|
electron_framework_name = electron_product_name + " Framework"
|
||||||
electron_helper_name = electron_product_name + " Helper"
|
electron_helper_name = electron_product_name + " Helper"
|
||||||
|
@ -373,12 +383,9 @@ if (is_mac) {
|
||||||
|
|
||||||
bundle_data("electron_framework_resources") {
|
bundle_data("electron_framework_resources") {
|
||||||
public_deps = [
|
public_deps = [
|
||||||
"//content/shell:pak",
|
":packed_resources",
|
||||||
":electron_locales",
|
|
||||||
]
|
|
||||||
sources = [
|
|
||||||
"$root_out_dir/content_shell.pak",
|
|
||||||
]
|
]
|
||||||
|
sources = []
|
||||||
if (icu_use_data_file) {
|
if (icu_use_data_file) {
|
||||||
sources += [ "$root_out_dir/icudtl.dat" ]
|
sources += [ "$root_out_dir/icudtl.dat" ]
|
||||||
public_deps += [ "//third_party/icu:icudata" ]
|
public_deps += [ "//third_party/icu:icudata" ]
|
||||||
|
@ -541,30 +548,6 @@ if (is_mac) {
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
repack_locales("electron_locales") {
|
|
||||||
source_patterns = [
|
|
||||||
"${root_gen_dir}/content/app/strings/content_strings_",
|
|
||||||
]
|
|
||||||
deps = [
|
|
||||||
"//content/app/strings",
|
|
||||||
]
|
|
||||||
|
|
||||||
input_locales = locales
|
|
||||||
|
|
||||||
if (is_mac) {
|
|
||||||
output_locales = locales_as_mac_outputs
|
|
||||||
} else {
|
|
||||||
output_locales = locales
|
|
||||||
}
|
|
||||||
|
|
||||||
if (is_mac) {
|
|
||||||
output_dir = "$root_gen_dir/repack"
|
|
||||||
copy_data_to_bundle = true
|
|
||||||
} else {
|
|
||||||
output_dir = root_out_dir
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
mac_app_bundle("electron_app") {
|
mac_app_bundle("electron_app") {
|
||||||
output_name = electron_product_name
|
output_name = electron_product_name
|
||||||
sources = filenames_gypi.app_sources
|
sources = filenames_gypi.app_sources
|
||||||
|
@ -604,10 +587,6 @@ if (is_mac) {
|
||||||
":electron_lib",
|
":electron_lib",
|
||||||
":js2asar",
|
":js2asar",
|
||||||
"//build/config:exe_and_shlib_deps",
|
"//build/config:exe_and_shlib_deps",
|
||||||
"//chrome:packed_resources",
|
|
||||||
"//content/shell:copy_shell_resources",
|
|
||||||
"//content/shell:pak",
|
|
||||||
"//third_party/WebKit/public:image_resources",
|
|
||||||
"//ui/strings",
|
"//ui/strings",
|
||||||
"//content:sandbox_helper_win",
|
"//content:sandbox_helper_win",
|
||||||
]
|
]
|
||||||
|
|
|
@ -25,6 +25,7 @@ static_library("brightray") {
|
||||||
|
|
||||||
defines = [
|
defines = [
|
||||||
"DISABLE_NACL=1",
|
"DISABLE_NACL=1",
|
||||||
|
"ELECTRON_GN_BUILD",
|
||||||
]
|
]
|
||||||
|
|
||||||
if (is_linux) {
|
if (is_linux) {
|
||||||
|
|
|
@ -48,19 +48,28 @@ void LoadResourceBundle(const std::string& locale) {
|
||||||
if (initialized)
|
if (initialized)
|
||||||
ui::ResourceBundle::CleanupSharedInstance();
|
ui::ResourceBundle::CleanupSharedInstance();
|
||||||
|
|
||||||
ui::ResourceBundle::InitSharedInstanceWithLocale(
|
|
||||||
locale, nullptr, ui::ResourceBundle::DO_NOT_LOAD_COMMON_RESOURCES);
|
|
||||||
|
|
||||||
ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
|
|
||||||
bundle.ReloadLocaleResources(locale);
|
|
||||||
|
|
||||||
// Load other resource files.
|
// Load other resource files.
|
||||||
base::FilePath pak_dir;
|
base::FilePath pak_dir;
|
||||||
#if defined(OS_MACOSX)
|
#if defined(OS_MACOSX)
|
||||||
pak_dir = base::mac::FrameworkBundlePath().Append("Resources");
|
pak_dir =
|
||||||
|
base::mac::FrameworkBundlePath().Append(FILE_PATH_LITERAL("Resources"));
|
||||||
#else
|
#else
|
||||||
PathService::Get(base::DIR_MODULE, &pak_dir);
|
PathService::Get(base::DIR_MODULE, &pak_dir);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(ELECTRON_GN_BUILD)
|
||||||
|
ui::ResourceBundle::InitSharedInstanceWithLocale(
|
||||||
|
locale, nullptr, ui::ResourceBundle::LOAD_COMMON_RESOURCES);
|
||||||
|
ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
|
||||||
|
bundle.ReloadLocaleResources(locale);
|
||||||
|
bundle.AddDataPackFromPath(pak_dir.Append(FILE_PATH_LITERAL("resources.pak")),
|
||||||
|
ui::SCALE_FACTOR_NONE);
|
||||||
|
#else
|
||||||
|
ui::ResourceBundle::InitSharedInstanceWithLocale(
|
||||||
|
locale, nullptr, ui::ResourceBundle::DO_NOT_LOAD_COMMON_RESOURCES);
|
||||||
|
ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
|
||||||
|
bundle.ReloadLocaleResources(locale);
|
||||||
|
|
||||||
bundle.AddDataPackFromPath(
|
bundle.AddDataPackFromPath(
|
||||||
pak_dir.Append(FILE_PATH_LITERAL("content_shell.pak")),
|
pak_dir.Append(FILE_PATH_LITERAL("content_shell.pak")),
|
||||||
ui::GetSupportedScaleFactors()[0]);
|
ui::GetSupportedScaleFactors()[0]);
|
||||||
|
@ -81,6 +90,7 @@ void LoadResourceBundle(const std::string& locale) {
|
||||||
bundle.AddDataPackFromPath(
|
bundle.AddDataPackFromPath(
|
||||||
pak_dir.Append(FILE_PATH_LITERAL("views_resources_200_percent.pak")),
|
pak_dir.Append(FILE_PATH_LITERAL("views_resources_200_percent.pak")),
|
||||||
ui::SCALE_FACTOR_200P);
|
ui::SCALE_FACTOR_200P);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
MainDelegate::MainDelegate() {}
|
MainDelegate::MainDelegate() {}
|
||||||
|
|
172
electron_paks.gni
Normal file
172
electron_paks.gni
Normal file
|
@ -0,0 +1,172 @@
|
||||||
|
import("//build/config/locales.gni")
|
||||||
|
import("//printing/features/features.gni")
|
||||||
|
import("//tools/grit/repack.gni")
|
||||||
|
import("//ui/base/ui_features.gni")
|
||||||
|
|
||||||
|
# See: //chrome/chrome_paks.gni
|
||||||
|
template("electron_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_scaled_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 = [
|
||||||
|
"//components/resources",
|
||||||
|
"//content/app/resources",
|
||||||
|
"//third_party/WebKit/public:scaled_resources_${percent}_percent",
|
||||||
|
"//ui/resources",
|
||||||
|
]
|
||||||
|
|
||||||
|
if (defined(invoker.deps)) {
|
||||||
|
deps += invoker.deps
|
||||||
|
}
|
||||||
|
|
||||||
|
if (toolkit_views) {
|
||||||
|
sources += [ "$root_gen_dir/ui/views/resources/views_resources_${percent}_percent.pak" ]
|
||||||
|
deps += [ "//ui/views/resources" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
output = "${invoker.output_dir}/chrome_${percent}_percent.pak"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template("electron_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/components/components_resources.pak",
|
||||||
|
"$root_gen_dir/content/browser/tracing/tracing_resources.pak",
|
||||||
|
"$root_gen_dir/content/content_resources.pak",
|
||||||
|
"$root_gen_dir/mojo/public/js/mojo_bindings_resources.pak",
|
||||||
|
"$root_gen_dir/net/net_resources.pak",
|
||||||
|
]
|
||||||
|
deps = [
|
||||||
|
"//components/resources",
|
||||||
|
"//content:resources",
|
||||||
|
"//content/browser/tracing:resources",
|
||||||
|
"//mojo/public/js:resources",
|
||||||
|
"//net:net_resources",
|
||||||
|
"//third_party/WebKit/public:resources",
|
||||||
|
]
|
||||||
|
if (defined(invoker.deps)) {
|
||||||
|
deps += invoker.deps
|
||||||
|
}
|
||||||
|
if (defined(invoker.additional_paks)) {
|
||||||
|
sources += invoker.additional_paks
|
||||||
|
}
|
||||||
|
|
||||||
|
# New paks should be added here by default.
|
||||||
|
sources +=
|
||||||
|
[ "$root_gen_dir/content/browser/devtools/devtools_resources.pak" ]
|
||||||
|
deps += [ "//content/browser/devtools:devtools_resources" ]
|
||||||
|
if (enable_print_preview) {
|
||||||
|
sources += [ "$root_gen_dir/chrome/print_preview_resources.pak" ]
|
||||||
|
deps += [ "//chrome/browser/resources:print_preview_resources" ]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template("electron_paks") {
|
||||||
|
electron_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) {
|
||||||
|
electron_repack_percent("${target_name}_200_percent") {
|
||||||
|
percent = "200"
|
||||||
|
forward_variables_from(invoker,
|
||||||
|
[
|
||||||
|
"copy_data_to_bundle",
|
||||||
|
"deps",
|
||||||
|
"output_dir",
|
||||||
|
"repack_whitelist",
|
||||||
|
"visibility",
|
||||||
|
])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
electron_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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
repack_locales("${target_name}_locales") {
|
||||||
|
forward_variables_from(invoker,
|
||||||
|
[
|
||||||
|
"copy_data_to_bundle",
|
||||||
|
"deps",
|
||||||
|
"visibility",
|
||||||
|
])
|
||||||
|
if (defined(invoker.locale_whitelist)) {
|
||||||
|
repack_whitelist = invoker.locale_whitelist
|
||||||
|
} else if (defined(invoker.repack_whitelist)) {
|
||||||
|
repack_whitelist = invoker.repack_whitelist
|
||||||
|
}
|
||||||
|
|
||||||
|
source_patterns = [ "${root_gen_dir}/content/app/strings/content_strings_" ]
|
||||||
|
deps = [
|
||||||
|
"//content/app/strings",
|
||||||
|
]
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue