blob: 0d832a0472e4603e449e5c1e9d77e2083510ff44 [file] [log] [blame]
# Copyright 2018 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.
import("//build/config/chromeos/ui_mode.gni")
import("//third_party/closure_compiler/compile_js.gni")
import("//tools/grit/preprocess_if_expr.gni")
import("//tools/polymer/css_to_wrapper.gni")
import("//tools/polymer/html_to_wrapper.gni")
import("//tools/polymer/polymer.gni")
import("//ui/webui/resources/include_polymer.gni")
import("//ui/webui/resources/tools/generate_grd.gni")
import("//ui/webui/resources/tools/js_modulizer.gni")
import("//ui/webui/webui_features.gni")
import("./cr_elements.gni")
preprocess_folder = "$root_gen_dir/ui/webui/resources/preprocessed/cr_elements"
if (include_polymer) {
preprocess_gen_manifest = "preprocessed_gen_manifest.json"
}
if (is_chromeos_ash) {
preprocess_polymer2_manifest = "preprocessed_polymer2_manifest.json"
}
if (include_polymer) {
generate_grd("build_grdp") {
grd_prefix = "cr_elements"
out_grd = "$target_gen_dir/${grd_prefix}_resources.grdp"
public_deps = [ ":preprocess" ]
manifest_files = [ "$target_gen_dir/$preprocess_gen_manifest" ]
if (is_chromeos_ash) {
manifest_files += [
# TODO(crbug.com/1184053): Fully remove once no longer used by CrOS.
"$target_gen_dir/$preprocess_polymer2_manifest",
]
}
resource_path_prefix = "cr_elements"
}
}
group("preprocess") {
public_deps = [
":html_wrapper_files_native",
":preprocess_ts",
]
if (include_polymer) {
public_deps += [
":css_wrapper_files",
":html_wrapper_files",
":preprocess_generated",
]
}
if (is_chromeos_ash) {
public_deps += [
# TODO(crbug.com/1184053): Fully remove once no longer used by CrOS.
":preprocess_polymer2",
]
}
}
# TS files are passed to a separate target so that they are not listed in the
# |out_manifest|.
preprocess_if_expr("preprocess_ts") {
in_folder = "."
out_folder = preprocess_folder
in_files = web_component_files_native_ts + native_html_files +
non_web_component_files_ts
if (include_polymer) {
in_files += web_component_files_polymer_ts + polymer_html_files +
icons_html_files + css_files
}
}
if (is_chromeos_ash) {
preprocess_if_expr("preprocess_polymer2") {
in_folder = "./"
out_folder = "$preprocess_folder"
out_manifest = "$target_gen_dir/$preprocess_polymer2_manifest"
in_files = [
"action_link_css.html",
"chromeos/cros_color_overrides.html",
"cr_actionable_row_style.html",
"cr_button/cr_button.html",
"cr_button/cr_button.js",
"cr_checkbox/cr_checkbox.html",
"cr_checkbox/cr_checkbox.js",
"cr_container_shadow_behavior.html",
"cr_container_shadow_behavior.js",
"cr_dialog/cr_dialog.html",
"cr_dialog/cr_dialog.js",
"cr_icon_button/cr_icon_button.html",
"cr_icon_button/cr_icon_button.js",
"cr_icons_css.html",
"cr_input/cr_input.html",
"cr_input/cr_input.js",
"cr_input/cr_input_style_css.html",
"cr_lottie/cr_lottie.html",
"cr_lottie/cr_lottie.js",
"cr_radio_button/cr_card_radio_button.html",
"cr_radio_button/cr_card_radio_button.js",
"cr_radio_button/cr_radio_button_behavior.html",
"cr_radio_button/cr_radio_button_behavior.js",
"cr_radio_button/cr_radio_button.html",
"cr_radio_button/cr_radio_button.js",
"cr_radio_button/cr_radio_button_style_css.html",
"cr_radio_group/cr_radio_group.html",
"cr_radio_group/cr_radio_group.js",
"cr_scrollable_behavior.html",
"cr_scrollable_behavior.js",
"cr_toggle/cr_toggle.html",
"cr_toggle/cr_toggle.js",
"find_shortcut_behavior.js",
"hidden_style_css.html",
"icons.html",
"md_select_css.html",
"policy/cr_policy_indicator_behavior.html",
"policy/cr_policy_indicator_behavior.js",
"policy/cr_policy_indicator.html",
"policy/cr_policy_indicator.js",
"policy/cr_policy_pref_indicator.html",
"policy/cr_policy_pref_indicator.js",
"policy/cr_tooltip_icon.html",
"policy/cr_tooltip_icon.js",
"shared_style_css.html",
"shared_vars_css.html",
]
}
}
if (include_polymer) {
preprocess_if_expr("preprocess_generated") {
deps = [ ":custom_elements" ]
in_folder = target_gen_dir
out_folder = preprocess_folder
out_manifest = "$target_gen_dir/$preprocess_gen_manifest"
in_files = [
"action_link_css.m.js",
"cr_actionable_row_style.m.js",
"cr_button/cr_button.m.js",
"cr_checkbox/cr_checkbox.m.js",
"cr_container_shadow_behavior.m.js",
"cr_dialog/cr_dialog.m.js",
"cr_expand_button/cr_expand_button.js",
"cr_icon_button/cr_icon_button.m.js",
"cr_icons_css.m.js",
"cr_input/cr_input.m.js",
"cr_input/cr_input_style_css.m.js",
"cr_lottie/cr_lottie.m.js",
"cr_radio_button/cr_card_radio_button.m.js",
"cr_radio_button/cr_radio_button_behavior.m.js",
"cr_radio_button/cr_radio_button.m.js",
"cr_radio_button/cr_radio_button_style_css.m.js",
"cr_radio_group/cr_radio_group.m.js",
"cr_scrollable_behavior.m.js",
"cr_toggle/cr_toggle.m.js",
"hidden_style_css.m.js",
"icons.m.js",
"md_select_css.m.js",
"policy/cr_policy_indicator_behavior.m.js",
"policy/cr_policy_indicator.m.js",
"policy/cr_policy_pref_indicator.m.js",
"policy/cr_tooltip_icon.m.js",
"shared_style_css.m.js",
"shared_vars_css.m.js",
]
if (is_chromeos_ash) {
in_files += [ "chromeos/cros_color_overrides.m.js" ]
}
}
}
if (include_polymer) {
group("closure_compile") {
deps = [
":cr_elements_resources",
"cr_checkbox:closure_compile",
"cr_dialog:closure_compile",
"cr_icon_button:closure_compile",
"cr_input:closure_compile",
"cr_lottie:closure_compile",
"cr_radio_button:closure_compile",
"cr_toggle:closure_compile",
"policy:closure_compile",
# Targets for auto-generated Polymer 3 JS Modules
":cr_elements_module_resources",
"cr_button:closure_compile_module",
"cr_checkbox:closure_compile_module",
"cr_dialog:closure_compile_module",
"cr_expand_button:closure_compile_module",
"cr_icon_button:closure_compile_module",
"cr_input:closure_compile_module",
"cr_lottie:closure_compile_module",
"cr_radio_button:closure_compile_module",
"cr_radio_group:closure_compile_module",
"cr_toggle:closure_compile_module",
"policy:closure_compile_module",
]
if (is_chromeos_ash) {
deps += [
"cr_button:closure_compile",
"cr_radio_group:closure_compile",
]
}
}
js_type_check("cr_elements_resources") {
uses_legacy_modules = true
deps = [
":cr_container_shadow_behavior",
":cr_scrollable_behavior",
]
}
js_library("cr_scrollable_behavior") {
deps = [ "//third_party/polymer/v1_0/components-chromium/iron-list:iron-list-extracted" ]
}
js_library("cr_container_shadow_behavior") {
deps = [ "//ui/webui/resources/js:assert" ]
}
}
# Targets for auto-generating Polymer 3 JS Modules.
if (include_polymer) {
polymer_modulizer("action_link_css") {
js_file = "action_link_css.m.js"
html_file = "action_link_css.html"
html_type = "style-module"
}
polymer_modulizer("cr_actionable_row_style") {
js_file = "cr_actionable_row_style.m.js"
html_file = "cr_actionable_row_style.html"
html_type = "style-module"
}
polymer_modulizer("shared_vars_css") {
js_file = "shared_vars_css.m.js"
html_file = "shared_vars_css.html"
html_type = "custom-style"
}
polymer_modulizer("shared_style_css") {
js_file = "shared_style_css.m.js"
html_file = "shared_style_css.html"
html_type = "style-module"
}
polymer_modulizer("hidden_style_css") {
js_file = "hidden_style_css.m.js"
html_file = "hidden_style_css.html"
html_type = "style-module"
}
polymer_modulizer("md_select_css") {
js_file = "md_select_css.m.js"
html_file = "md_select_css.html"
html_type = "style-module"
}
polymer_modulizer("cr_icons_css") {
js_file = "cr_icons_css.m.js"
html_file = "cr_icons_css.html"
html_type = "style-module"
}
polymer_modulizer("icons") {
js_file = "icons.m.js"
html_file = "icons.html"
html_type = "iron-iconset"
}
js_modulizer("modulize") {
input_files = [
"cr_container_shadow_behavior.js",
"cr_scrollable_behavior.js",
]
}
}
if (include_polymer) {
group("custom_elements") {
public_deps = [
":action_link_css_module",
":cr_actionable_row_style_module",
":cr_icons_css_module",
":hidden_style_css_module",
":icons_module",
":md_select_css_module",
":modulize",
":shared_style_css_module",
":shared_vars_css_module",
"cr_button:cr_button_module",
"cr_checkbox:cr_checkbox_module",
"cr_dialog:cr_dialog_module",
"cr_expand_button:web_components",
"cr_icon_button:cr_icon_button_module",
"cr_input:polymer3_elements",
"cr_lottie:cr_lottie_module",
"cr_radio_button:polymer3_elements",
"cr_radio_group:cr_radio_group_module",
"cr_toggle:cr_toggle_module",
"policy:polymer3_elements",
]
if (is_chromeos) {
public_deps += [ "chromeos:polymer3_elements" ]
}
}
}
if (include_polymer) {
js_type_check("cr_elements_module_resources") {
is_polymer3 = true
deps = [
":cr_container_shadow_behavior.m",
":cr_scrollable_behavior.m",
]
if (is_chromeos_ash) {
deps += [ ":find_shortcut_behavior" ]
}
}
js_library("cr_container_shadow_behavior.m") {
sources = [ "$root_gen_dir/ui/webui/resources/cr_elements/cr_container_shadow_behavior.m.js" ]
deps = [ "//ui/webui/resources/js:assert.m" ]
extra_deps = [ ":modulize" ]
}
js_library("cr_scrollable_behavior.m") {
sources = [ "$root_gen_dir/ui/webui/resources/cr_elements/cr_scrollable_behavior.m.js" ]
deps = [
"//third_party/polymer/v3_0/components-chromium/iron-list:iron-list",
"//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
]
extra_deps = [ ":modulize" ]
}
}
if (is_chromeos_ash) {
js_library("find_shortcut_behavior") {
deps = [
"//ui/webui/resources/js:assert.m",
"//ui/webui/resources/js:cr.m",
"//ui/webui/resources/js:util.m",
"//ui/webui/resources/js/cr/ui:keyboard_shortcut_list",
]
}
}
html_to_wrapper("html_wrapper_files_native") {
deps = [ ":preprocess_ts" ]
in_folder = preprocess_folder
out_folder = preprocess_folder
in_files = native_html_files
minify = optimize_webui
template = "native"
}
if (include_polymer) {
html_to_wrapper("html_wrapper_files") {
deps = [ ":preprocess_ts" ]
in_folder = preprocess_folder
out_folder = preprocess_folder
in_files = polymer_html_files + icons_html_files
minify = optimize_webui
}
css_to_wrapper("css_wrapper_files") {
deps = [ ":preprocess_ts" ]
in_folder = preprocess_folder
out_folder = preprocess_folder
in_files = css_files
minify = optimize_webui
}
}