# Copyright 2021 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/tools/mwc_path_mappings.gni")
import("//build/config/chromeos/ui_mode.gni")
import("//tools/typescript/ts_library.gni")
import("//ui/webui/resources/tools/build_webui.gni")
import("//ui/webui/resources/tools/generate_grd.gni")
assert(is_chromeos_ash, "Sample System Web App is ash-chrome only")
assert(!is_official_build,
"Sample System Web App is only built for unofficial builds")
build_webui("build") {
grd_prefix = "ash_sample_system_web_app"
static_files = [
"app_icon_192.png",
"component_playground.html",
"index.html",
"inter_frame_communication.html",
"share.html",
"timer.html",
]
non_web_component_files = [
"component_playground.ts",
"inter_frame_communication.ts",
"main.ts",
"page_handler.ts",
"timer.ts",
]
mojo_files_deps = [ "../../mojom:mojo_bindings_ts__generator" ]
mojo_files = [
"$root_gen_dir/ash/webui/sample_system_web_app_ui/mojom/sample_system_web_app_shared_ui.mojom-webui.ts",
"$root_gen_dir/ash/webui/sample_system_web_app_ui/mojom/sample_system_web_app_ui.mojom-webui.ts",
]
ts_composite = true
ts_deps = [
"//third_party/cros-components:cros_components_ts",
"//third_party/material_web_components:bundle_lit_ts",
"//third_party/material_web_components:library",
"//ui/webui/resources/cr_components/color_change_listener:build_ts",
"//ui/webui/resources/mojo:build_ts",
]
ts_path_mappings = []
foreach(_mwc_mapping, mwc_path_mappings) {
ts_path_mappings +=
[ _mwc_mapping[0] + "|" + rebase_path(_mwc_mapping[1], target_gen_dir) ]
}
webui_context_type = "trusted"
grit_output_dir = "$root_gen_dir/ash/webui"
extra_grdp_deps = [ ":build_worker_grdp" ]
extra_grdp_files = [ "$target_gen_dir/worker_resources.grdp" ]
}
# Not so common setup for Ash WebUIs that need to use a Webworker.
# 1) Use a dedicated ts_library() for the worker files, as it requires
# configuration that is not compatible with non-worker files. See
# https://github.com/microsoft/TypeScript/issues/20595
# 2) Use a dedicated generate_grd() target generating a grdp file listing the
# worker files which is hooked up to the main grd file via build_webui()'s
# `extra_grdp_files`.
ts_library("build_worker_ts") {
tsconfig_base = "tsconfig_worker.json"
root_dir = "."
out_dir = "$target_gen_dir/tsc"
in_files = [ "worker.ts" ]
}
generate_grd("build_worker_grdp") {
grd_prefix = "ash_sample_system_web_app"
out_grd = "$target_gen_dir/worker_resources.grdp"
manifest_files = filter_include(get_target_outputs(":build_worker_ts"),
[ "*_manifest.json" ])
deps = [ ":build_worker_ts" ]
}