| # 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("//sdk/cts/build/cts_element.gni") |
| import("//sdk/cts/build/cts_vars.gni") |
| |
| # A source_set that can be used in CTS. |
| # |
| # An equivalent to the built-in source_set, but ensures dependencies are allowed |
| # in CTS. |
| # |
| # Example: |
| # ``` |
| # cts_source_set("my-source-set") { |
| # sources = [ |
| # "//sdk/cts/tests/my_test/my_lib.h", |
| # "//sdk/cts/tests/my_test/my_lib.cc", |
| # ] |
| # } |
| # ``` |
| template("cts_source_set") { |
| if (defined(invoker.deps) && invoker.deps != []) { |
| cts_element("${target_name}_verify_deps") { |
| deps = invoker.deps |
| invoker_label = get_label_info(invoker.target_name, "label_no_toolchain") |
| } |
| } |
| |
| source_set(target_name) { |
| forward_variables_from(invoker, "*") |
| if (defined(deps) && deps != []) { |
| deps += [ ":${target_name}_verify_deps" ] |
| } |
| } |
| |
| # Creates a file to enable other CTS targets to depend on this test package. |
| target_build_dir = get_label_info(":$target_name", "dir") |
| target_build_dir = string_replace(target_build_dir, "//", "/") |
| write_file( |
| "${root_build_dir}/cts/${target_build_dir}/${target_name}.${cts_extension}", |
| true) |
| } |
| |
| set_defaults("cts_source_set") { |
| configs = default_common_binary_configs |
| } |