Commit ef836d86 authored by michaelbai's avatar michaelbai Committed by Commit bot

GN WebView: add resources

BUG=532905

Review URL: https://codereview.chromium.org/1425143004

Cr-Commit-Position: refs/heads/master@{#357049}
parent 05fe05b3
...@@ -4,8 +4,17 @@ ...@@ -4,8 +4,17 @@
import("//build/config/android/config.gni") import("//build/config/android/config.gni")
import("//build/config/android/rules.gni") import("//build/config/android/rules.gni")
import("//build/config/locales.gni")
import("//build_overrides/v8.gni") import("//build_overrides/v8.gni")
import("//third_party/icu/config.gni")
import("//tools/grit/repack.gni") import("//tools/grit/repack.gni")
import("webview_repack_locales.gni")
if (current_cpu == "arm" || current_cpu == "x86" || current_cpu == "mipsel") {
arch_suffix = 32
} else {
arch_suffix = 64
}
# This is dummy target for adding WebView gn piece by piece, so we don't need # This is dummy target for adding WebView gn piece by piece, so we don't need
# to modify the src/BUILD.gn everytime new targets added. # to modify the src/BUILD.gn everytime new targets added.
...@@ -13,6 +22,154 @@ group("system_webview_apk") { ...@@ -13,6 +22,154 @@ group("system_webview_apk") {
deps = [ deps = [
":android_webview_java", ":android_webview_java",
":common", ":common",
":assets",
]
}
webview_repack_locales("repack_locales") {
input_locales = locales
output_locales = locales
}
locale_pak_resources("locale_paks") {
sources = [
"$root_out_dir/android_webview/locales/am.pak",
"$root_out_dir/android_webview/locales/ar.pak",
"$root_out_dir/android_webview/locales/bg.pak",
"$root_out_dir/android_webview/locales/bn.pak",
"$root_out_dir/android_webview/locales/ca.pak",
"$root_out_dir/android_webview/locales/cs.pak",
"$root_out_dir/android_webview/locales/da.pak",
"$root_out_dir/android_webview/locales/de.pak",
"$root_out_dir/android_webview/locales/el.pak",
"$root_out_dir/android_webview/locales/en-GB.pak",
"$root_out_dir/android_webview/locales/en-US.pak",
"$root_out_dir/android_webview/locales/es-419.pak",
"$root_out_dir/android_webview/locales/es.pak",
"$root_out_dir/android_webview/locales/et.pak",
"$root_out_dir/android_webview/locales/fa.pak",
"$root_out_dir/android_webview/locales/fi.pak",
"$root_out_dir/android_webview/locales/fil.pak",
"$root_out_dir/android_webview/locales/fr.pak",
"$root_out_dir/android_webview/locales/gu.pak",
"$root_out_dir/android_webview/locales/he.pak",
"$root_out_dir/android_webview/locales/hi.pak",
"$root_out_dir/android_webview/locales/hr.pak",
"$root_out_dir/android_webview/locales/hu.pak",
"$root_out_dir/android_webview/locales/id.pak",
"$root_out_dir/android_webview/locales/it.pak",
"$root_out_dir/android_webview/locales/ja.pak",
"$root_out_dir/android_webview/locales/kn.pak",
"$root_out_dir/android_webview/locales/ko.pak",
"$root_out_dir/android_webview/locales/lt.pak",
"$root_out_dir/android_webview/locales/lv.pak",
"$root_out_dir/android_webview/locales/ml.pak",
"$root_out_dir/android_webview/locales/mr.pak",
"$root_out_dir/android_webview/locales/ms.pak",
"$root_out_dir/android_webview/locales/nb.pak",
"$root_out_dir/android_webview/locales/nl.pak",
"$root_out_dir/android_webview/locales/pl.pak",
"$root_out_dir/android_webview/locales/pt-BR.pak",
"$root_out_dir/android_webview/locales/pt-PT.pak",
"$root_out_dir/android_webview/locales/ro.pak",
"$root_out_dir/android_webview/locales/ru.pak",
"$root_out_dir/android_webview/locales/sk.pak",
"$root_out_dir/android_webview/locales/sl.pak",
"$root_out_dir/android_webview/locales/sr.pak",
"$root_out_dir/android_webview/locales/sv.pak",
"$root_out_dir/android_webview/locales/sw.pak",
"$root_out_dir/android_webview/locales/ta.pak",
"$root_out_dir/android_webview/locales/te.pak",
"$root_out_dir/android_webview/locales/th.pak",
"$root_out_dir/android_webview/locales/tr.pak",
"$root_out_dir/android_webview/locales/uk.pak",
"$root_out_dir/android_webview/locales/vi.pak",
"$root_out_dir/android_webview/locales/zh-CN.pak",
"$root_out_dir/android_webview/locales/zh-TW.pak",
]
deps = [
":repack_locales",
]
}
repack("repack_pack") {
sources = [
"$root_gen_dir/blink/public/resources/blink_image_resources_100_percent.pak",
"$root_gen_dir/blink/public/resources/blink_resources.pak",
"$root_gen_dir/content/app/resources/content_resources_100_percent.pak",
"$root_gen_dir/content/content_resources.pak",
"$root_gen_dir/net/net_resources.pak",
"$root_gen_dir/ui/resources/ui_resources_100_percent.pak",
"$target_gen_dir/aw_resources.pak",
]
deps = [
":generate_aw_resources",
"//third_party/WebKit/public:image_resources",
"//third_party/WebKit/public:resources",
"//content/app/resources",
"//content:resources",
"//net:net_resources",
"//ui/resources",
]
output = "$target_gen_dir/webviewchromium.pak"
}
copy("rename_natives_blob") {
sources = [
"$root_out_dir/natives_blob.bin",
]
outputs = [
"$target_gen_dir/natives_blob_$arch_suffix.bin",
]
deps = [
"//v8",
]
}
copy("rename_snapshot_blob") {
sources = [
"$root_out_dir/snapshot_blob.bin",
]
outputs = [
"$target_gen_dir/snapshot_blob_$arch_suffix.bin",
]
deps = [
"//v8",
]
}
android_webview_assets_dir = "$root_build_dir/android_webview_assets"
copy_ex("assets") {
clear_dir = true
dest = android_webview_assets_dir
sources = [
"$target_gen_dir/webviewchromium.pak",
]
deps = [
":repack_pack",
]
if (icu_use_data_file) {
sources += [ "$root_build_dir/icudtl.dat" ]
deps += [ "//third_party/icu:icudata" ]
}
if (v8_use_external_startup_data) {
sources += [
"$target_gen_dir/natives_blob_$arch_suffix.bin",
"$target_gen_dir/snapshot_blob_$arch_suffix.bin",
]
deps += [
":rename_natives_blob",
":rename_snapshot_blob",
]
}
}
android_resources("resources") {
resource_dirs = [ "java/res" ]
custom_package = "org.chromium.android_webview"
deps = [
":locale_paks",
":strings_grd", ":strings_grd",
] ]
} }
...@@ -362,6 +519,7 @@ source_set("common") { ...@@ -362,6 +519,7 @@ source_set("common") {
android_library("android_webview_java") { android_library("android_webview_java") {
deps = [ deps = [
":resources",
":strings_grd", ":strings_grd",
"//base:base_java", "//base:base_java",
"//components/external_video_surface:java", "//components/external_video_surface:java",
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
}, },
'includes': [ '../build/grit_action.gypi' ], 'includes': [ '../build/grit_action.gypi' ],
}, },
# GN version: //android_webview:repack_pack
{ {
'action_name': 'repack_android_webview_pack', 'action_name': 'repack_android_webview_pack',
'variables': { 'variables': {
...@@ -72,6 +73,7 @@ ...@@ -72,6 +73,7 @@
}, },
'includes': [ '../build/grit_action.gypi' ], 'includes': [ '../build/grit_action.gypi' ],
}, },
# GN Version: //android_webview:repack_locales
{ {
'action_name': 'android_webview_repack_locales', 'action_name': 'android_webview_repack_locales',
'variables': { 'variables': {
...@@ -92,6 +94,7 @@ ...@@ -92,6 +94,7 @@
'<@(locales)', '<@(locales)',
], ],
}, },
# GN version: //android_webview/rename_snapshot_blob
{ {
'action_name': 'rename_snapshot_blob', 'action_name': 'rename_snapshot_blob',
'inputs': [ 'inputs': [
...@@ -107,6 +110,7 @@ ...@@ -107,6 +110,7 @@
'<@(_outputs)', '<@(_outputs)',
], ],
}, },
# GN version: //android_webview/rename_natives_blob
{ {
'action_name': 'rename_natives_blob', 'action_name': 'rename_natives_blob',
'inputs': [ 'inputs': [
...@@ -124,6 +128,7 @@ ...@@ -124,6 +128,7 @@
}, },
], ],
}, },
# GN version: //android_webview/locale_paks
{ {
'target_name': 'android_webview_locale_paks', 'target_name': 'android_webview_locale_paks',
'type': 'none', 'type': 'none',
......
# Copyright 2015 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.
#
# This is a copy of src/chrome/chrome_repack_locales.gni with the necessary
# modifications to meet WebView's requirement.
import("//build/config/chrome_build.gni")
import("//build/config/features.gni")
import("//build/config/ui.gni")
import("//tools/grit/repack.gni")
# Arguments:
#
# locale
# Internal name of locale. e.g. "pt-BR"
#
# output
# Output file name.
#
# visibility
# Normal meaning.
template("_repack_one_locale") {
locale = invoker.locale
repack(target_name) {
visibility = invoker.visibility
# Each input pak file should also have a deps line for completeness.
sources = [
"${root_gen_dir}/android_webview/aw_strings_${locale}.pak",
"${root_gen_dir}/android_webview/components_strings_${locale}.pak",
"${root_gen_dir}/content/app/strings/content_strings_${locale}.pak",
]
deps = [
"//android_webview:generate_aw_strings",
"//android_webview:generate_components_strings",
"//content/app/strings",
]
output = invoker.output
}
}
# Creates an action to call the repack_locales script.
#
# The GYP version generates the locales in the "gen" directory and then copies
# it to the root build directory. This isn't easy to express in a GN copy
# rule since the files on Mac have a complex structure. So we generate the
# files into the final place and skip the "gen" directory.
#
# This template uses GN's looping constructs to avoid the complex call to
# chrome/tools/build/repack_locales.py which wraps the repack commands in the
# GYP build.
#
# Arguments
#
# input_locales
# List of locale names to use as inputs.
#
# output_locales
# A list containing the corresponding output names for each of the
# input names.
#
# visibility
template("webview_repack_locales") {
# This is the name of the group below that will collect all the invidual
# locale targets. External targets will depend on this.
group_target_name = target_name
# GN's subscript is too stupid to do invoker.output_locales[foo] so we need
# to make a copy and do output_locales[foo].
output_locales = invoker.output_locales
# Collects all targets the loop generates.
locale_targets = []
# This loop iterates over the input locales and also keeps a counter so it
# can simultaneously iterate over the output locales (using GN's very
# limited looping capabilities).
current_index = 0
foreach(input_locale, invoker.input_locales) {
output_locale = output_locales[current_index]
# Compute the name of the target for the current file. Save it for the deps.
current_name = "${target_name}_${input_locale}"
locale_targets += [ ":$current_name" ]
_repack_one_locale(current_name) {
visibility = [ ":$group_target_name" ]
locale = input_locale
output = "${root_out_dir}/android_webview/locales/${output_locale}.pak"
}
current_index = current_index + 1
}
# The group that external targets depend on which collects all deps.
group(group_target_name) {
forward_variables_from(invoker, [ "visibility" ])
public_deps = locale_targets
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment