# 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("//build/config/chrome_build.gni")
import("//build/config/chromeos/ui_mode.gni")
import("//third_party/closure_compiler/compile_js.gni")
import("//tools/grit/grit_rule.gni")
import("//tools/grit/preprocess_if_expr.gni")
import("//tools/polymer/css_to_wrapper.gni")
import("//tools/polymer/html_to_wrapper.gni")
import("//tools/typescript/ts_definitions.gni")
import("//tools/typescript/webui_ts_library.gni")
import("//ui/webui/resources/tools/generate_grd.gni")
assert(is_chromeos_ash)
preprocessed_dir = "$target_gen_dir/preprocessed"
preprocessed_manifest = "preprocessed_manifest.json"
web_component_files = [
"keyboard_diagram.js",
"keyboard_key.js",
"navigation_selector.js",
"navigation_view_panel.js",
"page_toolbar.js",
"multidevice_setup/button_bar.js",
"multidevice_setup/multidevice_setup.js",
"multidevice_setup/password_page.js",
"multidevice_setup/setup_succeeded_page.js",
"multidevice_setup/start_setup_page.js",
"multidevice_setup/ui_page.js",
"network/apn_list.js",
"network/apn_list_item.js",
"network/cr_policy_network_indicator_mojo.js",
"network/network_apnlist.js",
"network/network_choose_mobile.js",
"network/network_config_input.js",
"network/network_config.js",
"network/network_config_select.js",
"network/network_config_toggle.js",
"network/network_icon.js",
"network/network_ip_config.js",
"network/network_list_item.js",
"network/network_list.js",
"network/network_nameservers.js",
"network/network_password_input.js",
"network/network_property_list_mojo.js",
"network/network_proxy_exclusions.js",
"network/network_proxy_input.js",
"network/network_proxy.js",
"network/network_select.js",
"network/network_siminfo.js",
"network/sim_lock_dialogs.js",
"network/apn_detail_dialog.js",
"network/apn_selection_dialog.js",
"network/apn_selection_dialog_list_item.js",
"smb_shares/add_smb_share_dialog.js",
]
non_web_component_files = [
"assert.js",
"cr.js",
"cr.m.js",
"cr_deprecated.js",
"cr_container_shadow_behavior.js",
"cr_picture/png.js",
"cr_picture/webcam_utils.js",
"cr_policy_indicator_behavior.js",
"cr_scrollable_behavior.js",
"event_target.js",
"event_tracker.js",
"fake_method_resolver.js",
"fake_observables.js",
"focus_row_js.js",
"focus_row_behavior.js",
"focus_without_ink_js.js",
"i18n_behavior.js",
"load_time_data.m.js",
"keyboard_shortcut_list_js.js",
"list_property_update_behavior.js",
"multidevice_setup/fake_mojo_service.js",
"multidevice_setup/mojo_api.js",
"multidevice_setup/multidevice_setup_browser_proxy.js",
"multidevice_setup/multidevice_setup_delegate.js",
"multidevice_setup/ui_page_container_behavior.js",
"network/cellular_utils.js",
"network/cr_policy_network_behavior_mojo.js",
"network/mojo_interface_provider.js",
"network/network_config_element_behavior.js",
"network/network_listener_behavior.js",
"network/network_list_types.js",
"network/onc_mojo.js",
"parse_html_subset.js",
"promise_resolver.js",
"post_message_api/post_message_api_client.js",
"post_message_api/post_message_api_request_handler.js",
"post_message_api/post_message_api_server.js",
"smb_shares/smb_browser_proxy.js",
"util.js",
"web_ui_listener_behavior.js",
]
web_component_files_ts = [
"auth_setup/set_local_password_input.ts",
"bluetooth/bluetooth_base_page.ts",
"bluetooth/bluetooth_battery_icon_percentage.ts",
"bluetooth/bluetooth_device_battery_info.ts",
"bluetooth/bluetooth_icon.ts",
"bluetooth/bluetooth_pairing_confirm_code_page.ts",
"bluetooth/bluetooth_pairing_device_item.ts",
"bluetooth/bluetooth_pairing_device_selection_page.ts",
"bluetooth/bluetooth_pairing_enter_code_page.ts",
"bluetooth/bluetooth_pairing_request_code_page.ts",
"bluetooth/bluetooth_pairing_ui.ts",
"bluetooth/bluetooth_spinner_page.ts",
"quick_unlock/fingerprint_progress.ts",
"network_health/network_diagnostics.ts",
"network_health/network_health_container.ts",
"network_health/network_health_summary.ts",
"network_health/routine_group.ts",
"quick_unlock/pin_keyboard.ts",
"quick_unlock/setup_pin_keyboard.ts",
"shortcut_input_ui/shortcut_input_key.ts",
"shortcut_input_ui/shortcut_input.ts",
"traffic_counters/traffic_counters.ts",
]
non_web_component_files_ts = [
"accessibility/macro_names.ts",
"accessibility/facial_gestures.ts",
"bluetooth/bluetooth_metrics_utils.ts",
"bluetooth/bluetooth_types.ts",
"bluetooth/bluetooth_utils.ts",
"bluetooth/cros_bluetooth_config.ts",
"bluetooth/hid_preserving_bluetooth_state_controller.ts",
"connectivity/mojo_connectivity_provider.ts",
"hotspot/cros_hotspot_config.ts",
"hotspot/fake_hotspot_config.ts",
"metrics/structured_metrics_service.ts",
"network_health/mojo_interface_provider.ts",
"network_health/network_diagnostics_types.ts",
"quick_unlock/lock_screen_constants.ts",
"quick_unlock/utils.ts",
"shortcut_input_ui/fake_accelerator_fetcher.ts",
"shortcut_input_ui/fake_shortcut_input_provider.ts",
"shortcut_input_ui/shortcut_utils.ts",
"typescript_utils/strict_query.ts",
"traffic_counters/traffic_counters_adapter.ts",
]
mojo_files_ts = [
"bluetooth/hid_preserving_bluetooth_state_controller.mojom-webui.ts",
"metrics/structured_metrics_service.mojom-webui.ts",
"metrics/event.mojom-webui.ts",
"connectivity/passpoint.mojom-webui.ts",
"hotspot/cros_hotspot_config.mojom-webui.ts",
"shortcut_input_ui/accelerator_actions.mojom-webui.ts",
"shortcut_input_ui/accelerator_info.mojom-webui.ts",
"shortcut_input_ui/accelerator_keys.mojom-webui.ts",
"shortcut_input_ui/input_device_settings.mojom-webui.ts",
"shortcut_input_ui/accelerator_fetcher.mojom-webui.ts",
"shortcut_input_ui/shortcut_input_provider.mojom-webui.ts",
"shortcut_input_ui/extended_fkeys_modifier.mojom-webui.ts",
"shortcut_input_ui/modifier_key.mojom-webui.ts",
"shortcut_input_ui/meta_key.mojom-webui.ts",
"shortcut_input_ui/simulate_right_click_modifier.mojom-webui.ts",
"shortcut_input_ui/six_pack_shortcut_modifier.mojom-webui.ts",
]
# Files that are generated and can skip the preprocess_if_expr step.
generated_files_ts = [ "metrics/structured_events.ts" ]
icons_html_files = [
"keyboard_icons.html",
"multidevice_setup/icons.html",
"navigation_icons.html",
"auth_setup/auth_setup_icons.html",
"bluetooth/bluetooth_icons.html",
"network/network_icons.html",
"quick_unlock/fingerprint_progress_icons.html",
"quick_unlock/pin_keyboard_icons.html",
"shortcut_input_ui/icons.html",
]
# Files that are passed as input to html_to_wrapper().
html_files = []
foreach(f, web_component_files) {
html_files += [ string_replace(f, ".js", ".html") ]
}
foreach(f, web_component_files_ts) {
html_files += [ string_replace(f, ".ts", ".html") ]
}
# Files that are generated by html_to_wrapper().
html_wrapper_files = []
foreach(f, html_files + icons_html_files) {
html_wrapper_files += [ f + ".js" ]
}
if (is_chrome_branded) {
internal_icon_html_files = [ "internal/ash_internal_icons.html" ]
foreach(f, internal_icon_html_files) {
html_wrapper_files += [ f + ".js" ]
}
}
css_files = [
"multidevice_setup/multidevice_setup_shared.css",
"navigation_shared_vars.css",
"network/network_shared.css",
]
# Files that are generated by css_to_wrapper().
css_wrapper_files = []
foreach(f, css_files) {
css_wrapper_files += [ f + ".js" ]
}
if (is_chrome_branded) {
copy("copy_internal_icons") {
sources = [ "//chromeos/ash/resources/internal/ash_internal_icons.html" ]
outputs = [ "$preprocessed_dir/internal/{{source_file_part}}" ]
}
}
preprocess_if_expr("preprocess") {
in_folder = "."
out_folder = preprocessed_dir
out_manifest = "$target_gen_dir/$preprocessed_manifest"
in_files = non_web_component_files + web_component_files + icons_html_files +
html_files + css_files
if (is_chrome_branded) {
deps = [ ":copy_internal_icons" ]
}
}
html_to_wrapper("html_wrapper_files") {
deps = [ ":preprocess" ]
in_folder = preprocessed_dir
out_folder = preprocessed_dir
in_files = html_files + icons_html_files
use_js = true
if (is_chrome_branded) {
in_files += internal_icon_html_files
deps += [ ":copy_internal_icons" ]
}
}
css_to_wrapper("css_wrapper_files") {
deps = [ ":preprocess" ]
in_folder = preprocessed_dir
out_folder = preprocessed_dir
in_files = css_files
use_js = true
}
preprocess_if_expr("preprocess_ts") {
in_folder = "."
in_files = non_web_component_files_ts + web_component_files_ts
out_folder = preprocessed_dir
}
webui_ts_library("build_ts") {
tsconfig_base = "//tools/typescript/tsconfig_base_polymer.json"
root_dir = preprocessed_dir
out_dir = preprocessed_dir
in_files = non_web_component_files_ts + web_component_files_ts +
mojo_files_ts + generated_files_ts
composite = true
deps = [
"//ash/webui/common/resources/cr_elements:build_ts",
"//third_party/cros-components:cros_components_ts",
"//third_party/material_web_components:bundle_lit_ts",
"//third_party/material_web_components:library",
"//third_party/polymer/v3_0:library",
"//ui/webui/resources/js:build_ts",
"//ui/webui/resources/mojo:build_ts",
]
definitions = [
"//tools/typescript/definitions/chrome_event.d.ts",
"//tools/typescript/definitions/chrome_send.d.ts",
"//tools/typescript/definitions/metrics_private.d.ts",
"//tools/typescript/definitions/quick_unlock_private.d.ts",
]
extra_deps = [
":generate_definitions",
":preprocess",
":preprocess_ts",
"bluetooth:copy_mojo_files",
"connectivity:copy_mojo_files",
"hotspot:copy_mojo_files",
"metrics:copy_files",
"shortcut_input_ui:copy_mojo_files",
"//ash/webui/common/resources:i18n_behavior",
"//ash/webui/common/resources/network:onc_mojo",
"//chromeos/services/network_config/public/mojom:mojom_webui_js",
"//chromeos/services/network_config/public/mojom:network_types_webui_js",
"//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
]
# TODO(b/314832310): Delete the path_mappings argument and change the imports
# to relative imports once ash/webui/common/resources/network migrated to TS.
path_mappings =
[ "chrome://resources/ash/common/network/*|" +
rebase_path(
"$root_gen_dir/ash/webui/common/resources/preprocessed/network/*",
target_gen_dir) ]
}
generate_grd("build_html_css_wrapper_files_grdp") {
input_files = html_wrapper_files + css_wrapper_files
input_files_base_dir = rebase_path(preprocessed_dir, root_build_dir)
public_deps = [
":css_wrapper_files",
":html_wrapper_files",
]
grd_prefix = "ash_common"
out_grd = "$target_gen_dir/html_css_wrapper_files_resources.grdp"
resource_path_prefix = "ash/common"
}
generate_grd("build_grd") {
input_files = [
"keyboard_layouts.js",
# Test runner used by file manager tests, webui_resource_browsertest.cc, and
# default_keyboard_extension_browser_test.cc
"webui_resource_test.js",
"hotspot/hotspot_dot.svg",
"hotspot/hotspot_inner.svg",
"hotspot/hotspot-off.svg",
"hotspot/hotspot.svg",
"multidevice_setup/multidevice_setup_animation.json",
"network/cellular_0.svg",
"network/cellular_0_with_x.svg",
"network/cellular_1.svg",
"network/cellular_2.svg",
"network/cellular_3.svg",
"network/cellular_4.svg",
"network/cellular_locked.svg",
"network/cellular_carrier_locked.svg",
"network/cellular_off.svg",
"network/cellular_unactivated.svg",
"network/ethernet.svg",
"network/roaming_badge.svg",
"network/vpn.svg",
"network/wifi_0.svg",
"network/wifi_0_with_x.svg",
"network/wifi_1.svg",
"network/wifi_2.svg",
"network/wifi_3.svg",
"network/wifi_4.svg",
"network/wifi_off.svg",
"network_health/test_canceled.png",
"network_health/test_failed.png",
"network_health/test_not_run.png",
"network_health/test_passed.png",
"network_health/test_warning.png",
"quick_unlock/fingerprint_enrollment.json",
"quick_unlock/fingerprint_check.json",
]
input_files_base_dir = rebase_path(".", "//")
deps = [
":build_html_css_wrapper_files_grdp",
":build_ts",
":preprocess",
"cellular_setup:build_grdp",
"cr_elements:build_grdp",
"personalization:build_grdp",
"sea_pen:build_grdp",
"//third_party/cros-components:cros_components_grdp",
"//third_party/material_web_components:build_lit_grdp",
"//third_party/material_web_components:build_mwc_grdp",
]
manifest_files =
filter_include(get_target_outputs(":build_ts"), [ "*_manifest.json" ]) +
filter_include(get_target_outputs(":preprocess"), [ "*_manifest.json" ])
grd_prefix = "ash_webui_common"
out_grd = "$target_gen_dir/resources.grd"
resource_path_prefix = "ash/common"
grdp_files = [
"$root_gen_dir/third_party/material_web_components/lit_resources.grdp",
"$root_gen_dir/third_party/material_web_components/mwc_resources.grdp",
"$target_gen_dir/html_css_wrapper_files_resources.grdp",
"$target_gen_dir/cellular_setup/resources.grdp",
"$target_gen_dir/cr_elements/resources.grdp",
"$target_gen_dir/personalization/resources.grdp",
"$target_gen_dir/sea_pen/resources.grdp",
"$root_gen_dir/third_party/cros-components/resources.grdp",
]
}
grit("resources") {
enable_input_discovery_for_gn_analyze = false
source = "$target_gen_dir/resources.grd"
deps = [ ":build_grd" ]
outputs = [
"grit/ash_webui_common_resources.h",
"grit/ash_webui_common_resources_map.cc",
"grit/ash_webui_common_resources_map.h",
"ash_webui_common_resources.pak",
]
output_dir = "$root_gen_dir/ash/webui"
}
generate_definitions_js_files = [
"assert.js",
"auth_setup/set_local_password_input.html.js",
"auth_setup/auth_setup_icons.html.js",
"bluetooth/bluetooth_pairing_confirm_code_page.html.js",
"bluetooth/bluetooth_pairing_enter_code_page.html.js",
"bluetooth/bluetooth_pairing_device_selection_page.html.js",
"bluetooth/bluetooth_pairing_request_code_page.html.js",
"bluetooth/bluetooth_pairing_device_item.html.js",
"bluetooth/bluetooth_pairing_ui.html.js",
"bluetooth/bluetooth_base_page.html.js",
"bluetooth/bluetooth_icon.html.js",
"bluetooth/bluetooth_icons.html.js",
"bluetooth/bluetooth_battery_icon_percentage.html.js",
"bluetooth/bluetooth_device_battery_info.html.js",
"bluetooth/bluetooth_spinner_page.html.js",
"cr_deprecated.js",
"cr_picture/png.js",
"cr_picture/webcam_utils.js",
"event_target.js",
"event_tracker.js",
"focus_row_js.js",
"focus_without_ink_js.js",
"keyboard_shortcut_list_js.js",
"multidevice_setup/multidevice_setup_shared.css.js",
"multidevice_setup/multidevice_setup_delegate.js",
"navigation_shared_vars.css.js",
"network/cellular_utils.js",
"network/cr_policy_network_behavior_mojo.js",
"network/mojo_interface_provider.js",
"network/network_config_element_behavior.js",
"network/network_listener_behavior.js",
"network/network_proxy_exclusions.html.js",
"network/network_proxy_exclusions.js",
"network/network_proxy_input.html.js",
"network/network_proxy_input.js",
"network/network_select.html.js",
"network/network_shared.css.js",
"network/onc_mojo.js",
"network_health/network_diagnostics.html.js",
"network_health/network_health_container.html.js",
"network_health/network_health_summary.html.js",
"network_health/routine_group.html.js",
"quick_unlock/fingerprint_progress.html.js",
"quick_unlock/fingerprint_progress_icons.html.js",
"quick_unlock/pin_keyboard.html.js",
"quick_unlock/pin_keyboard_icons.html.js",
"quick_unlock/setup_pin_keyboard.html.js",
"shortcut_input_ui/shortcut_input_key.html.js",
"shortcut_input_ui/icons.html.js",
"shortcut_input_ui/shortcut_input.html.js",
"traffic_counters/traffic_counters.html.js",
"util.js",
]
if (is_chrome_branded) {
generate_definitions_js_files += [ "internal/ash_internal_icons.html.js" ]
}
ts_definitions("generate_definitions") {
root_dir = preprocessed_dir
out_dir = preprocessed_dir
js_files = generate_definitions_js_files
deps = [
"//ash/webui/common/resources/cr_elements:build_ts",
"//ui/webui/resources/js:build_ts",
"//ui/webui/resources/mojo:build_ts",
]
extra_deps = [
":copy_checked_in_dts_files",
":css_wrapper_files",
":html_wrapper_files",
":preprocess",
]
}
checked_in_dts_files = [
"cr.m.d.ts",
"cr_container_shadow_behavior.d.ts",
"cr_scrollable_behavior.d.ts",
"cr_policy_indicator_behavior.d.ts",
"fake_method_resolver.d.ts",
"fake_observables.d.ts",
"focus_row_behavior.d.ts",
"i18n_behavior.d.ts",
"keyboard_diagram.d.ts",
"keyboard_key.d.ts",
"load_time_data.m.d.ts",
"list_property_update_behavior.d.ts",
"page_toolbar.d.ts",
"parse_html_subset.d.ts",
"promise_resolver.d.ts",
"navigation_view_panel.d.ts",
"navigation_selector.d.ts",
"web_ui_listener_behavior.d.ts",
"smb_shares/add_smb_share_dialog.d.ts",
"smb_shares/smb_browser_proxy.d.ts",
"multidevice_setup/mojo_api.d.ts",
"multidevice_setup/multidevice_setup.d.ts",
"network/apn_detail_dialog.d.ts",
"network/apn_selection_dialog.d.ts",
"network/apn_selection_dialog_list_item.d.ts",
"network/apn_list.d.ts",
"network/apn_list_item.d.ts",
"network/cr_policy_network_indicator_mojo.d.ts",
"network/network_apnlist.d.ts",
"network/network_choose_mobile.d.ts",
"network/network_config.d.ts",
"network/network_config_input.d.ts",
"network/network_config_select.d.ts",
"network/network_config_toggle.d.ts",
"network/network_icon.d.ts",
"network/network_ip_config.d.ts",
"network/network_list.d.ts",
"network/network_list_item.d.ts",
"network/network_list_types.d.ts",
"network/network_nameservers.d.ts",
"network/network_password_input.d.ts",
"network/network_property_list_mojo.d.ts",
"network/network_proxy.d.ts",
"network/network_select.d.ts",
"network/network_siminfo.d.ts",
"network/sim_lock_dialogs.d.ts",
"post_message_api/post_message_api_client.d.ts",
"post_message_api/post_message_api_request_handler.d.ts",
"post_message_api/post_message_api_server.d.ts",
]
copy("copy_checked_in_dts_files") {
sources = checked_in_dts_files
outputs = [ "$preprocessed_dir/{{source_target_relative}}" ]
}
group("closure_compile") {
deps = [
":closure_compile_local",
"cr_picture:closure_compile_module",
"multidevice_setup:closure_compile_module",
"network:closure_compile_module",
"post_message_api:closure_compile",
"smb_shares:closure_compile_module",
]
}
js_type_check("closure_compile_local") {
is_polymer3 = true
deps = [
":assert",
":cr.m",
":cr_deprecated",
":event_tracker",
":fake_method_resolver",
":fake_observables",
":focus_row_behavior",
":focus_row_js",
":focus_without_ink_js",
":keyboard_diagram",
":keyboard_key",
":keyboard_layouts",
":keyboard_shortcut_list_js",
":list_property_update_behavior",
":load_time_data.m",
":navigation_selector",
":navigation_view_panel",
":page_toolbar",
":parse_html_subset",
":promise_resolver",
":webui_resource_test",
]
}
js_library("assert") {
}
js_library("cr_deprecated") {
deps = [ ":assert" ]
}
js_library("cr.m") {
}
js_library("cr_container_shadow_behavior") {
deps = [ ":assert" ]
}
js_library("cr_policy_indicator_behavior") {
deps = [ ":assert" ]
}
js_library("cr_scrollable_behavior") {
deps = [
"//third_party/polymer/v3_0/components-chromium/iron-list:iron-list",
"//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
]
}
js_library("event_target") {
}
js_library("event_tracker") {
}
js_library("fake_observables") {
deps = [ ":cr.m" ]
}
js_library("fake_method_resolver") {
deps = [ ":cr.m" ]
}
js_library("focus_row_js") {
deps = [
":assert",
":event_tracker",
":util",
]
}
js_library("focus_row_behavior") {
deps = [
":assert",
":focus_row_js",
":focus_without_ink_js",
"//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
]
}
js_library("focus_without_ink_js") {
deps = [
":assert",
":cr.m",
]
}
js_library("i18n_behavior") {
deps = [
":load_time_data.m",
":parse_html_subset",
]
}
js_library("keyboard_diagram") {
deps = [
":keyboard_key",
":keyboard_layouts",
"//ash/webui/common/resources:i18n_behavior",
"//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
]
}
js_library("keyboard_key") {
deps = [
"//ash/webui/common/resources:i18n_behavior",
"//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
]
}
js_library("keyboard_layouts") {
sources = [ "keyboard_layouts.js" ]
}
js_library("keyboard_shortcut_list_js") {
}
js_library("list_property_update_behavior") {
deps = [
"//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
]
}
js_library("load_time_data.m") {
}
js_library("navigation_selector") {
deps = [
"//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
]
}
js_library("navigation_view_panel") {
deps = [
":navigation_selector",
"//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
]
}
js_library("page_toolbar") {
deps = [
"//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
]
}
js_library("parse_html_subset") {
}
js_library("promise_resolver") {
deps = [ ":assert" ]
}
js_library("web_ui_listener_behavior") {
deps = [ ":cr.m" ]
}
js_library("webui_resource_test") {
externs_list = [ "//ui/webui/resources/js/dom_automation_controller.js" ]
}
js_library("util") {
deps = [ ":assert" ]
}