From 61b5aaccf3c4767cf4cb6e4ef055ca9f95f2c0bf Mon Sep 17 00:00:00 2001 From: Ben Clayton Date: Mon, 12 Dec 2022 23:06:43 +0000 Subject: [PATCH] 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 Reviewed-by: Corentin Wallez Commit-Queue: Ben Clayton --- PRESUBMIT.py | 2 +- src/dawn/node/CMakeLists.txt | 8 ++--- src/dawn/node/PRESUBMIT.py | 29 ---------------- src/dawn/node/README.md | 8 ++--- src/dawn/node/interop/WebGPU.cpp.tmpl | 6 ++-- src/dawn/node/interop/WebGPU.h.tmpl | 8 ++--- src/dawn/node/interop/WebGPUCommon.tmpl | 6 ++-- src/dawn/node/tools/run-cts | 33 ------------------- .../tools => tools}/src/cmd/idlgen/main.go | 0 .../tools => tools}/src/cmd/run-cts/main.go | 0 10 files changed, 19 insertions(+), 81 deletions(-) delete mode 100644 src/dawn/node/PRESUBMIT.py delete mode 100755 src/dawn/node/tools/run-cts rename {src/dawn/node/tools => tools}/src/cmd/idlgen/main.go (100%) rename {src/dawn/node/tools => tools}/src/cmd/run-cts/main.go (100%) diff --git a/PRESUBMIT.py b/PRESUBMIT.py index 7c93279e12..63f39ef81e 100644 --- a/PRESUBMIT.py +++ b/PRESUBMIT.py @@ -114,7 +114,7 @@ def _NonInclusiveFileFilter(file): "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 854c3975d2..ef0d5c24d6 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 - (required) the path to the root .tmpl file. If the # template imports other templates, then these should be @@ -41,7 +41,7 @@ function(idlgen) 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 a37a984520..0000000000 --- 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 623d35bf38..7453e48aea 100644 --- a/src/dawn/node/README.md +++ b/src/dawn/node/README.md @@ -57,15 +57,15 @@ ninja dawn.node - Run `npm install` from inside the CTS directory to install its dependencies ```sh -./src/dawn/node/tools/run-cts --cts= --dawn-node= [WebGPU CTS query] +./src/tools/run run-cts --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=/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=/Linux/vk_swiftshader_icd.json`. For example: ```sh -VK_ICD_FILENAMES=/Linux/vk_swiftshader_icd.json ./src/dawn/node/tools/run-cts --cts= --dawn-node= --flag=dawn-backend=vulkan [WebGPU CTS query] +VK_ICD_FILENAMES=/Linux/vk_swiftshader_icd.json ./src/tools/run run-cts --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 @@ The `--flag` parameter must be passed in multiple times, once for each flag begi 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 a8f8bc8404..491a2f9726 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 eb09690ee0..6025bdd821 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 bf11709e0a..56ee967184 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 cf58452bec..0000000000 --- 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