diff --git a/packages/webgpu/cpp/rnwgpu/api/GPU.h b/packages/webgpu/cpp/rnwgpu/api/GPU.h index 9e79af4a..26c4f6ec 100644 --- a/packages/webgpu/cpp/rnwgpu/api/GPU.h +++ b/packages/webgpu/cpp/rnwgpu/api/GPU.h @@ -27,8 +27,6 @@ namespace m = margelo; class GPU : public m::HybridObject { public: GPU() : HybridObject("GPU") { -// DawnProcTable backendProcs = dawn::native::GetProcs(); -// dawnProcSetProcs(&backendProcs); wgpu::InstanceDescriptor instanceDesc; instanceDesc.features.timedWaitAnyEnable = true; instanceDesc.features.timedWaitAnyMaxCount = 64; diff --git a/packages/webgpu/scripts/build/dawn.ts b/packages/webgpu/scripts/build/dawn.ts index 136c018d..7b1813a5 100644 --- a/packages/webgpu/scripts/build/dawn.ts +++ b/packages/webgpu/scripts/build/dawn.ts @@ -6,17 +6,16 @@ import { chdir } from "process"; import yargs from "yargs"; import { hideBin } from "yargs/helpers"; -import type { Platform } from "./util"; +import type { Platform } from "./dawn-configuration"; +import { $, mapKeys } from "./util"; import { - $, build, checkBuildArtifacts, + copyHeaders, copyLib, libs, - mapKeys, projectRoot, -} from "./util"; -import { copyHeaders } from "./dawn-configuration"; +} from "./dawn-configuration"; const { argv } = yargs(hideBin(process.argv)) .option("exclude", { diff --git a/packages/webgpu/scripts/build/util.ts b/packages/webgpu/scripts/build/util.ts index 776f81be..acaa7a24 100644 --- a/packages/webgpu/scripts/build/util.ts +++ b/packages/webgpu/scripts/build/util.ts @@ -1,24 +1,7 @@ -/* eslint-disable max-len */ import { spawn, execSync } from "child_process"; import { existsSync } from "fs"; import { exit } from "process"; -export const libs = ["libwebgpu_dawn"] as const; - -export const projectRoot = "packages/webgpu"; - -export const platforms = [ - "arm64", - "x86_64", - "x86", - "armeabi-v7a", - "arm64-v8a", - "universal", -] as const; - -export type OS = "apple" | "android"; -export type Platform = (typeof platforms)[number]; - export const runAsync = (command: string, label: string): Promise => { return new Promise((resolve, reject) => { const [cmd, ...args] = command.split(" "); @@ -72,58 +55,3 @@ export const $ = (command: string) => { exit(1); } }; - -const serializeCMakeArgs = (args: Record) => { - return Object.keys(args) - .map((key) => `-D${key}=${args[key]}`) - .join(" "); -}; - -export const build = async ( - label: string, - args: Record, - debugLabel: string, -) => { - console.log(`🔨 Building ${label}`); - $(`mkdir -p externals/dawn/out/${label}`); - process.chdir(`externals/dawn/out/${label}`); - const cmd = `cmake ../.. -G Ninja ${serializeCMakeArgs(args)}`; - await runAsync(cmd, debugLabel); - await runAsync("ninja", debugLabel); - process.chdir("../../../.."); -}; - -export const copyLib = (os: OS, platform: Platform, sdk?: string) => { - const suffix = `${platform}${sdk ? `_${sdk}` : ""}`; - const out = `${os}_${suffix}`; - const dstPath = `${projectRoot}/libs/${os}/${suffix}/`; - $(`mkdir -p ${dstPath}`); - if (os === "android") { - console.log("Strip debug symbols from libwebgpu_dawn.a..."); - $( - `$ANDROID_NDK/toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-strip externals/dawn/out/${out}/src/dawn/native/libwebgpu_dawn.so`, - ); - } - [ - `externals/dawn/out/${out}/src/dawn/native/libwebgpu_dawn.${os === "apple" ? "a" : "so"}`, - ].forEach((lib) => { - const libPath = lib; - console.log(`Copying ${libPath} to ${dstPath}`); - $(`cp ${libPath} ${dstPath}`); - }); -}; - -export const checkBuildArtifacts = () => { - console.log("Check build artifacts..."); - platforms - .filter((arch) => arch !== "arm64" && arch !== "universal") - .forEach((platform) => { - libs.forEach((lib) => { - checkFileExists(`libs/android/${platform}/${lib}.so`); - }); - }); - libs.forEach((lib) => { - checkFileExists(`libs/apple/${lib}.xcframework`); - }); - checkFileExists("libs/dawn.json"); -};