Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions scripts/build_instrumentation.js
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions src/core/compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ function getAscArgs(sources: string[], outputWasm: string, outputWat: string, fl

async function unifiedCompile(testCodePaths: string[], option: CompileOption): Promise<string> {
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;
Expand Down
4 changes: 2 additions & 2 deletions src/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down