| # 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("//crypto/features.gni") |
| import("//third_party/closure_compiler/compile_js.gni") |
| import("//tools/typescript/ts_definitions.gni") |
| import("//tools/typescript/ts_library.gni") |
| import("//ui/webui/resources/include_polymer.gni") |
| import("//ui/webui/resources/tools/generate_grd.gni") |
| import("./cr_elements/cr_elements.gni") |
| |
| generate_grd("build_grd") { |
| grd_prefix = "webui_generated" |
| out_grd = "$target_gen_dir/${grd_prefix}_resources.grd" |
| |
| public_deps = [ |
| ":build_ts_grdp", |
| "css:build_grdp", |
| "html:build_grdp", |
| "images:build_grdp", |
| "js:build_grdp", |
| "js/cr/ui:build_grdp", |
| "js/metrics_reporter:build_grdp", |
| "//third_party/jstemplate:build_grdp", |
| ] |
| grdp_files = [ |
| "$target_gen_dir/css/resources.grdp", |
| "$target_gen_dir/html/resources.grdp", |
| "$target_gen_dir/images/resources.grdp", |
| "$target_gen_dir/js/cr/ui/resources.grdp", |
| "$target_gen_dir/js/metrics_reporter/resources.grdp", |
| "$target_gen_dir/js/resources.grdp", |
| "$target_gen_dir/resources_ts.grdp", |
| "$root_gen_dir/third_party/jstemplate/resources.grdp", |
| ] |
| |
| if (!is_chromeos_ash && !is_android) { |
| # Roboto Font. Roboto-Regular and Roboto-Light is already available on |
| # Android, and Roboto-Medium is not used on Android. All 6 weights of |
| # Roboto are available on Chrome OS. |
| input_files_base_dir = rebase_path(".", "//") |
| input_files = [ |
| "roboto/roboto-bold.woff2", |
| "roboto/roboto-medium.woff2", |
| "roboto/roboto-regular.woff2", |
| ] |
| } |
| |
| if (include_polymer) { |
| public_deps += [ |
| "cr_components:build_grdp", |
| "cr_components/app_management:build_grdp", |
| "cr_components/customize_themes:build_grdp", |
| "cr_components/help_bubble:build_grdp", |
| "cr_components/most_visited:build_grdp", |
| "cr_elements:build_grdp", |
| "js/browser_command:build_grdp", |
| "//third_party/polymer/v3_0:build_grdp", |
| ] |
| grdp_files += [ |
| "$root_gen_dir/third_party/polymer/v3_0/polymer_3_0_resources.grdp", |
| "$root_gen_dir/ui/webui/resources/cr_components/app_management/resources.grdp", |
| "$root_gen_dir/ui/webui/resources/cr_components/cr_components_resources.grdp", |
| "$root_gen_dir/ui/webui/resources/cr_components/customize_themes/resources.grdp", |
| "$root_gen_dir/ui/webui/resources/cr_components/help_bubble/resources.grdp", |
| "$root_gen_dir/ui/webui/resources/cr_components/most_visited/resources.grdp", |
| "$root_gen_dir/ui/webui/resources/cr_elements/cr_elements_resources.grdp", |
| "$root_gen_dir/ui/webui/resources/js/browser_command/resources.grdp", |
| ] |
| |
| if (use_nss_certs) { |
| public_deps += [ "cr_components/certificate_manager:build_grdp" ] |
| grdp_files += |
| [ "$target_gen_dir/cr_components/certificate_manager/resources.grdp" ] |
| } |
| |
| # TODO(crbug.com/1184053): Fully remove once no longer used by CrOS. |
| if (is_chromeos_ash) { |
| public_deps += [ "//third_party/polymer/v1_0:build_grdp" ] |
| grdp_files += [ |
| "$root_gen_dir/third_party/polymer/v1_0/polymer_1_0_resources.grdp", |
| ] |
| } |
| |
| if (!is_android) { |
| public_deps += [ "cr_components/history_clusters:build_grdp" ] |
| grdp_files += [ "$root_gen_dir/ui/webui/resources/cr_components/history_clusters/resources.grdp" ] |
| } |
| } |
| |
| if (is_chromeos_ash) { |
| public_deps += [ |
| ":build_cros_styles_grdp", |
| "//ash/webui/common/resources:build_grdp", |
| "//ash/webui/common/resources:build_html_css_wrapper_files_grdp", |
| "//chromeos/ash/components/cros_elements:build_grdp", |
| "//third_party/material_web_components:build_grdp", |
| "//third_party/web-animations-js:build_grdp", |
| ] |
| grdp_files += [ |
| "$root_gen_dir/ash/webui/common/resources/ash_common_resources.grdp", |
| "$root_gen_dir/ash/webui/common/resources/html_css_wrapper_files_resources.grdp", |
| "$root_gen_dir/chromeos/ash/components/cros_elements/cros_elements_resources.grdp", |
| "$root_gen_dir/third_party/material_web_components/material_web_components_resources.grdp", |
| "$root_gen_dir/third_party/web-animations-js/web_animations_resources.grdp", |
| "$root_gen_dir/ui/webui/resources/cros_styles_resources.grdp", |
| ] |
| } |
| |
| if (!is_android && !is_ios) { |
| public_deps += [ |
| "cr_components/color_change_listener:build_grdp", |
| "//third_party/lottie:build_grdp", |
| ] |
| grdp_files += [ |
| "$root_gen_dir/third_party/lottie/resources.grdp", |
| "$root_gen_dir/ui/webui/resources/cr_components/color_change_listener/resources.grdp", |
| ] |
| } |
| } |
| |
| if (is_chromeos_ash) { |
| generate_grd("build_cros_styles_grdp") { |
| grd_prefix = "webui" |
| out_grd = "$target_gen_dir/cros_styles_resources.grdp" |
| public_deps = [ "//ui/chromeos/styles:cros_styles_css" ] |
| input_files_base_dir = rebase_path("$root_gen_dir/", root_build_dir) |
| input_files = [ "ui/chromeos/styles/cros_styles.css" ] |
| resource_path_rewrites = |
| [ "ui/chromeos/styles/cros_styles.css|chromeos/colors/cros_styles.css" ] |
| } |
| } |
| |
| group("preprocess") { |
| public_deps = [ |
| "cr_elements:preprocess", |
| "js:preprocess", |
| ] |
| |
| if (include_polymer) { |
| public_deps += [ "cr_components:preprocess" ] |
| } |
| } |
| |
| group("closure_compile") { |
| deps = [ |
| "js:closure_compile", |
| "js:closure_compile_modules", |
| ] |
| |
| if (include_polymer) { |
| deps += [ "cr_elements:closure_compile" ] |
| |
| if (is_chromeos_ash) { |
| deps += [ "cr_components/chromeos:closure_compile" ] |
| } |
| } |
| } |
| |
| # TypeScript targets |
| |
| preprocessed_folder = "$target_gen_dir/preprocessed" |
| |
| checked_in_dts_files = [ |
| "cr_elements/cr_button/cr_button.m.d.ts", |
| "cr_elements/cr_checkbox/cr_checkbox.m.d.ts", |
| "cr_elements/cr_container_shadow_behavior.m.d.ts", |
| "cr_elements/cr_dialog/cr_dialog.m.d.ts", |
| "cr_elements/cr_expand_button/cr_expand_button.d.ts", |
| "cr_elements/cr_icon_button/cr_icon_button.m.d.ts", |
| "cr_elements/cr_input/cr_input.m.d.ts", |
| "cr_elements/cr_lottie/cr_lottie.m.d.ts", |
| "cr_elements/cr_radio_button/cr_card_radio_button.m.d.ts", |
| "cr_elements/cr_radio_button/cr_radio_button_behavior.m.d.ts", |
| "cr_elements/cr_radio_button/cr_radio_button.m.d.ts", |
| "cr_elements/cr_radio_group/cr_radio_group.m.d.ts", |
| "cr_elements/cr_scrollable_behavior.m.d.ts", |
| "cr_elements/cr_toggle/cr_toggle.m.d.ts", |
| "cr_elements/find_shortcut_behavior.d.ts", |
| "cr_elements/policy/cr_policy_indicator_behavior.m.d.ts", |
| "cr_elements/policy/cr_policy_indicator.m.d.ts", |
| "cr_elements/policy/cr_policy_pref_indicator.m.d.ts", |
| "cr_elements/policy/cr_tooltip_icon.m.d.ts", |
| "js/cr/ui/focus_row_behavior.m.d.ts", |
| "js/i18n_behavior.m.d.ts", |
| "js/parse_html_subset.m.d.ts", |
| "js/promise_resolver.m.d.ts", |
| "js/static_types.d.ts", |
| "js/web_ui_listener_behavior.m.d.ts", |
| ] |
| |
| if (is_chromeos_ash || is_fuchsia || is_linux || is_mac || is_win) { |
| checked_in_dts_files += [ |
| "js/cr/ui/context_menu_handler.d.ts", |
| "js/cr/ui/menu_button.d.ts", |
| "js/cr/ui/menu_item.d.ts", |
| ] |
| } |
| |
| if (is_chromeos_ash) { |
| checked_in_dts_files += [ |
| "cr_components/chromeos/bluetooth/bluetooth_base_page.d.ts", |
| "cr_components/chromeos/bluetooth/bluetooth_battery_icon_percentage.d.ts", |
| "cr_components/chromeos/bluetooth/bluetooth_device_battery_info.d.ts", |
| "cr_components/chromeos/bluetooth/bluetooth_icon.d.ts", |
| "cr_components/chromeos/bluetooth/bluetooth_pairing_device_item.d.ts", |
| "cr_components/chromeos/bluetooth/bluetooth_pairing_device_selection_page.d.ts", |
| "cr_components/chromeos/bluetooth/bluetooth_pairing_enter_code_page.d.ts", |
| "cr_components/chromeos/bluetooth/bluetooth_pairing_request_code_page.d.ts", |
| "cr_components/chromeos/bluetooth/bluetooth_pairing_ui.d.ts", |
| "cr_components/chromeos/smb_shares/add_smb_share_dialog.d.ts", |
| "cr_components/chromeos/smb_shares/smb_browser_proxy.d.ts", |
| "js/cr/ui/grid.m.d.ts", |
| "js/cr/ui/list.m.d.ts", |
| "js/list_property_update_behavior.d.ts", |
| ] |
| } |
| |
| # Copies checked-in .d.ts files to the preprocess folder so that they are |
| # discovered by TSC the same way generated .d.ts files are. |
| copy("copy_checked_in_dts_files") { |
| sources = checked_in_dts_files |
| outputs = [ "$preprocessed_folder/{{source_target_relative}}" ] |
| } |
| |
| # Files for which .d.ts files will be auto-generated with ts_definitions(). |
| generate_definitions_js_files = [ |
| "js/action_link.js", |
| "js/assert.m.js", |
| "js/color_utils.js", |
| "js/cr/event_target.m.js", |
| "js/cr.m.js", |
| "js/cr/ui.m.js", |
| "js/cr/ui/focus_outline_manager.m.js", |
| "js/cr/ui/focus_row.m.js", |
| "js/cr/ui/keyboard_shortcut_list.js", |
| "js/event_tracker.m.js", |
| "js/load_time_data.m.js", |
| "js/plural_string_proxy.js", |
| "js/icon.js", |
| "js/util.m.js", |
| ] |
| |
| if (is_chromeos_ash || is_fuchsia || is_linux || is_mac || is_win) { |
| generate_definitions_js_files += [ |
| "js/cr/ui/menu.js", |
| "js/cr/ui/command.js", |
| "js/cr/ui/position_util.js", |
| ] |
| } |
| |
| if (is_chromeos_ash) { |
| generate_definitions_js_files += [ |
| "js/cr/ui/array_data_model.m.js", |
| "js/cr/ui/list_item.m.js", |
| "js/cr/ui/list_selection_controller.m.js", |
| "js/cr/ui/list_selection_model.m.js", |
| "js/cr/ui/list_single_selection_model.m.js", |
| "js/cr/ui/store_client.js", |
| "js/cr/ui/store.js", |
| ] |
| } |
| |
| if (include_polymer) { |
| generate_definitions_js_files += [ |
| "cr_elements/action_link_css.m.js", |
| "cr_elements/cr_actionable_row_style.m.js", |
| "cr_elements/cr_icons_css.m.js", |
| "cr_elements/cr_input/cr_input_style_css.m.js", |
| "cr_elements/cr_radio_button/cr_radio_button_style_css.m.js", |
| "cr_elements/hidden_style_css.m.js", |
| "cr_elements/icons.m.js", |
| "cr_elements/md_select_css.m.js", |
| "cr_elements/shared_style_css.m.js", |
| "cr_elements/shared_vars_css.m.js", |
| ] |
| |
| if (is_chromeos_ash) { |
| generate_definitions_js_files += [ |
| "cr_components/chromeos/bluetooth/bluetooth_dialog.js", |
| "cr_components/chromeos/bluetooth/bluetooth_icons.js", |
| "cr_components/chromeos/bluetooth/bluetooth_metrics_utils.js", |
| "cr_components/chromeos/bluetooth/bluetooth_pairing_confirm_code_page.js", |
| "cr_components/chromeos/bluetooth/bluetooth_spinner_page.js", |
| "cr_components/chromeos/bluetooth/bluetooth_types.js", |
| "cr_components/chromeos/bluetooth/bluetooth_utils.js", |
| "cr_components/chromeos/bluetooth/cros_bluetooth_config.js", |
| "cr_components/chromeos/quick_unlock/lock_screen_constants.m.js", |
| "cr_components/chromeos/quick_unlock/pin_keyboard_icon.m.js", |
| "cr_components/chromeos/quick_unlock/pin_keyboard.m.js", |
| "cr_components/chromeos/quick_unlock/setup_pin_keyboard.m.js", |
| "cr_elements/chromeos/cros_color_overrides.m.js", |
| ] |
| } |
| } |
| |
| if (!is_android) { |
| generate_definitions_js_files += [ "js/cr/ui/focus_without_ink.m.js" ] |
| } |
| |
| if (is_ios) { |
| generate_definitions_js_files += [ "js/ios/web_ui.js" ] |
| } |
| |
| ts_library("library") { |
| root_dir = preprocessed_folder |
| out_dir = preprocessed_folder |
| composite = true |
| tsconfig_base = "tsconfig_base.json" |
| |
| in_files = cr_elements_files + [ |
| "js/assert_ts.ts", |
| "js/custom_element.ts", |
| "js/cr/ui/focus_grid.ts", |
| "js/cr/ui/drag_wrapper.ts", |
| "js/cr/ui/store_ts.ts", |
| ] |
| |
| if (include_polymer) { |
| in_files += [ |
| "cr_components/localized_link/localized_link.html.ts", |
| "cr_components/localized_link/localized_link.ts", |
| "cr_components/managed_dialog/managed_dialog.html.ts", |
| "cr_components/managed_dialog/managed_dialog.ts", |
| "cr_components/managed_footnote/managed_footnote.html.ts", |
| "cr_components/managed_footnote/managed_footnote.ts", |
| "js/i18n_mixin.ts", |
| "js/list_property_update_mixin.ts", |
| "js/search_highlight_utils.ts", |
| "js/web_ui_listener_mixin.ts", |
| ] |
| } |
| |
| definitions = [ |
| "//tools/typescript/definitions/bluetooth_private.d.ts", |
| "//tools/typescript/definitions/bluetooth.d.ts", |
| "//tools/typescript/definitions/chrome_send.d.ts", |
| "//tools/typescript/definitions/pending.d.ts", |
| "//tools/typescript/definitions/settings_private.d.ts", |
| ] |
| |
| # Checked-in .d.ts files. |
| foreach(_file, checked_in_dts_files) { |
| definitions += [ "$root_dir/$_file" ] |
| } |
| |
| # Auto-generated .d.ts files. |
| foreach(_file, generate_definitions_js_files) { |
| definitions += [ "$root_dir/" + string_replace(_file, ".js", ".d.ts") ] |
| } |
| |
| deps = [ "//third_party/polymer/v3_0:library" ] |
| extra_deps = [ |
| ":copy_checked_in_dts_files", |
| ":generate_definitions", |
| ":preprocess", |
| ] |
| } |
| |
| generate_grd("build_ts_grdp") { |
| grd_prefix = "webui" |
| out_grd = "$target_gen_dir/resources_ts.grdp" |
| public_deps = [ ":library" ] |
| manifest_files = |
| filter_include(get_target_outputs(":library"), [ "*.manifest" ]) |
| } |
| |
| ts_definitions("generate_definitions") { |
| root_dir = preprocessed_folder |
| out_dir = preprocessed_folder |
| js_files = generate_definitions_js_files |
| extra_deps = [ |
| # Copy checked-in d.ts files first, so that |generate_definitions| leverages |
| # these files, instead of accidentally auto-generating them. |
| ":copy_checked_in_dts_files", |
| ":preprocess", |
| "mojo:library", |
| ] |
| } |