| # Copyright 2021 The Chromium Authors | |
| # Use of this source code is governed by a BSD-style license that can be | |
| # found in the LICENSE file. | |
| import("../../../scripts/build/ninja/vars.gni") | |
| import("../../../scripts/build/typescript/typescript.gni") | |
| template("devtools_base_module") { | |
| ts_library(target_name) { | |
| forward_variables_from(invoker, "*", [ "visibility" ]) | |
| visibility += [ ":*" ] | |
| } | |
| } | |
| # Legacy exceptions for devtools_module in core and models. | |
| # New modules in these directories must use devtools_foundation_module instead. | |
| _devtools_module_folder_exceptions = [ | |
| "front_end/core/platform/browser", | |
| "front_end/core/platform/node", | |
| ] | |
| _devtools_module_folder_exceptions_full = [] | |
| foreach(_dir, _devtools_module_folder_exceptions) { | |
| _devtools_module_folder_exceptions_full += | |
| [ devtools_location_prepend + _dir ] | |
| } | |
| template("devtools_module") { | |
| _target_dir = get_label_info(":$target_name", "dir") | |
| _disallowed = | |
| filter_include([ _target_dir ], | |
| [ | |
| devtools_location_prepend + "front_end/core", | |
| devtools_location_prepend + "front_end/core/*", | |
| devtools_location_prepend + "front_end/models", | |
| devtools_location_prepend + "front_end/models/*", | |
| ]) | |
| assert( | |
| filter_exclude(_disallowed, _devtools_module_folder_exceptions_full) == | |
| [], | |
| "devtools_module is not allowed in $_target_dir. Use devtools_foundation_module instead.") | |
| devtools_base_module(target_name) { | |
| forward_variables_from(invoker, "*") | |
| } | |
| } | |
| # API tests (`*.test.api.ts`). They import `describe`, `it` and `setup` from | |
| # test/api/mocha-interface.ts, so the target needs `test/api` in its `ts_deps`. | |
| template("devtools_api_test_module") { | |
| devtools_base_module(target_name) { | |
| testonly = true | |
| forward_variables_from(invoker, "*", [ "testonly" ]) | |
| } | |
| } | |
| # A module that can run in any runtime we support. As such, it must only use | |
| # features and APIs shared across all supported runtimes. | |
| # | |
| # To check for this we type-check both against browser and node runtime APIs. | |
| template("devtools_foundation_module") { | |
| _node_type_check_target = target_name + "_node_typecheck" | |
| ts_type_check(_node_type_check_target) { | |
| forward_variables_from(invoker, | |
| "*", | |
| [ | |
| "deps", | |
| "ts_deps", | |
| "validations", | |
| "visibility", | |
| ]) | |
| if (defined(invoker.ts_deps)) { | |
| ts_deps = invoker.ts_deps | |
| } | |
| if (defined(invoker.deps)) { | |
| deps = invoker.deps | |
| } | |
| es_target = "es2023" | |
| es_libs = [] | |
| runs_in = "node" | |
| } | |
| ts_library(target_name) { | |
| forward_variables_from(invoker, "*", [ "visibility" ]) | |
| es_target = "es2023" | |
| es_libs = [ | |
| "dom", | |
| "dom.iterable", | |
| ] | |
| visibility += [ ":*" ] | |
| # Not in public_deps: the stamp changes on each run and defeats restat. | |
| validations += [ ":$_node_type_check_target" ] | |
| } | |
| } | |
| template("devtools_ui_module") { | |
| devtools_base_module(target_name) { | |
| forward_variables_from(invoker, "*") | |
| es_target = "esnext" | |
| es_libs = [ | |
| "dom", | |
| "dom.iterable", | |
| ] | |
| } | |
| } | |
| foreach(module, | |
| [ | |
| "devtools_api_test_module", | |
| "devtools_foundation_module", | |
| "devtools_module", | |
| "devtools_ui_module", | |
| ]) { | |
| set_defaults(module) { | |
| visibility = [] | |
| data = [] | |
| public_deps = [] | |
| validations = [] | |
| } | |
| } |