diff --git a/scripts/build_instrumentation.js b/scripts/build_instrumentation.js index d79e4fb..9c4dc85 100644 --- a/scripts/build_instrumentation.js +++ b/scripts/build_instrumentation.js @@ -1,5 +1,6 @@ import { execSync } from "node:child_process"; import { existsSync, copyFileSync } from "node:fs"; +import { join, resolve } from "node:path"; const env = process.env; @@ -12,14 +13,15 @@ if (jIndex !== -1 && args[jIndex + 1]) { } function initEmscripten() { - const sdkPath = "third_party/emsdk/"; + const sdkPath = resolve("third_party/emsdk/"); + const emscriptenPath = join(sdkPath, "upstream", "emscripten"); - env["PATH"] = `${sdkPath}:` + env["PATH"]; - if (!existsSync(`${sdkPath}upstream/emscripten`)) { + env["PATH"] += `${process.platform === "win32" ? ";" : ":"}${sdkPath}`; + if (!existsSync(emscriptenPath)) { execSync("emsdk install 3.1.32", { encoding: "utf8", stdio: "inherit", env }); execSync("emsdk activate 3.1.32", { encoding: "utf8", stdio: "inherit", env }); } - env["PATH"] = `${sdkPath}upstream/emscripten:` + env["PATH"]; + env["PATH"] += `${process.platform === "win32" ? ";" : ":"}${emscriptenPath}`; } initEmscripten(); diff --git a/src/core/compile.ts b/src/core/compile.ts index f7b367f..70e4a7e 100644 --- a/src/core/compile.ts +++ b/src/core/compile.ts @@ -36,8 +36,8 @@ function getAscArgs(sources: string[], outputWasm: string, outputWat: string, fl async function unifiedCompile(testCodePaths: string[], option: CompileOption): Promise { const { outputFolder, flags } = option; - const outputWasm = join(outputFolder, "test.wasm"); - const outputWat = join(outputFolder, "test.wat"); + const outputWasm = join(outputFolder, "test.wasm").replaceAll(/\\/g, "/"); + const outputWat = join(outputFolder, "test.wat").replaceAll(/\\/g, "/"); const ascArgv = getAscArgs(testCodePaths, outputWasm, outputWat, flags); await ascMain(ascArgv, false); return outputWasm; diff --git a/src/interface.ts b/src/interface.ts index da44f0e..edc3744 100644 --- a/src/interface.ts +++ b/src/interface.ts @@ -5,13 +5,13 @@ import { Type } from "wasmparser"; import { ASUtil } from "@assemblyscript/loader"; -import path from "node:path"; +import { relative } from "node:path"; // instrumented file information export class InstrumentResult { baseName: string; constructor(baseName: string) { - this.baseName = path.relative(process.cwd(), baseName); + this.baseName = relative(process.cwd(), baseName).replaceAll(/\\/g, "/"); } get sourceWasm() { return this.baseName.concat(".wasm");