WebUI: Make build_webui() available outside chrome/browser/resources/
Exposing a new grit_output_dir parameter in build_webui() that is forwarded to the underlying grit() target, to allow overriding the default value of $root_gen_dir/chrome. Deploying build_webui() to content/browser/resources/quota/ (chrome://quota-internals) as a proof that it can be successfully used outside of the chrome/browser/resources folder. Bug: 1340376 Change-Id: I734ef01f1adecb645e79dd2d427cfce49763d864 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3880652 Reviewed-by: Rebekah Potter <rbpotter@chromium.org> Commit-Queue: Demetrios Papadopoulos <dpapad@chromium.org> Cr-Commit-Position: refs/heads/main@{#1044975}
This commit is contained in:
chrome/browser/resources/tools
content/browser/resources/quota
docs
@ -293,6 +293,12 @@ template("build_webui") {
|
||||
"grit/${grd_prefix}_resources_map.h",
|
||||
"${grd_prefix}_resources.pak",
|
||||
]
|
||||
output_dir = "$root_gen_dir/chrome"
|
||||
|
||||
grit_output_dir = "$root_gen_dir/chrome"
|
||||
if (defined(invoker.grit_output_dir)) {
|
||||
grit_output_dir = invoker.grit_output_dir
|
||||
}
|
||||
|
||||
output_dir = grit_output_dir
|
||||
}
|
||||
}
|
||||
|
@ -2,72 +2,28 @@
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
import("//chrome/common/features.gni")
|
||||
import("//tools/grit/grit_rule.gni")
|
||||
import("//tools/typescript/ts_library.gni")
|
||||
import("//ui/webui/resources/tools/generate_grd.gni")
|
||||
import("//chrome/browser/resources/tools/build_webui.gni")
|
||||
|
||||
copy("copy_ts") {
|
||||
sources = [
|
||||
"quota_internals.ts",
|
||||
"quota_internals_browser_proxy.ts",
|
||||
]
|
||||
outputs = [ "$target_gen_dir/{{source_file_part}}" ]
|
||||
}
|
||||
|
||||
copy("copy_mojo") {
|
||||
deps = [ "//storage/browser/quota:mojo_bindings_webui_js" ]
|
||||
mojom_folder = "$root_gen_dir/mojom-webui/storage/browser/quota/"
|
||||
sources = [ "$mojom_folder/quota_internals.mojom-webui.js" ]
|
||||
outputs = [ "$target_gen_dir/{{source_file_part}}" ]
|
||||
}
|
||||
|
||||
grit("resources") {
|
||||
defines = chrome_grit_defines
|
||||
|
||||
# These arguments are needed since the grd is generated at build time.
|
||||
enable_input_discovery_for_gn_analyze = false
|
||||
source = "$target_gen_dir/resources.grd"
|
||||
deps = [ ":build_grd" ]
|
||||
|
||||
outputs = [
|
||||
"grit/quota_internals_resources.h",
|
||||
"grit/quota_internals_resources_map.cc",
|
||||
"grit/quota_internals_resources_map.h",
|
||||
"quota_internals_resources.pak",
|
||||
]
|
||||
output_dir = "$root_gen_dir/content"
|
||||
}
|
||||
|
||||
ts_library("build_ts") {
|
||||
root_dir = target_gen_dir
|
||||
out_dir = "$target_gen_dir/tsc"
|
||||
tsconfig_base = "tsconfig_base.json"
|
||||
in_files = [
|
||||
"quota_internals.ts",
|
||||
"quota_internals_browser_proxy.ts",
|
||||
"quota_internals.mojom-webui.js",
|
||||
]
|
||||
deps = [
|
||||
"//ui/webui/resources:library",
|
||||
"//ui/webui/resources/mojo:library",
|
||||
]
|
||||
extra_deps = [
|
||||
":copy_mojo",
|
||||
":copy_ts",
|
||||
]
|
||||
}
|
||||
|
||||
generate_grd("build_grd") {
|
||||
build_webui("build") {
|
||||
grd_prefix = "quota_internals"
|
||||
out_grd = "$target_gen_dir/resources.grd"
|
||||
input_files = [
|
||||
|
||||
static_files = [
|
||||
"quota_internals.html",
|
||||
"quota_internals.css",
|
||||
]
|
||||
input_files_base_dir = rebase_path(".", "//")
|
||||
|
||||
deps = [ ":build_ts" ]
|
||||
manifest_files =
|
||||
filter_include(get_target_outputs(":build_ts"), [ "*.manifest" ])
|
||||
non_web_component_files = [
|
||||
"quota_internals.ts",
|
||||
"quota_internals_browser_proxy.ts",
|
||||
]
|
||||
|
||||
mojo_files_deps = [ "//storage/browser/quota:mojo_bindings_webui_js" ]
|
||||
mojo_files = [ "$root_gen_dir/mojom-webui/storage/browser/quota/quota_internals.mojom-webui.js" ]
|
||||
|
||||
ts_deps = [
|
||||
"//ui/webui/resources:library",
|
||||
"//ui/webui/resources/mojo:library",
|
||||
]
|
||||
|
||||
grit_output_dir = "$root_gen_dir/content"
|
||||
}
|
||||
|
@ -471,6 +471,8 @@ extra_grdp_deps: List of external generate_grd() targets that generate .grdp
|
||||
resources.grd file. Optional parameter.
|
||||
extra_grdp_files: Output .grdp files of external generate_grd() targets. Must be
|
||||
defined if |extra_grdp_deps| is defined.
|
||||
grit_output_dir: See |output_dir| in grit(). Optional parameter, defaults to
|
||||
"$root_gen_dir/chrome"
|
||||
```
|
||||
|
||||
#### **Example**
|
||||
|
Reference in New Issue
Block a user