Austin Eng | cc2516a | 2023-10-17 20:57:54 +0000 | [diff] [blame] | 1 | # Copyright 2022 The Dawn & Tint Authors |
Austin Eng | 1cdea90 | 2022-03-24 00:21:55 +0000 | [diff] [blame] | 2 | # |
Austin Eng | cc2516a | 2023-10-17 20:57:54 +0000 | [diff] [blame] | 3 | # Redistribution and use in source and binary forms, with or without |
| 4 | # modification, are permitted provided that the following conditions are met: |
Austin Eng | 1cdea90 | 2022-03-24 00:21:55 +0000 | [diff] [blame] | 5 | # |
Austin Eng | cc2516a | 2023-10-17 20:57:54 +0000 | [diff] [blame] | 6 | # 1. Redistributions of source code must retain the above copyright notice, this |
| 7 | # list of conditions and the following disclaimer. |
Austin Eng | 1cdea90 | 2022-03-24 00:21:55 +0000 | [diff] [blame] | 8 | # |
Austin Eng | cc2516a | 2023-10-17 20:57:54 +0000 | [diff] [blame] | 9 | # 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 Ninomiya | 5c780d7 | 2022-03-17 21:43:17 +0000 | [diff] [blame] | 27 | |
| 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 Eng | 1cdea90 | 2022-03-24 00:21:55 +0000 | [diff] [blame] | 32 | import("../../../scripts/dawn_overrides_with_defaults.gni") |
| 33 | |
Kai Ninomiya | 5c780d7 | 2022-03-17 21:43:17 +0000 | [diff] [blame] | 34 | group("webgpu-cts") { |
| 35 | public_deps = [ |
| 36 | ":compile_src", |
| 37 | ":copy_resources", |
| 38 | ":verify_gen_ts_dep_list", |
| 39 | ] |
Brian Sheedy | ced4c0d | 2022-08-11 15:16:38 +0000 | [diff] [blame] | 40 | data = [ "test_list.txt" ] |
Kai Ninomiya | 5c780d7 | 2022-03-17 21:43:17 +0000 | [diff] [blame] | 41 | } |
| 42 | |
| 43 | list_from_ts_sources_txt = read_file("ts_sources.txt", "list lines") |
| 44 | |
| 45 | ts_source_inputs = [ "../../webgpu-cts/tsconfig.json" ] |
| 46 | foreach(file, list_from_ts_sources_txt) { |
| 47 | ts_source_inputs += [ "../../webgpu-cts/$file" ] |
| 48 | } |
| 49 | |
| 50 | js_outputs = [] |
Austin Eng | 75943c2 | 2022-09-13 22:22:02 +0000 | [diff] [blame] | 51 | foreach(ts_file, filter_exclude(list_from_ts_sources_txt, [ "*.d.ts" ])) { |
Kai Ninomiya | 5c780d7 | 2022-03-17 21:43:17 +0000 | [diff] [blame] | 52 | js_file = string_replace(ts_file, ".ts", ".js") |
Kai Ninomiya | ca296e1 | 2024-04-08 21:20:13 +0000 | [diff] [blame] | 53 | js_node_file = string_replace(js_file, "src/", "src-node/", 1) |
Kai Ninomiya | 5c780d7 | 2022-03-17 21:43:17 +0000 | [diff] [blame] | 54 | |
| 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 Eng | b542f9d | 2022-03-19 00:50:18 +0000 | [diff] [blame] | 59 | 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 Ninomiya | 5c780d7 | 2022-03-17 21:43:17 +0000 | [diff] [blame] | 62 | js_outputs += [ "$target_gen_dir/../../webgpu-cts/$js_node_file" ] |
| 63 | } |
| 64 | } |
Kai Ninomiya | ca296e1 | 2024-04-08 21:20:13 +0000 | [diff] [blame] | 65 | foreach(ts_file, |
| 66 | filter_include(list_from_ts_sources_txt, [ "src/webgpu/*.spec.ts" ])) { |
| 67 | worker_js_file = |
Kai Ninomiya | e3950cb | 2024-07-03 21:45:24 +0000 | [diff] [blame] | 68 | string_replace(string_replace(ts_file, ".spec.ts", ".as_worker.js"), |
Kai Ninomiya | ca296e1 | 2024-04-08 21:20:13 +0000 | [diff] [blame] | 69 | "src/webgpu/", |
| 70 | "src/webgpu/webworker/", |
| 71 | 1) |
| 72 | js_outputs += [ "$target_gen_dir/../../webgpu-cts/$worker_js_file" ] |
| 73 | } |
Kai Ninomiya | 5c780d7 | 2022-03-17 21:43:17 +0000 | [diff] [blame] | 74 | |
| 75 | action("compile_src") { |
Austin Eng | 1cdea90 | 2022-03-24 00:21:55 +0000 | [diff] [blame] | 76 | script = "${dawn_root}/webgpu-cts/scripts/compile_src.py" |
Kai Ninomiya | 5c780d7 | 2022-03-17 21:43:17 +0000 | [diff] [blame] | 77 | |
| 78 | inputs = [ |
| 79 | "//third_party/node/node_modules/typescript/lib/tsc.js", |
| 80 | "//third_party/node/node.py", |
Austin Eng | 1cdea90 | 2022-03-24 00:21:55 +0000 | [diff] [blame] | 81 | "${dawn_root}/webgpu-cts/scripts/tsc_ignore_errors.py", |
Kai Ninomiya | 44f7b8d | 2022-10-05 00:00:05 +0000 | [diff] [blame] | 82 | |
| 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 Ninomiya | 5c780d7 | 2022-03-17 21:43:17 +0000 | [diff] [blame] | 86 | ] + 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 | |
| 94 | list_from_resource_files_txt = read_file("resource_files.txt", "list lines") |
| 95 | resource_file_inputs = [] |
| 96 | foreach(file, list_from_resource_files_txt) { |
| 97 | resource_file_inputs += [ "$file" ] |
| 98 | } |
| 99 | |
Ben Clayton | 2880e5d | 2023-11-16 17:16:57 +0000 | [diff] [blame] | 100 | action("copy_resources") { |
Ben Clayton | 248bad4 | 2023-11-20 22:40:34 +0000 | [diff] [blame] | 101 | # 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 Clayton | 2880e5d | 2023-11-16 17:16:57 +0000 | [diff] [blame] | 107 | 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 Ninomiya | 5c780d7 | 2022-03-17 21:43:17 +0000 | [diff] [blame] | 112 | foreach(resource_file, resource_file_inputs) { |
Ben Clayton | 2880e5d | 2023-11-16 17:16:57 +0000 | [diff] [blame] | 113 | inputs += [ "$src_dir/$resource_file" ] |
| 114 | outputs += [ "$dst_dir/$resource_file" ] |
Kai Ninomiya | 5c780d7 | 2022-03-17 21:43:17 +0000 | [diff] [blame] | 115 | } |
Ben Clayton | 2880e5d | 2023-11-16 17:16:57 +0000 | [diff] [blame] | 116 | data = outputs |
Kai Ninomiya | 5c780d7 | 2022-03-17 21:43:17 +0000 | [diff] [blame] | 117 | |
Ben Clayton | 2880e5d | 2023-11-16 17:16:57 +0000 | [diff] [blame] | 118 | script = "${dawn_root}/webgpu-cts/scripts/copy_files.py" |
| 119 | args = [ |
| 120 | "--src_dir", |
Ben Clayton | 1d7f148 | 2023-11-20 23:10:57 +0000 | [diff] [blame] | 121 | rebase_path(src_dir, root_build_dir), |
Ben Clayton | 2880e5d | 2023-11-16 17:16:57 +0000 | [diff] [blame] | 122 | "--dst_dir", |
Ben Clayton | 1d7f148 | 2023-11-20 23:10:57 +0000 | [diff] [blame] | 123 | rebase_path(dst_dir, root_build_dir), |
Ben Clayton | 2880e5d | 2023-11-16 17:16:57 +0000 | [diff] [blame] | 124 | "--file_list", |
Ben Clayton | 1d7f148 | 2023-11-20 23:10:57 +0000 | [diff] [blame] | 125 | rebase_path("resource_files.txt", root_build_dir), |
Ben Clayton | 2880e5d | 2023-11-16 17:16:57 +0000 | [diff] [blame] | 126 | "--stamp", |
| 127 | rebase_path(outputs[0], root_build_dir), |
| 128 | ] |
Kai Ninomiya | 5c780d7 | 2022-03-17 21:43:17 +0000 | [diff] [blame] | 129 | } |
| 130 | |
| 131 | action("verify_gen_ts_dep_list") { |
Austin Eng | 1cdea90 | 2022-03-24 00:21:55 +0000 | [diff] [blame] | 132 | script = "${dawn_root}/webgpu-cts/scripts/gen_ts_dep_lists.py" |
Kai Ninomiya | 5c780d7 | 2022-03-17 21:43:17 +0000 | [diff] [blame] | 133 | inputs = [ |
Shrek Shao | 951d12e | 2022-04-20 02:34:55 +0000 | [diff] [blame] | 134 | "../../../DEPS", |
Kai Ninomiya | 5c780d7 | 2022-03-17 21:43:17 +0000 | [diff] [blame] | 135 | "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 | } |