xref: /aosp_15_r20/external/angle/build/chromeos/crosier_tests.gni (revision 8975f5c5ed3d1c378011245431ada316dfb6f244)
1*8975f5c5SAndroid Build Coastguard Worker# Copyright 2024 The Chromium Authors
2*8975f5c5SAndroid Build Coastguard Worker# Use of this source code is governed by a BSD-style license that can be found
3*8975f5c5SAndroid Build Coastguard Worker# in the LICENSE file.
4*8975f5c5SAndroid Build Coastguard Worker
5*8975f5c5SAndroid Build Coastguard Worker# The crosier_tests template is used to define crosier test targets in
6*8975f5c5SAndroid Build Coastguard Worker# subdirectories. They should be in the dependency chain of the top-level
7*8975f5c5SAndroid Build Coastguard Worker# chromeos_integration_tests target.
8*8975f5c5SAndroid Build Coastguard Worker#
9*8975f5c5SAndroid Build Coastguard Worker# crosier_tests behaves like source_set except that it supports (and expects) a
10*8975f5c5SAndroid Build Coastguard Worker# "sources_metadata" variable that lists the yaml metadata files corresponding
11*8975f5c5SAndroid Build Coastguard Worker# to the test sources. These files will be copied to the appropriate directory.
12*8975f5c5SAndroid Build Coastguard Worker# See docs/testing/chromeos_integration/crosier_metadata.md for details.
13*8975f5c5SAndroid Build Coastguard Worker
14*8975f5c5SAndroid Build Coastguard Workerimport("//build/config/chromeos/ui_mode.gni")
15*8975f5c5SAndroid Build Coastguard Worker
16*8975f5c5SAndroid Build Coastguard Workertemplate("crosier_tests") {
17*8975f5c5SAndroid Build Coastguard Worker  assert(is_chromeos_device)
18*8975f5c5SAndroid Build Coastguard Worker  assert(defined(invoker.sources),
19*8975f5c5SAndroid Build Coastguard Worker         "Need sources in $target_name listing the C++ files.")
20*8975f5c5SAndroid Build Coastguard Worker  assert(defined(invoker.sources_metadata),
21*8975f5c5SAndroid Build Coastguard Worker         "Need sources_metadata in $target_name listing the yaml files.")
22*8975f5c5SAndroid Build Coastguard Worker
23*8975f5c5SAndroid Build Coastguard Worker  _have_metadata = invoker.sources_metadata != []
24*8975f5c5SAndroid Build Coastguard Worker
25*8975f5c5SAndroid Build Coastguard Worker  source_set(target_name) {
26*8975f5c5SAndroid Build Coastguard Worker    forward_variables_from(invoker, "*", [ "sources_metadata" ])
27*8975f5c5SAndroid Build Coastguard Worker    testonly = true
28*8975f5c5SAndroid Build Coastguard Worker    if (defined(defines)) {
29*8975f5c5SAndroid Build Coastguard Worker      defines += [ "HAS_OUT_OF_PROC_TEST_RUNNER" ]
30*8975f5c5SAndroid Build Coastguard Worker    } else {
31*8975f5c5SAndroid Build Coastguard Worker      defines = [ "HAS_OUT_OF_PROC_TEST_RUNNER" ]
32*8975f5c5SAndroid Build Coastguard Worker    }
33*8975f5c5SAndroid Build Coastguard Worker    if (_have_metadata) {
34*8975f5c5SAndroid Build Coastguard Worker      if (defined(data_deps)) {
35*8975f5c5SAndroid Build Coastguard Worker        data_deps += [ ":${target_name}_metadata" ]
36*8975f5c5SAndroid Build Coastguard Worker      } else {
37*8975f5c5SAndroid Build Coastguard Worker        data_deps = [ ":${target_name}_metadata" ]
38*8975f5c5SAndroid Build Coastguard Worker      }
39*8975f5c5SAndroid Build Coastguard Worker    }
40*8975f5c5SAndroid Build Coastguard Worker  }
41*8975f5c5SAndroid Build Coastguard Worker
42*8975f5c5SAndroid Build Coastguard Worker  if (_have_metadata) {
43*8975f5c5SAndroid Build Coastguard Worker    copy("${target_name}_metadata") {
44*8975f5c5SAndroid Build Coastguard Worker      testonly = true
45*8975f5c5SAndroid Build Coastguard Worker      sources = invoker.sources_metadata
46*8975f5c5SAndroid Build Coastguard Worker      outputs = [ "$root_out_dir/crosier_metadata/{{source_file_part}}" ]
47*8975f5c5SAndroid Build Coastguard Worker    }
48*8975f5c5SAndroid Build Coastguard Worker  }
49*8975f5c5SAndroid Build Coastguard Worker}
50