tools: Move idlgen and run-cts to from dawn/node to tools/
This is the standard place for tooling.
Update src/dawn/node/README.md with the new paths, and drop inferred
arguments from the examples.
Change-Id: Ib944ca045366b81b8897d9548112a8889e097769
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/113643
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
index 7c93279..63f39ef 100644
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -114,7 +114,7 @@
"src/dawn/native/metal/BackendMTL.mm", # OSX Constant
"src/dawn/native/vulkan/SamplerVk.cpp", # External URL
"src/dawn/native/vulkan/TextureVk.cpp", # External URL
- "src/dawn/node/tools/src/cmd/run-cts/main.go", # Terminal type name
+ "src/tools/src/cmd/run-cts/main.go", # Terminal type name
"src/dawn/samples/ComputeBoids.cpp", # External URL
"src/dawn/tests/end2end/DepthBiasTests.cpp", # External URL
"src/tint/transform/canonicalize_entry_point_io.cc", # External URL
diff --git a/src/dawn/node/CMakeLists.txt b/src/dawn/node/CMakeLists.txt
index 854c397..ef0d5c2 100644
--- a/src/dawn/node/CMakeLists.txt
+++ b/src/dawn/node/CMakeLists.txt
@@ -13,10 +13,10 @@
# limitations under the License.
set(DAWN_NODE_GEN_DIR "${DAWN_BUILD_GEN_DIR}/node")
-set(IDLGEN_TOOL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/tools/src/cmd/idlgen")
+set(IDLGEN_TOOL_DIR "${CMAKE_SOURCE_DIR}/tools/src/cmd/idlgen")
-# idlgen() is a function that uses the tools/cmd/idlgen/main.go tool to generate
-# code from an IDL file and template.
+# idlgen() is a function that uses the tools/src/cmd/idlgen/main.go tool to
+# generate code from an IDL file and template.
# idlgen() accepts the following named arguments:
# TEMPLATE <path> - (required) the path to the root .tmpl file. If the
# template imports other templates, then these should be
@@ -41,7 +41,7 @@
message(FATAL_ERROR "idlgen() missing IDLS argument(s)")
endif()
add_custom_command(
- COMMAND ${GO_EXECUTABLE} "run" "main.go"
+ COMMAND ${GO_EXECUTABLE} "run" "${IDLGEN_TOOL_DIR}/main.go"
"--template" "${IDLGEN_TEMPLATE}"
"--output" "${IDLGEN_OUTPUT}"
${IDLGEN_IDLS}
diff --git a/src/dawn/node/PRESUBMIT.py b/src/dawn/node/PRESUBMIT.py
deleted file mode 100644
index a37a984..0000000
--- a/src/dawn/node/PRESUBMIT.py
+++ /dev/null
@@ -1,29 +0,0 @@
-# Copyright 2022 The Dawn & Tint Authors
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import sys
-
-USE_PYTHON3 = True
-
-
-def _DoCommonChecks(input_api, output_api):
- sys.path += [input_api.change.RepositoryRoot()]
-
- from go_presubmit_support import RunGoTests
-
- return RunGoTests(input_api, output_api)
-
-
-CheckChangeOnUpload = _DoCommonChecks
-CheckChangeOnCommit = _DoCommonChecks
diff --git a/src/dawn/node/README.md b/src/dawn/node/README.md
index 623d35b..7453e48 100644
--- a/src/dawn/node/README.md
+++ b/src/dawn/node/README.md
@@ -57,15 +57,15 @@
- Run `npm install` from inside the CTS directory to install its dependencies
```sh
-./src/dawn/node/tools/run-cts --cts=<path-to-webgpu-cts> --dawn-node=<path-to-dawn.node> [WebGPU CTS query]
+./src/tools/run run-cts --dawn-node=<path-to-dawn.node> [WebGPU CTS query]
```
If this fails with the error message `TypeError: expander is not a function or its return value is not iterable`, try appending `--build=false` to the start of the `run-cts` command line flags.
-To test against SwiftShader instead of the default Vulkan device, prefix `./src/dawn/node/tools/run-cts` with `VK_ICD_FILENAMES=<swiftshader-cmake-build>/Linux/vk_swiftshader_icd.json` and append `--flag=dawn-backend=vulkan` to the start of run-cts command line flags. For example:
+To test against SwiftShader instead of the default Vulkan device, prefix `./src/tools/run run-cts` with `VK_ICD_FILENAMES=<swiftshader-cmake-build>/Linux/vk_swiftshader_icd.json`. For example:
```sh
-VK_ICD_FILENAMES=<swiftshader-cmake-build>/Linux/vk_swiftshader_icd.json ./src/dawn/node/tools/run-cts --cts=<path-to-webgpu-cts> --dawn-node=<path-to-dawn.node> --flag=dawn-backend=vulkan [WebGPU CTS query]
+VK_ICD_FILENAMES=<swiftshader-cmake-build>/Linux/vk_swiftshader_icd.json ./src/tools/run run-cts --dawn-node=<path-to-dawn.node> [WebGPU CTS query]
```
The `--flag` parameter must be passed in multiple times, once for each flag begin set. Here are some common arguments:
@@ -77,7 +77,7 @@
For example, on Windows, to use the d3dcompiler_47.dll from a Chromium checkout, and to dump shader output, we could run the following using Git Bash:
```sh
-./src/dawn/node/tools/run-cts --verbose --dawn-node=/c/src/dawn/build/Debug/dawn.node --cts=/c/src/webgpu-cts --flag=dlldir="C:\src\chromium\src\out\Release" --flag=enable-dawn-features=dump_shaders 'webgpu:shader,execution,builtin,abs:integer_builtin_functions,abs_unsigned:storageClass="storage";storageMode="read_write";containerType="vector";isAtomic=false;baseType="u32";type="vec2%3Cu32%3E"'
+./src/tools/run run-cts --verbose --dawn-node=/c/src/dawn/build/Debug/dawn.node --cts=/c/src/webgpu-cts --flag=dlldir="C:\src\chromium\src\out\Release" --flag=enable-dawn-features=dump_shaders 'webgpu:shader,execution,builtin,abs:integer_builtin_functions,abs_unsigned:storageClass="storage";storageMode="read_write";containerType="vector";isAtomic=false;baseType="u32";type="vec2%3Cu32%3E"'
```
Note that we pass `--verbose` above so that all test output, including the dumped shader, is written to stdout.
diff --git a/src/dawn/node/interop/WebGPU.cpp.tmpl b/src/dawn/node/interop/WebGPU.cpp.tmpl
index a8f8bc8..491a2f9 100644
--- a/src/dawn/node/interop/WebGPU.cpp.tmpl
+++ b/src/dawn/node/interop/WebGPU.cpp.tmpl
@@ -16,13 +16,13 @@
{{- /*
--------------------------------------------------------------------------------
-Template file for use with src/dawn/node/tools/cmd/idlgen/main.go to generate
-the WebGPU.cpp source file.
+Template file for use with tools/src/cmd/idlgen/main.go to generate the
+WebGPU.cpp source file.
See:
* https://github.com/ben-clayton/webidlparser/blob/main/ast/ast.go for the AST
types used by this template
-* src/dawn/node/tools/cmd/idlgen/main.go for additional structures and functions
+* tools/src/cmd/idlgen/main.go for additional structures and functions
used by this template
* https://golang.org/pkg/text/template/ for documentation on the template syntax
--------------------------------------------------------------------------------
diff --git a/src/dawn/node/interop/WebGPU.h.tmpl b/src/dawn/node/interop/WebGPU.h.tmpl
index eb09690..6025bdd 100644
--- a/src/dawn/node/interop/WebGPU.h.tmpl
+++ b/src/dawn/node/interop/WebGPU.h.tmpl
@@ -16,14 +16,14 @@
{{- /*
--------------------------------------------------------------------------------
-Template file for use with src/dawn/node/tools/cmd/idlgen/main.go to generate
-the WebGPU.h header file.
+Template file for use with tools/src/cmd/idlgen/main.go to generate the
+WebGPU.h header file.
See:
* https://github.com/ben-clayton/webidlparser/blob/main/ast/ast.go for the AST
types used by this template
-* src/dawn/node/tools/cmd/idlgen/main.go for additional structures and functions
- used by this template
+* tools/src/cmd/idlgen/main.go for additional structures and functions used by
+ this template
* https://golang.org/pkg/text/template/ for documentation on the template syntax
--------------------------------------------------------------------------------
*/ -}}
diff --git a/src/dawn/node/interop/WebGPUCommon.tmpl b/src/dawn/node/interop/WebGPUCommon.tmpl
index bf11709..56ee967 100644
--- a/src/dawn/node/interop/WebGPUCommon.tmpl
+++ b/src/dawn/node/interop/WebGPUCommon.tmpl
@@ -16,15 +16,15 @@
{{- /*
--------------------------------------------------------------------------------
-Template file for use with src/dawn/node/tools/cmd/idlgen/main.go.
+Template file for use with tools/src/cmd/idlgen/main.go.
This file provides common template definitions and is included by WebGPU.h.tmpl
and WebGPU.cpp.tmpl.
See:
* https://github.com/ben-clayton/webidlparser/blob/main/ast/ast.go for the AST
types used by this template
-* src/dawn/node/tools/cmd/idlgen/main.go for additional structures and functions
- used by this template
+* tools/src/cmd/idlgen/main.go for additional structures and functions used by
+ this template
* https://golang.org/pkg/text/template/ for documentation on the template syntax
--------------------------------------------------------------------------------
*/ -}}
diff --git a/src/dawn/node/tools/run-cts b/src/dawn/node/tools/run-cts
deleted file mode 100755
index cf58452..0000000
--- a/src/dawn/node/tools/run-cts
+++ /dev/null
@@ -1,33 +0,0 @@
-#!/usr/bin/env bash
-# Copyright 2021 The Tint Authors
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-set -e # Fail on any error.
-
-if [ ! -x "$(which go)" ] ; then
- echo "error: go needs to be on \$PATH to use $0"
- exit 1
-fi
-
-SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd )"
-ROOT_DIR="$( cd "${SCRIPT_DIR}/.." >/dev/null 2>&1 && pwd )"
-BINARY="${SCRIPT_DIR}/bin/run-cts"
-
-# Rebuild the binary.
-# Note, go caches build artifacts, so this is quick for repeat calls
-pushd "${SCRIPT_DIR}/src/cmd/run-cts" > /dev/null
- go build -o "${BINARY}" main.go
-popd > /dev/null
-
-"${BINARY}" "$@"
diff --git a/src/dawn/node/tools/src/cmd/idlgen/main.go b/tools/src/cmd/idlgen/main.go
similarity index 100%
rename from src/dawn/node/tools/src/cmd/idlgen/main.go
rename to tools/src/cmd/idlgen/main.go
diff --git a/src/dawn/node/tools/src/cmd/run-cts/main.go b/tools/src/cmd/run-cts/main.go
similarity index 100%
rename from src/dawn/node/tools/src/cmd/run-cts/main.go
rename to tools/src/cmd/run-cts/main.go