| # Copyright 2020 The Fuchsia 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("//cts/build/cts_vars.gni") |
| |
| # Defines a CTS element. |
| # |
| # Ensures that dependencies are allowed in CTS. This template should not be used |
| # directly, but through the other CTS templates. |
| template("cts_element") { |
| assert(defined(invoker.deps)) |
| |
| # This template is used for code-reuse, not to create a target, so the |
| # target_name isn't needed. |
| not_needed([ "target_name" ]) |
| |
| deps = [] |
| foreach(dep, invoker.deps) { |
| allowed = false |
| foreach(adep, allowed_cts_deps) { |
| if (!allowed && dep == adep) { |
| deps += [ dep ] |
| allowed = true |
| } |
| } |
| |
| if (!allowed) { |
| label_name = get_label_info(dep, "name") |
| is_cts = rebase_path("${root_gen_dir}/cts/${label_name}.${cts_extension}") |
| |
| # CTS targets can depend on other CTS targets, but not on targets outside |
| # of CTS. To check a target's type, CTS creates a file for each cts_* |
| # invocation and is checked for here. |
| # |
| # If the file is not found, the dependency is not in allowed_cts_deps, it |
| # is not a CTS target, and it cannot be used in CTS. |
| if (read_file(is_cts, "value")) { # Read above for context. |
| deps += [ dep ] |
| } |
| } |
| } |
| } |