| # Copyright 2018 The Chromium Authors |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| import("//chrome/common/features.gni") |
| import("//tools/grit/grit_rule.gni") |
| import("//tools/grit/preprocess_if_expr.gni") |
| import("//tools/polymer/html_to_wrapper.gni") |
| import("//tools/typescript/ts_library.gni") |
| import("//ui/webui/resources/tools/generate_grd.gni") |
| |
| assert(!is_android) |
| |
| preprocess_folder = "preprocessed" |
| tsc_folder = "tsc" |
| |
| # Files holding a Polymer element definition and have an equivalent .html file. |
| web_component_files = [ |
| "database_tab.ts", |
| "discards_main.ts", |
| "discards_tab.ts", |
| "graph_tab_template.ts", |
| ] |
| |
| # Files that are passed as input to html_to_wrapper(). |
| html_files = [] |
| foreach(f, web_component_files) { |
| html_files += [ string_replace(f, ".ts", ".html") ] |
| } |
| |
| # Files that are generated by html_to_wrapper(). |
| html_wrapper_files = [] |
| foreach(f, html_files) { |
| html_wrapper_files += [ f + ".ts" ] |
| } |
| |
| ts_files = [ |
| "discards.ts", |
| "graph_doc.ts", |
| "sorted_table_mixin.ts", |
| ] + web_component_files |
| |
| html_to_wrapper("html_wrapper_files") { |
| in_files = html_files |
| } |
| |
| preprocess_if_expr("preprocess") { |
| in_files = ts_files |
| out_folder = "$target_gen_dir/$preprocess_folder" |
| } |
| |
| preprocess_if_expr("preprocess_gen") { |
| in_folder = target_gen_dir |
| in_files = html_wrapper_files |
| out_folder = "$target_gen_dir/$preprocess_folder" |
| deps = [ ":html_wrapper_files" ] |
| } |
| |
| # This action merges the graph tab script into the graph_doc HTML template. |
| # It then base64 encodes the combination, and merges into the graph_tab HTML |
| # template to complete the data: URL for the webview therein. |
| action("generate_graph_tab") { |
| script = "generate_graph_tab.py" |
| sources = [ |
| "graph_doc.ts", |
| "graph_doc_template.html", |
| "graph_tab_template.html", |
| ] |
| outputs = [ "$target_gen_dir/graph_tab/graph_tab_template.html.js" ] |
| |
| args = rebase_path(outputs, root_build_dir) + |
| rebase_path([ "graph_doc_template.html" ], root_build_dir) + |
| rebase_path([ |
| "$target_gen_dir/tsc/graph_doc.js", |
| "$target_gen_dir/tsc/graph_tab_template.html.js", |
| ], |
| root_build_dir) |
| deps = [ ":build_ts" ] |
| } |
| |
| copy("copy_mojo") { |
| deps = [ |
| "//chrome/browser/resource_coordinator:mojo_bindings_ts__generator", |
| "//chrome/browser/ui/webui/discards:mojo_bindings_ts__generator", |
| ] |
| sources = [ |
| "$root_gen_dir/chrome/browser/resource_coordinator/lifecycle_unit_state.mojom-webui.ts", |
| "$root_gen_dir/chrome/browser/ui/webui/discards/discards.mojom-webui.ts", |
| "$root_gen_dir/chrome/browser/ui/webui/discards/site_data.mojom-webui.ts", |
| ] |
| outputs = [ "$target_gen_dir/$preprocess_folder/{{source_file_part}}" ] |
| } |
| |
| ts_library("build_ts") { |
| root_dir = "$target_gen_dir/$preprocess_folder" |
| out_dir = "$target_gen_dir/$tsc_folder" |
| composite = true |
| tsconfig_base = "tsconfig_base.json" |
| manifest_excludes = [ |
| "graph_doc.ts", |
| "graph_tab_template.html.ts", |
| ] |
| in_files = ts_files + html_wrapper_files + [ |
| "discards.mojom-webui.ts", |
| "site_data.mojom-webui.ts", |
| "lifecycle_unit_state.mojom-webui.ts", |
| ] |
| |
| deps = [ |
| "//third_party/polymer/v3_0:library", |
| "//ui/webui/resources:library", |
| ] |
| |
| extra_deps = [ |
| ":copy_mojo", |
| ":preprocess", |
| ":preprocess_gen", |
| ] |
| } |
| |
| generate_grd("build_graph_tab_grdp") { |
| input_files = [ "graph_tab_template.html.js" ] |
| input_files_base_dir = |
| rebase_path("$target_gen_dir/graph_tab", root_build_dir) |
| deps = [ ":generate_graph_tab" ] |
| grd_prefix = "discards" |
| out_grd = "$target_gen_dir/discards_graph_tab.grdp" |
| } |
| |
| generate_grd("build_grd") { |
| input_files = [ "discards.html" ] |
| input_files_base_dir = rebase_path(".", "//") |
| deps = [ |
| ":build_graph_tab_grdp", |
| ":build_ts", |
| ] |
| manifest_files = |
| filter_include(get_target_outputs(":build_ts"), [ "*.manifest" ]) |
| grdp_files = [ "$target_gen_dir/discards_graph_tab.grdp" ] |
| grd_prefix = "discards" |
| out_grd = "$target_gen_dir/${grd_prefix}_resources.grd" |
| } |
| |
| grit("resources") { |
| defines = chrome_grit_defines |
| |
| # These arguments are needed since the grd is generated at build time. |
| enable_input_discovery_for_gn_analyze = false |
| source = "$target_gen_dir/discards_resources.grd" |
| deps = [ ":build_grd" ] |
| |
| outputs = [ |
| "grit/discards_resources.h", |
| "grit/discards_resources_map.cc", |
| "grit/discards_resources_map.h", |
| "discards_resources.pak", |
| ] |
| output_dir = "$root_gen_dir/chrome" |
| } |