Skip to content

Commit 33df99c

Browse files
authored
Fix/correct instrumentation filepath for windows (#80)
1 parent 091785f commit 33df99c

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

scripts/build_instrumentation.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { execSync } from "node:child_process";
22
import { existsSync, copyFileSync } from "node:fs";
3+
import { join, resolve } from "node:path";
34

45
const env = process.env;
56

@@ -12,14 +13,15 @@ if (jIndex !== -1 && args[jIndex + 1]) {
1213
}
1314

1415
function initEmscripten() {
15-
const sdkPath = "third_party/emsdk/";
16+
const sdkPath = resolve("third_party/emsdk/");
17+
const emscriptenPath = join(sdkPath, "upstream", "emscripten");
1618

17-
env["PATH"] = `${sdkPath}:` + env["PATH"];
18-
if (!existsSync(`${sdkPath}upstream/emscripten`)) {
19+
env["PATH"] += `${process.platform === "win32" ? ";" : ":"}${sdkPath}`;
20+
if (!existsSync(emscriptenPath)) {
1921
execSync("emsdk install 3.1.32", { encoding: "utf8", stdio: "inherit", env });
2022
execSync("emsdk activate 3.1.32", { encoding: "utf8", stdio: "inherit", env });
2123
}
22-
env["PATH"] = `${sdkPath}upstream/emscripten:` + env["PATH"];
24+
env["PATH"] += `${process.platform === "win32" ? ";" : ":"}${emscriptenPath}`;
2325
}
2426

2527
initEmscripten();

src/core/compile.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ function getAscArgs(sources: string[], outputWasm: string, outputWat: string, fl
3636

3737
async function unifiedCompile(testCodePaths: string[], option: CompileOption): Promise<string> {
3838
const { outputFolder, flags } = option;
39-
const outputWasm = join(outputFolder, "test.wasm");
40-
const outputWat = join(outputFolder, "test.wat");
39+
const outputWasm = join(outputFolder, "test.wasm").replaceAll(/\\/g, "/");
40+
const outputWat = join(outputFolder, "test.wat").replaceAll(/\\/g, "/");
4141
const ascArgv = getAscArgs(testCodePaths, outputWasm, outputWat, flags);
4242
await ascMain(ascArgv, false);
4343
return outputWasm;

src/interface.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55

66
import { Type } from "wasmparser";
77
import { ASUtil } from "@assemblyscript/loader";
8-
import path from "node:path";
8+
import { relative } from "node:path";
99

1010
// instrumented file information
1111
export class InstrumentResult {
1212
baseName: string;
1313
constructor(baseName: string) {
14-
this.baseName = path.relative(process.cwd(), baseName);
14+
this.baseName = relative(process.cwd(), baseName).replaceAll(/\\/g, "/");
1515
}
1616
get sourceWasm() {
1717
return this.baseName.concat(".wasm");

0 commit comments

Comments
 (0)