blob: ce03df58ea5fa42a385feba44779a83d365d098c [file] [log] [blame]
Austin Engcc2516a2023-10-17 20:57:54 +00001# Copyright 2022 The Dawn & Tint Authors
Austin Eng1cdea902022-03-24 00:21:55 +00002#
Austin Engcc2516a2023-10-17 20:57:54 +00003# Redistribution and use in source and binary forms, with or without
4# modification, are permitted provided that the following conditions are met:
Austin Eng1cdea902022-03-24 00:21:55 +00005#
Austin Engcc2516a2023-10-17 20:57:54 +00006# 1. Redistributions of source code must retain the above copyright notice, this
7# list of conditions and the following disclaimer.
Austin Eng1cdea902022-03-24 00:21:55 +00008#
Austin Engcc2516a2023-10-17 20:57:54 +00009# 2. Redistributions in binary form must reproduce the above copyright notice,
10# this list of conditions and the following disclaimer in the documentation
11# and/or other materials provided with the distribution.
12#
13# 3. Neither the name of the copyright holder nor the names of its
14# contributors may be used to endorse or promote products derived from
15# this software without specific prior written permission.
16#
17# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
21# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
24# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Kai Ninomiya5c780d72022-03-17 21:43:17 +000027
28# Note: This file is intentionally not used by any other BUILD.gn in Dawn.
29# Instead, Chromium depends directly on this file to build the WebGPU CTS.
30# Scripts called from this file assume Dawn is checked out inside Chromium.
31
Austin Eng1cdea902022-03-24 00:21:55 +000032import("../../../scripts/dawn_overrides_with_defaults.gni")
33
Kai Ninomiya5c780d72022-03-17 21:43:17 +000034group("webgpu-cts") {
35 public_deps = [
36 ":compile_src",
37 ":copy_resources",
38 ":verify_gen_ts_dep_list",
39 ]
Brian Sheedyced4c0d2022-08-11 15:16:38 +000040 data = [ "test_list.txt" ]
Kai Ninomiya5c780d72022-03-17 21:43:17 +000041}
42
43list_from_ts_sources_txt = read_file("ts_sources.txt", "list lines")
44
45ts_source_inputs = [ "../../webgpu-cts/tsconfig.json" ]
46foreach(file, list_from_ts_sources_txt) {
47 ts_source_inputs += [ "../../webgpu-cts/$file" ]
48}
49
50js_outputs = []
Austin Eng75943c22022-09-13 22:22:02 +000051foreach(ts_file, filter_exclude(list_from_ts_sources_txt, [ "*.d.ts" ])) {
Kai Ninomiya5c780d72022-03-17 21:43:17 +000052 js_file = string_replace(ts_file, ".ts", ".js")
Kai Ninomiyaca296e12024-04-08 21:20:13 +000053 js_node_file = string_replace(js_file, "src/", "src-node/", 1)
Kai Ninomiya5c780d72022-03-17 21:43:17 +000054
55 js_outputs += [ "$target_gen_dir/../../webgpu-cts/$js_file" ]
56
57 if (js_node_file != "src-node/common/runtime/wpt.js" &&
58 js_node_file != "src-node/common/runtime/standalone.js" &&
Austin Engb542f9d2022-03-19 00:50:18 +000059 js_node_file != "src-node/common/runtime/helper/test_worker.js" &&
60 js_node_file !=
61 "src-node/webgpu/web_platform/worker/worker_launcher.js") {
Kai Ninomiya5c780d72022-03-17 21:43:17 +000062 js_outputs += [ "$target_gen_dir/../../webgpu-cts/$js_node_file" ]
63 }
64}
Kai Ninomiyaca296e12024-04-08 21:20:13 +000065foreach(ts_file,
66 filter_include(list_from_ts_sources_txt, [ "src/webgpu/*.spec.ts" ])) {
67 worker_js_file =
Kai Ninomiyae3950cb2024-07-03 21:45:24 +000068 string_replace(string_replace(ts_file, ".spec.ts", ".as_worker.js"),
Kai Ninomiyaca296e12024-04-08 21:20:13 +000069 "src/webgpu/",
70 "src/webgpu/webworker/",
71 1)
72 js_outputs += [ "$target_gen_dir/../../webgpu-cts/$worker_js_file" ]
73}
Kai Ninomiya5c780d72022-03-17 21:43:17 +000074
75action("compile_src") {
Austin Eng1cdea902022-03-24 00:21:55 +000076 script = "${dawn_root}/webgpu-cts/scripts/compile_src.py"
Kai Ninomiya5c780d72022-03-17 21:43:17 +000077
78 inputs = [
79 "//third_party/node/node_modules/typescript/lib/tsc.js",
80 "//third_party/node/node.py",
Austin Eng1cdea902022-03-24 00:21:55 +000081 "${dawn_root}/webgpu-cts/scripts/tsc_ignore_errors.py",
Kai Ninomiya44f7b8d2022-10-05 00:00:05 +000082
83 # If the only change is that a file is deleted, we still need to
84 # rebuild so that listing.js gets updated.
85 "ts_sources.txt",
Kai Ninomiya5c780d72022-03-17 21:43:17 +000086 ] + ts_source_inputs
87
88 outputs = js_outputs
89 data = js_outputs
90
91 args = [ rebase_path("$target_gen_dir/../../webgpu-cts", root_build_dir) ]
92}
93
94list_from_resource_files_txt = read_file("resource_files.txt", "list lines")
95resource_file_inputs = []
96foreach(file, list_from_resource_files_txt) {
97 resource_file_inputs += [ "$file" ]
98}
99
Ben Clayton2880e5d2023-11-16 17:16:57 +0000100action("copy_resources") {
Ben Clayton248bad42023-11-20 22:40:34 +0000101 # Note: We use a python script to perform the copy here instead of a "copy"
102 # action because of limitations of source expansions. This copy needs to:
103 # * move files to outside the target's directory
104 # * remove '/src/' from within the path
105 # * copy subdirectories.
106 # It does not seem possible to do all of these things with a source expansion.
Ben Clayton2880e5d2023-11-16 17:16:57 +0000107 src_dir = "../../webgpu-cts/src/resources/"
108 dst_dir = "$target_gen_dir/../../webgpu-cts/resources/"
109
110 inputs = []
111 outputs = [ "$target_out_dir/run_$target_name.stamp" ]
Kai Ninomiya5c780d72022-03-17 21:43:17 +0000112 foreach(resource_file, resource_file_inputs) {
Ben Clayton2880e5d2023-11-16 17:16:57 +0000113 inputs += [ "$src_dir/$resource_file" ]
114 outputs += [ "$dst_dir/$resource_file" ]
Kai Ninomiya5c780d72022-03-17 21:43:17 +0000115 }
Ben Clayton2880e5d2023-11-16 17:16:57 +0000116 data = outputs
Kai Ninomiya5c780d72022-03-17 21:43:17 +0000117
Ben Clayton2880e5d2023-11-16 17:16:57 +0000118 script = "${dawn_root}/webgpu-cts/scripts/copy_files.py"
119 args = [
120 "--src_dir",
Ben Clayton1d7f1482023-11-20 23:10:57 +0000121 rebase_path(src_dir, root_build_dir),
Ben Clayton2880e5d2023-11-16 17:16:57 +0000122 "--dst_dir",
Ben Clayton1d7f1482023-11-20 23:10:57 +0000123 rebase_path(dst_dir, root_build_dir),
Ben Clayton2880e5d2023-11-16 17:16:57 +0000124 "--file_list",
Ben Clayton1d7f1482023-11-20 23:10:57 +0000125 rebase_path("resource_files.txt", root_build_dir),
Ben Clayton2880e5d2023-11-16 17:16:57 +0000126 "--stamp",
127 rebase_path(outputs[0], root_build_dir),
128 ]
Kai Ninomiya5c780d72022-03-17 21:43:17 +0000129}
130
131action("verify_gen_ts_dep_list") {
Austin Eng1cdea902022-03-24 00:21:55 +0000132 script = "${dawn_root}/webgpu-cts/scripts/gen_ts_dep_lists.py"
Kai Ninomiya5c780d72022-03-17 21:43:17 +0000133 inputs = [
Shrek Shao951d12e2022-04-20 02:34:55 +0000134 "../../../DEPS",
Kai Ninomiya5c780d72022-03-17 21:43:17 +0000135 "resource_files.txt",
136 "ts_sources.txt",
137 ]
138 outputs = [ "$target_out_dir/run_$target_name.stamp" ]
139 args = [
140 "--check",
141 "--stamp",
142 rebase_path(outputs[0], root_build_dir),
143 ]
144}