| # Copyright 2022 The Chromium Authors |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| import("//tools/grit/grit_rule.gni") |
| import("//tools/polymer/html_to_wrapper.gni") |
| import("//tools/typescript/ts_library.gni") |
| import("//ui/webui/resources/tools/generate_grd.gni") |
| |
| # The list of components that have a ".ts" file and a ".html" file. |
| file_names = [ |
| "components/manage_mirrorsync", |
| "components/folder_selector", |
| ] |
| |
| ts_files = [ "browser_proxy.ts" ] |
| html_files = [] |
| foreach(f, file_names) { |
| ts_files += [ f + ".ts" ] |
| html_files += [ f + ".html" ] |
| } |
| |
| # Takes the ".html" file from above and generates a TS file out of it. |
| html_to_wrapper("gen_ts_files_from_html") { |
| in_files = html_files |
| out_folder = "$target_gen_dir" |
| } |
| |
| # Copy all the source files into the gen/ directory. |
| copy("copy_src") { |
| sources = ts_files |
| outputs = [ "$target_gen_dir/{{source_target_relative}}" ] |
| } |
| |
| # Mojo bindings are generated in the corresponding webui folder, copy the JS |
| # binding outputs to the same gen/ directory as above. |
| copy("copy_mojo") { |
| deps = [ |
| "//chrome/browser/ui/webui/ash/manage_mirrorsync:mojo_bindings_webui_js", |
| ] |
| sources = [ "$root_gen_dir/mojom-webui/chrome/browser/ui/webui/ash/manage_mirrorsync/manage_mirrorsync.mojom-webui.js" ] |
| outputs = [ "$target_gen_dir/{{source_file_part}}" ] |
| } |
| |
| ts_library("build_ts") { |
| root_dir = "$target_gen_dir" |
| out_dir = "$target_gen_dir/tsc" |
| in_files = [ "manage_mirrorsync.mojom-webui.js" ] + ts_files |
| |
| # The `gen_ts_files_from_html` rule automatically creates these. |
| foreach(f, file_names) { |
| in_files += [ f + ".html.ts" ] |
| } |
| tsconfig_base = "tsconfig_base.json" |
| extra_deps = [ |
| ":copy_mojo", |
| ":copy_src", |
| ":gen_ts_files_from_html", |
| ] |
| composite = true |
| deps = [ "//ui/webui/resources/mojo:library" ] |
| } |
| |
| resources_grd_file = "$target_gen_dir/resources.grd" |
| |
| # Generate a grd file dynamically, this takes static files via `input_files` and |
| # all the files ran through tsc (via the output manifest_files). |
| generate_grd("build_grd") { |
| input_files_base_dir = rebase_path(".", "//") |
| deps = [ ":build_ts" ] |
| input_files = [ |
| "index.html", |
| "main.css", |
| "images/expand_arrow.svg", |
| ] |
| manifest_files = |
| filter_include(get_target_outputs(":build_ts"), [ "*.manifest" ]) |
| |
| grd_prefix = "manage_mirrorsync" |
| out_grd = resources_grd_file |
| } |
| |
| grit("resources") { |
| enable_input_discovery_for_gn_analyze = false |
| source = resources_grd_file |
| deps = [ ":build_grd" ] |
| outputs = [ |
| "grit/manage_mirrorsync_resources.h", |
| "grit/manage_mirrorsync_resources_map.cc", |
| "grit/manage_mirrorsync_resources_map.h", |
| "manage_mirrorsync_resources.pak", |
| ] |
| output_dir = "$root_gen_dir/chrome" |
| } |