blob: e1a116ce0a2210fc65542f29a45c3b69a4bb74fe [file] [log] [blame]
# 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("//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")
bluetooth_grd_prefix = "bluetooth_internals"
resources_grd_file = "$target_gen_dir/resources.grd"
html_files = [
"characteristic_list_item.html",
"descriptor_list_item.html",
"device_table.html",
"expandable_list.html",
"expandable_list_item.html",
"object_fieldset.html",
"service_list_item.html",
"snackbar.html",
"value_control.html",
]
# Files generated by html_to_wrapper
html_wrapper_files = []
foreach(f, html_files) {
html_wrapper_files += [ f + ".ts" ]
}
html_to_wrapper("html_wrapper_files") {
in_files = html_files
template = "native"
}
js_files = [
"adapter_broker.js",
"adapter_page.js",
"characteristic_list.js",
"characteristic_list_item.js",
"debug_log_page.js",
"descriptor_list.js",
"descriptor_list_item.js",
"device_broker.js",
"device_collection.js",
"device_details_page.js",
"device_table.js",
"device_utils.js",
"devices_page.js",
"expandable_list_item.js",
"expandable_list.js",
"bluetooth_internals.js",
"main.js",
"object_fieldset.js",
"page_manager.js",
"page.js",
"service_list.js",
"service_list_item.js",
"sidebar.js",
"snackbar.js",
"value_control.js",
]
mojom_files = [
"adapter.mojom-webui.ts",
"bluetooth_internals.mojom-webui.ts",
"device.mojom-webui.ts",
"uuid.mojom-webui.js",
]
copy("copy_mojom") {
deps = [
"//chrome/browser/ui/webui/bluetooth_internals:mojo_bindings_ts__generator",
"//device/bluetooth/public/mojom:deprecated_experimental_interfaces_ts__generator",
"//device/bluetooth/public/mojom:mojom_js__generator",
]
sources = [
"$root_gen_dir/chrome/browser/ui/webui/bluetooth_internals/bluetooth_internals.mojom-webui.ts",
"$root_gen_dir/device/bluetooth/public/mojom/adapter.mojom-webui.ts",
"$root_gen_dir/device/bluetooth/public/mojom/device.mojom-webui.ts",
"$root_gen_dir/mojom-webui/device/bluetooth/public/mojom/uuid.mojom-webui.js",
]
outputs = [ "$target_gen_dir/{{source_file_part}}" ]
}
copy("copy_files") {
sources = js_files
outputs = [ "${target_gen_dir}/{{source_file_part}}" ]
}
# TODO(crbug.com/1337318): This page should be converted to TypeScript but this
# will be a lot of work. Passing the JavaScript files through the TypeScript
# compiler will provide basic static checks (e.g. syntax) without validating
# types.
ts_library("build_ts") {
root_dir = target_gen_dir
out_dir = "$target_gen_dir/tsc"
tsconfig_base = "tsconfig_base.json"
in_files = js_files + html_wrapper_files + mojom_files
deps = [
"//ui/webui/resources/js:build_ts",
"//ui/webui/resources/mojo:library",
]
extra_deps = [
":copy_files",
":copy_mojom",
":html_wrapper_files",
]
}
grit("resources") {
enable_input_discovery_for_gn_analyze = false
source = resources_grd_file
deps = [ ":build_grd" ]
outputs = [
"grit/bluetooth_internals_resources.h",
"grit/bluetooth_internals_resources_map.h",
"grit/bluetooth_internals_resources_map.cc",
"bluetooth_internals_resources.pak",
]
output_dir = "$root_gen_dir/chrome"
}
generate_grd("build_grd") {
grd_prefix = bluetooth_grd_prefix
out_grd = resources_grd_file
deps = [ ":build_ts" ]
input_files = [
"bluetooth_internals.css",
"bluetooth_internals.html",
"menu.svg",
]
input_files_base_dir = rebase_path(".", "//")
manifest_files =
filter_include(get_target_outputs(":build_ts"), [ "*.manifest" ])
}