# Copyright 2020 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//ash/webui/help_app_ui/help_app_files.gni")
import("//ash/webui/web_applications/system_apps.gni")
import("//build/config/chromeos/ui_mode.gni")
import("//tools/typescript/ts_library.gni")
import("//tools/typescript/webui_ts_library.gni")
import("//ui/webui/resources/tools/optimize_webui.gni")
assert(is_chromeos_ash, "Help App is ash-chrome only")
stage_folder = "$target_gen_dir/stage_rollup"
ts_root_dir = "$target_gen_dir/stage_ts"
copy("copy_for_tsc") {
visibility = [ ":build_ts" ]
public_deps = [
"//ash/webui/help_app_ui:mojo_bindings_js__generator",
"//ash/webui/help_app_ui/search:mojo_bindings_js__generator",
"//ash/webui/system_apps/public/js:build_ts",
"//chromeos/ash/components/local_search_service/public/mojom:mojom_js__generator",
]
sources = [
"$root_gen_dir/ash/webui/system_apps/public/js/message_pipe.js",
"$root_gen_dir/mojom-webui/ash/webui/help_app_ui/help_app_ui.mojom-webui.js",
"$root_gen_dir/mojom-webui/ash/webui/help_app_ui/search/search.mojom-webui.js",
"$root_gen_dir/mojom-webui/chromeos/ash/components/local_search_service/public/mojom/index.mojom-webui.js",
"$root_gen_dir/mojom-webui/chromeos/ash/components/local_search_service/public/mojom/types.mojom-webui.js",
"//ui/webui/resources/js/mojo_type_util.ts",
"browser_proxy.ts",
"message_types.ts",
"receiver.ts",
]
outputs = [ "${ts_root_dir}/{{source_file_part}}" ]
}
webui_ts_library("build_ts") {
root_dir = ts_root_dir
in_files = []
foreach(o, get_target_outputs(":copy_for_tsc")) {
in_files += [ rebase_path(o, ts_root_dir) ]
}
composite = true
definitions = [ "//ash/webui/help_app_ui/resources/js/help_app.d.ts" ]
# The out_dir needs to be a different folder from the folder containing files
# generated by targets in this BUILD.gn, otherwise it may be treated as an
# artifact from a previous build which will cause ts_library to delete them.
out_dir = stage_folder
deps = [
"//ash/webui/common/resources:build_ts",
"//ash/webui/system_apps/public/js:build_ts",
"//ui/webui/resources/cr_components/color_change_listener:build_ts",
"//ui/webui/resources/mojo:build_ts",
]
extra_deps = [ ":copy_for_tsc" ]
path_mappings = [ "//system_apps/*|" + rebase_path(
"$root_gen_dir/ash/webui/system_apps/public/js/*",
target_gen_dir) ]
}
copy("stage_static") {
sources = [ "//ash/webui/system_apps/public/js/sandboxed_load_time_data.js" ]
outputs = [ stage_folder + "/{{source_file_part}}" ]
}
system_apps_dir =
rebase_path("$root_gen_dir/ash/webui/system_apps/public/js", root_build_dir)
# Generate a bundle of all the JS needed for chrome://help-app.
optimize_webui("browser_proxy_rollup") {
host = "help-app"
js_module_in_files = [ "browser_proxy.js" ]
# Exclude files that are served from chrome://resources anyway, since bundling
# them would unnecessarily increase the overall build size.
excludes = [
"chrome://resources/js/mojo_type_util.js",
"chrome://resources/mojo/mojo/public/mojom/base/string16.mojom-webui.js",
"chrome://resources/mojo/url/mojom/url.mojom-webui.js",
]
input = rebase_path(stage_folder, root_build_dir)
deps = [
":build_ts",
":stage_static",
]
external_paths = [ "//system_apps/|$system_apps_dir" ]
}
# Generate a bundle of all the JS needed for chrome-untrusted://help-app.
optimize_webui("receiver_rollup") {
host = "chrome-untrusted://help-app"
js_module_in_files = [ "receiver.js" ]
input = rebase_path(stage_folder, root_build_dir)
deps = [
":build_ts",
":stage_static",
]
external_paths = [ "//system_apps/|$system_apps_dir" ]
}
ts_library("test_build_ts") {
root_dir = ts_root_dir
testonly = true
in_files = help_app_test_ts
definitions = [
"//ash/webui/help_app_ui/resources/js/help_app.d.ts",
"//ash/webui/help_app_ui/test/test_api.d.ts",
]
deps = [
":build_ts",
"//chrome/test/data/webui:build_ts",
]
path_mappings = [ "//webui-test/*|" +
rebase_path("$root_gen_dir/chrome/test/data/webui/tsc/*",
target_gen_dir) ]
extra_deps = [ "//ash/webui/help_app_ui/test:stage_for_test_tsc" ]
}