Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / build / chip / chip_test.gni
1 # Copyright (c) 2020 Project CHIP Authors
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 import("//build_overrides/build.gni")
16 import("//build_overrides/chip.gni")
17 import("//build_overrides/pigweed.gni")
18
19 import("$dir_pw_build/python_action.gni")
20
21 import("${chip_root}/build/chip/tests.gni")
22 import("${chip_root}/src/platform/device.gni")
23 import("${dir_pw_unit_test}/test.gni")
24
25 assert(chip_build_tests)
26
27 if (chip_link_tests) {
28   template("chip_test") {
29     _test_name = target_name
30
31     _test_output_dir = "${root_out_dir}/tests"
32     if (defined(invoker.output_dir)) {
33       _test_output_dir = invoker.output_dir
34     }
35
36     executable(_test_name) {
37       forward_variables_from(invoker, "*", [ "output_dir" ])
38       output_dir = _test_output_dir
39     }
40
41     group(_test_name + "_lib") {
42     }
43
44     pw_python_action(_test_name + "_run") {
45       deps = [ ":${_test_name}" ]
46       inputs = [ pw_unit_test_AUTOMATIC_RUNNER ]
47       script = "$dir_pw_unit_test/py/pw_unit_test/test_runner.py"
48       args = [
49         "--runner",
50         rebase_path(pw_unit_test_AUTOMATIC_RUNNER, root_build_dir),
51         "--test",
52         rebase_path("$_test_output_dir/$_test_name", root_build_dir),
53       ]
54       stamp = true
55     }
56   }
57 } else {
58   template("chip_test") {
59     group(target_name) {
60     }
61     group(target_name + "_lib") {
62     }
63     not_needed(invoker, "*")
64   }
65 }