diff options
author | Aaron O'Mullan <aaron.omullan@gmail.com> | 2022-01-20 15:23:53 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-20 15:23:53 +0100 |
commit | 3ab68bd0a2aff6df12388f2c3b5ed7ae3333a6ca (patch) | |
tree | 9a81824deb4e5a2b29c3eeb5a2adaa3e00720c45 /tools | |
parent | 1cc38f5155bdc5605d74cd959660fa04f782ac63 (diff) |
revert(#13402): experiment: wgpu sync (#13439)
Diffstat (limited to 'tools')
-rw-r--r-- | tools/README.md | 13 | ||||
-rwxr-xr-x | tools/wgpu_sync.js | 90 |
2 files changed, 0 insertions, 103 deletions
diff --git a/tools/README.md b/tools/README.md index 65cff694f..7bdf6f77a 100644 --- a/tools/README.md +++ b/tools/README.md @@ -59,16 +59,3 @@ So you can simply run `./tools/flamebench.js op_baseline bench_op_async` or Tip: the `[bench_filter]` argument doesn't have to be an exact bench name, you can use a shorthand or a partial match to profile a group of benches, e.g: `./tools/flamebench.js de v8` - -## wgpu_sync.js - -`wgpu_sync.js` streamlines updating `deno_webgpu` from -[gfx-rs/wgpu](https://github.com/gfx-rs/wgpu/). - -It essentially vendors the `deno_webgpu` tree with a few minor patches applied -on top, somewhat similar to `git subtree`. - -1. Update `COMMIT` in `./tools/wgpu_sync.js` -2. Run `./tools/wgpu_sync.js` -3. Double check changes, possibly patch -4. Commit & send a PR with the updates diff --git a/tools/wgpu_sync.js b/tools/wgpu_sync.js deleted file mode 100755 index 341cffc71..000000000 --- a/tools/wgpu_sync.js +++ /dev/null @@ -1,90 +0,0 @@ -#!/usr/bin/env -S deno run --unstable --allow-read --allow-write --allow-run -// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. - -import { join, ROOT_PATH } from "./util.js"; - -// const COMMIT = "c00e471274b6c21acda89b4b13d41742c0285d71"; // Release 12 -const COMMIT = "cdd480a89c9e3b681d9d174e65082d2bdbc903ef"; // tip -const REPO = "gfx-rs/wgpu"; -// const V_WGPU = "0.12.0"; -const TARGET_DIR = join(ROOT_PATH, "ext", "webgpu"); - -async function bash(subcmd, opts = {}) { - const p = Deno.run({ ...opts, cmd: ["bash", "-c", subcmd] }); - - // Exit process on failure - const { success, code } = await p.status(); - if (!success) { - Deno.exit(code); - } - // Cleanup - p.close(); -} - -async function clearTargetDir() { - await bash(`rm -r ${TARGET_DIR}/*`); -} - -async function checkoutUpstream() { - // Path of deno_webgpu inside the TAR - const tarPrefix = `gfx-rs-wgpu-${COMMIT.slice(0, 7)}/deno_webgpu/`; - const cmd = - `curl -L https://api.github.com/repos/${REPO}/tarball/${COMMIT} | tar -C '${TARGET_DIR}' -xzvf - --strip=2 '${tarPrefix}'`; - // console.log(cmd); - await bash(cmd); -} - -async function denoCoreVersion() { - const coreCargo = join(ROOT_PATH, "core", "Cargo.toml"); - const contents = await Deno.readTextFile(coreCargo); - return contents.match(/^version = "(\d+\.\d+\.\d+)"$/m)[1]; -} - -async function patchCargo() { - const vDenoCore = await denoCoreVersion(); - - const webgpuCargo = join(ROOT_PATH, "ext", "webgpu", "Cargo.toml"); - const data = await Deno.readTextFile(webgpuCargo); - - // Patch ext/webgpu/Cargo.toml's contents - const patched = data - .replace(`version = "0.17.0"`, `version = "0.33.0"`) - .replace(`edition = "2018"`, `edition = "2021"`) - .replace( - /^deno_core \= .*$/gm, - `deno_core = { version = "${vDenoCore}", path = "../../core" }`, - ) - // .replace(/^wgpu-core \= .*$/gm, `wgpu-core = { version = "${V_WGPU}", features = ["trace", "replay", "serde"] }`) - // .replace(/^wgpu-types \= .*$/gm, `wgpu-types = { version = "${V_WGPU}", features = ["trace", "replay", "serde"] }`) - .replace( - /^wgpu-core \= .*$/gm, - `wgpu-core = { git = "https://github.com/${REPO}", rev = "${COMMIT}", features = ["trace", "replay", "serde"] }`, - ) - .replace( - /^wgpu-types \= .*$/gm, - `wgpu-types = { git = "https://github.com/${REPO}", rev = "${COMMIT}", features = ["trace", "replay", "serde"] }`, - ); - - await Deno.writeTextFile(webgpuCargo, patched); -} - -async function patchSrcLib() { - const srcLib = join(ROOT_PATH, "ext", "webgpu", "src", "lib.rs"); - const data = await Deno.readTextFile(srcLib); - - // Patch ext/webgpu/src/lib.rs's contents - const patched = data - .replace(`prefix "deno:deno_webgpu",`, `prefix "deno:ext/webgpu",`); - - await Deno.writeTextFile(srcLib, patched); -} - -async function main() { - await clearTargetDir(); - await checkoutUpstream(); - await patchCargo(); - await patchSrcLib(); - await bash(join(ROOT_PATH, "tools", "format.js")); -} - -await main(); |