From 89250e0ded24454fd299bdd7ae84e5400e6ba540 Mon Sep 17 00:00:00 2001 From: Willem Wyndham Date: Sat, 5 Sep 2020 13:44:18 -0400 Subject: [PATCH 1/2] fix: allow wat files to be created if no outDir is specified (#6) --- src/cli.ts | 2 +- test/index.ts | 6 +++++- test/wat/asconfig.json | 13 +++++++++++++ test/wat/assembly/index.ts | 3 +++ test/wat/assembly/tsconfig.json | 6 ++++++ test/wat/expected.json | 5 +++++ test/wat/package.json | 7 +++++++ 7 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 test/wat/asconfig.json create mode 100644 test/wat/assembly/index.ts create mode 100644 test/wat/assembly/tsconfig.json create mode 100644 test/wat/expected.json create mode 100644 test/wat/package.json diff --git a/src/cli.ts b/src/cli.ts index 470ca07..13ef637 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -173,7 +173,7 @@ function compileProject( const watFile = path.relative(baseDir, path.join(outDir, name + ".wat")); const wasmFile = path.relative(baseDir, path.join(outDir, name + ".wasm")); - if (args.wat && (args.outDir && !(hasOutput(ascArgv, ".wat") || config.options?.textFile))) { + if (args.wat && (!(hasOutput(ascArgv, ".wat") || config.options?.textFile))) { ascArgv.push("--textFile", watFile); } if (args.outDir || !(hasOutput(ascArgv, ".wasm") || (config.options?.binaryFile))) { diff --git a/test/index.ts b/test/index.ts index ad82b36..cbf9434 100644 --- a/test/index.ts +++ b/test/index.ts @@ -4,6 +4,7 @@ import * as path from "path"; import * as fs from "fs"; let binary: Uint8Array; +let textFile: string; let stderr: string; let args = process.argv.slice(2); @@ -19,6 +20,8 @@ main(args, { mapFiles.set(name, contents); if (name.endsWith(".wasm")) { binary = contents; + } else if (name.endsWith(".wat")) { + textFile = contents; } }, stderr: { @@ -37,6 +40,7 @@ main(args, { const jsonPath = path.join(process.cwd(), "expected.json"); if (fs.existsSync(jsonPath) && stderr) { const actual = JSON.parse(stderr).options; + console.log(actual) const expected = require(jsonPath); let errored = false; for (let name of Object.getOwnPropertyNames(expected)) { @@ -65,7 +69,7 @@ main(args, { } - if (!binary) { + if (!binary && !textFile) { console.error("No binary was generated for the asconfig test in " + process.cwd()); process.exit(1); } diff --git a/test/wat/asconfig.json b/test/wat/asconfig.json new file mode 100644 index 0000000..2eb1a6c --- /dev/null +++ b/test/wat/asconfig.json @@ -0,0 +1,13 @@ +{ + "targets": { + "debug": { + "debug": true + }, + "release": { + "optimize": true + } + }, + "options": { + "noAssert": true + } +} \ No newline at end of file diff --git a/test/wat/assembly/index.ts b/test/wat/assembly/index.ts new file mode 100644 index 0000000..848b176 --- /dev/null +++ b/test/wat/assembly/index.ts @@ -0,0 +1,3 @@ +if (!ASC_NO_ASSERT) { + assert(false, "noAssert should be true"); +} \ No newline at end of file diff --git a/test/wat/assembly/tsconfig.json b/test/wat/assembly/tsconfig.json new file mode 100644 index 0000000..e28fcf2 --- /dev/null +++ b/test/wat/assembly/tsconfig.json @@ -0,0 +1,6 @@ +{ + "extends": "assemblyscript/std/assembly.json", + "include": [ + "./**/*.ts" + ] +} \ No newline at end of file diff --git a/test/wat/expected.json b/test/wat/expected.json new file mode 100644 index 0000000..8d61c70 --- /dev/null +++ b/test/wat/expected.json @@ -0,0 +1,5 @@ +{ + "debug": false, + "optimize": true, + "textFile": "build/release/wat.wat" +} \ No newline at end of file diff --git a/test/wat/package.json b/test/wat/package.json new file mode 100644 index 0000000..f1efaa7 --- /dev/null +++ b/test/wat/package.json @@ -0,0 +1,7 @@ +{ + "name": "wat", + "license": "MIT", + "scripts": { + "test": "ts-node .. --wat -- --showConfig" + } +} From 06ba5c2bcd9135707816a82a59bcc1de4e864475 Mon Sep 17 00:00:00 2001 From: Willem Wyndham Date: Sat, 5 Sep 2020 13:45:42 -0400 Subject: [PATCH 2/2] v0.0.7 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7ec9df6..4e84758 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "asbuild", - "version": "0.0.6", + "version": "0.0.7", "bin": { "asb": "bin/asb" },