@gasm-compiler/cli 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +17 -0
- package/README.md +172 -0
- package/dist/cli.js +309 -0
- package/dist/cli.js.map +1 -0
- package/package.json +49 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
Copyright (c) 2025-present Gasm Compiler Authors
|
|
2
|
+
|
|
3
|
+
All rights reserved.
|
|
4
|
+
|
|
5
|
+
This software and associated documentation files (the "Software") are the
|
|
6
|
+
proprietary property of the copyright holder(s). No permission is granted to
|
|
7
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
8
|
+
of the Software, except as expressly permitted in a separate written license
|
|
9
|
+
agreement with the copyright holder(s).
|
|
10
|
+
|
|
11
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
12
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
13
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
14
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
15
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
16
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
17
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
# Gasm Compiler CLI
|
|
2
|
+
|
|
3
|
+
A Deno-based command-line tool for compiling AssemblyScript to WGSL using the Gasm compiler.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
This CLI tool provides an easy way to:
|
|
8
|
+
|
|
9
|
+
1. **Write AssemblyScript** code (a TypeScript-like subset of WebAssembly)
|
|
10
|
+
2. **Compile to WebAssembly** using the AssemblyScript compiler
|
|
11
|
+
3. **Transform to WGSL** using the Gasm Compiler Gasm compiler
|
|
12
|
+
4. **Execute on GPU** using WebGPU
|
|
13
|
+
|
|
14
|
+
## Quick Start
|
|
15
|
+
|
|
16
|
+
### Prerequisites
|
|
17
|
+
|
|
18
|
+
- [Deno](https://deno.com) installed
|
|
19
|
+
- AssemblyScript installed (or use `npm` within the examples folder)
|
|
20
|
+
|
|
21
|
+
### Usage
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
# Compile AssemblyScript to WASM, then to WGSL
|
|
25
|
+
deno run --allow-all src/cli.ts compile examples/demo.as --output output.wgsl
|
|
26
|
+
|
|
27
|
+
# View help
|
|
28
|
+
deno run --allow-all src/cli.ts --help
|
|
29
|
+
|
|
30
|
+
# Show detailed compiler output
|
|
31
|
+
deno run --allow-all src/cli.ts compile examples/demo.as --verbose
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Project Structure
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
packages/cli/
|
|
38
|
+
├── src/
|
|
39
|
+
│ ├── cli.ts # Main CLI entry point
|
|
40
|
+
│ ├── compiler.ts # Compilation orchestration
|
|
41
|
+
│ └── utils.ts # Utility functions
|
|
42
|
+
├── examples/
|
|
43
|
+
│ ├── package.json # AssemblyScript dependencies
|
|
44
|
+
│ ├── demo.as # Sample AssemblyScript program
|
|
45
|
+
│ └── asconfig.json # AssemblyScript compiler config
|
|
46
|
+
├── deno.json # Deno configuration
|
|
47
|
+
├── package.json # NPM package metadata
|
|
48
|
+
└── README.md # This file
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Example AssemblyScript Programs
|
|
52
|
+
|
|
53
|
+
### Simple Arithmetic
|
|
54
|
+
|
|
55
|
+
The `examples/demo.ts` file contains a basic example showing:
|
|
56
|
+
- Function definitions
|
|
57
|
+
- Integer arithmetic
|
|
58
|
+
- Memory operations
|
|
59
|
+
- Control flow
|
|
60
|
+
|
|
61
|
+
### WASM vs WGSL Execution Comparison
|
|
62
|
+
|
|
63
|
+
The **`examples/simple_math.ts`** and **`examples/compare.ts`** demonstrate 1:1 parity verification:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
# 1. Compile AssemblyScript to WASM
|
|
67
|
+
cd examples && npx asc simple_math.ts -o simple_math.wasm
|
|
68
|
+
|
|
69
|
+
# 2. Run comparison (executes WASM natively and compiles to WGSL)
|
|
70
|
+
cd ../.. && deno run --allow-all --unstable-webgpu packages/cli/examples/compare.ts packages/cli/examples/simple_math.wasm
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
This validates that:
|
|
74
|
+
- ✅ WASM functions produce expected results
|
|
75
|
+
- ✅ WGSL code compiles successfully
|
|
76
|
+
- ✅ Compilation preserves semantics
|
|
77
|
+
|
|
78
|
+
See **[COMPARISON_DEMO.md](examples/COMPARISON_DEMO.md)** for detailed documentation.
|
|
79
|
+
|
|
80
|
+
### Running Examples
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
# Compile and view the WGSL output
|
|
84
|
+
deno run --allow-all src/cli.ts compile examples/demo.as
|
|
85
|
+
|
|
86
|
+
# Save to file
|
|
87
|
+
deno run --allow-all src/cli.ts compile examples/demo.as --output output.wgsl
|
|
88
|
+
|
|
89
|
+
# Verbose output with compilation steps
|
|
90
|
+
deno run --allow-all src/cli.ts compile examples/demo.as --verbose
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## How It Works
|
|
94
|
+
|
|
95
|
+
1. **AssemblyScript Parsing**: Your `.as` file is compiled to WebAssembly using the official AssemblyScript compiler
|
|
96
|
+
2. **Gasm Validation**: The compiler validates that the Wasm conforms to the Gasm specification
|
|
97
|
+
3. **IR Generation**: An intermediate representation is built for analysis and transformation
|
|
98
|
+
4. **WGSL Code Generation**: The IR is transformed into WGSL shader code ready for WebGPU
|
|
99
|
+
|
|
100
|
+
## CLI Options
|
|
101
|
+
|
|
102
|
+
- `compile <input>` - Compile AssemblyScript to WGSL
|
|
103
|
+
- `--output <file>` - Write output to file (default: stdout)
|
|
104
|
+
- `--verbose` - Show detailed compilation steps
|
|
105
|
+
- `--keep-wasm` - Keep intermediate WASM files
|
|
106
|
+
- `--optimize` - Apply optimization passes
|
|
107
|
+
|
|
108
|
+
## Development
|
|
109
|
+
|
|
110
|
+
### Building from Source
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
# No build step needed - Deno runs TypeScript directly
|
|
114
|
+
deno run --allow-all src/cli.ts --version
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Running Tests
|
|
118
|
+
|
|
119
|
+
The CLI uses the core compiler tests. To run all tests:
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
cd ../core
|
|
123
|
+
deno test --allow-all
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## Architecture
|
|
127
|
+
|
|
128
|
+
The CLI integrates with the Gasm Compiler Core compiler:
|
|
129
|
+
|
|
130
|
+
```
|
|
131
|
+
AssemblyScript (.as)
|
|
132
|
+
↓
|
|
133
|
+
ASC Compiler
|
|
134
|
+
↓
|
|
135
|
+
WebAssembly Binary (.wasm)
|
|
136
|
+
↓
|
|
137
|
+
Core Compiler (Gasm)
|
|
138
|
+
├─ Parser
|
|
139
|
+
├─ Validator
|
|
140
|
+
├─ IR Generator
|
|
141
|
+
└─ Code Generator
|
|
142
|
+
↓
|
|
143
|
+
WGSL Code (.wgsl)
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## Testing
|
|
147
|
+
# Compiler tests (WASM → WGSL compilation)
|
|
148
|
+
deno test --allow-all tests/compiler_test.ts
|
|
149
|
+
|
|
150
|
+
# CLI integration tests (command parsing, help, etc.)
|
|
151
|
+
deno test --allow-all tests/cli_test.ts
|
|
152
|
+
|
|
153
|
+
# GPU execution tests (requires WebGPU support)
|
|
154
|
+
deno test --allow-all --unstable-webgpu tests/execution_test.ts
|
|
155
|
+
|
|
156
|
+
## Future Plans
|
|
157
|
+
|
|
158
|
+
- [ ] Web-based REPL for interactive compilation
|
|
159
|
+
- [ ] Inline WASM binary support
|
|
160
|
+
- [ ] Multiple output formats (WGSL, IR, debug info)
|
|
161
|
+
- [ ] Performance profiling and optimization suggestions
|
|
162
|
+
- [ ] Integration with gpu.js or wgpu for execution
|
|
163
|
+
|
|
164
|
+
## Related Documentation
|
|
165
|
+
|
|
166
|
+
- [Core Compiler Documentation](../core/README.md)
|
|
167
|
+
- [Gasm Specification](../../spec/gasm-v0.1.md)
|
|
168
|
+
- [AssemblyScript Handbook](https://www.assemblyscript.org/)
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
**Status**: Early development | **Last Updated**: December 2025
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
// Gasm Compiler CLI — requires Deno runtime
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
// src/cli.ts
|
|
6
|
+
import { parseArgs } from "jsr:@std/cli/parse-args";
|
|
7
|
+
|
|
8
|
+
// src/compiler.ts
|
|
9
|
+
import { resolve } from "jsr:@std/path";
|
|
10
|
+
import { ensureFile } from "jsr:@std/fs";
|
|
11
|
+
import {
|
|
12
|
+
compileWithDiagnostics,
|
|
13
|
+
disassembleToWAT,
|
|
14
|
+
parseWasmModule,
|
|
15
|
+
isParseError
|
|
16
|
+
} from "@gasm-compiler/core";
|
|
17
|
+
function printDiagnostics(diagnostics, verbose) {
|
|
18
|
+
for (const w of diagnostics.warnings) {
|
|
19
|
+
const where = w.functionName ? ` (${w.functionName})` : "";
|
|
20
|
+
console.error(`warning${where}: ${w.message}`);
|
|
21
|
+
}
|
|
22
|
+
if (verbose && diagnostics.demotions.length > 0) {
|
|
23
|
+
const counts = /* @__PURE__ */ new Map();
|
|
24
|
+
for (const d of diagnostics.demotions) {
|
|
25
|
+
counts.set(d.kind, (counts.get(d.kind) ?? 0) + 1);
|
|
26
|
+
}
|
|
27
|
+
const parts = [...counts.entries()].map(([kind, count]) => `${kind} (${count})`);
|
|
28
|
+
console.error(`demotions: ${parts.join(", ")}`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
async function compileAssemblyScriptToWGSL(inputFile, options = {}) {
|
|
32
|
+
const {
|
|
33
|
+
output: outputFile,
|
|
34
|
+
watOutput: watOutputFile,
|
|
35
|
+
verbose = false,
|
|
36
|
+
keepWasm = false,
|
|
37
|
+
optimize = false,
|
|
38
|
+
denyF64Demotion = false,
|
|
39
|
+
allowI64Demotion = false,
|
|
40
|
+
warningsAsErrors = false,
|
|
41
|
+
sourceMapping
|
|
42
|
+
} = options;
|
|
43
|
+
try {
|
|
44
|
+
if (verbose) console.log(`[1/4] Validating input file: ${inputFile}`);
|
|
45
|
+
const resolvedInput = resolve(inputFile);
|
|
46
|
+
const stats = await Deno.stat(resolvedInput);
|
|
47
|
+
if (!stats.isFile) {
|
|
48
|
+
throw new Error(`Not a file: ${inputFile}`);
|
|
49
|
+
}
|
|
50
|
+
const isWasm = resolvedInput.endsWith(".wasm");
|
|
51
|
+
if (!isWasm && !resolvedInput.endsWith(".as") && !resolvedInput.endsWith(".ts")) {
|
|
52
|
+
console.warn("Warning: Input file does not have .as, .ts, or .wasm extension");
|
|
53
|
+
}
|
|
54
|
+
let wasmPath = resolvedInput.replace(/\.(as|ts)$/, ".wasm");
|
|
55
|
+
if (!isWasm) {
|
|
56
|
+
if (verbose) console.log("[2/4] Compiling AssemblyScript to WASM...");
|
|
57
|
+
const asmPath = await getAssemblyScriptPath();
|
|
58
|
+
let inputForAsc = resolvedInput;
|
|
59
|
+
let cleanupTsFile = false;
|
|
60
|
+
if (resolvedInput.endsWith(".as")) {
|
|
61
|
+
inputForAsc = resolvedInput.replace(/\.as$/, ".ts");
|
|
62
|
+
cleanupTsFile = true;
|
|
63
|
+
try {
|
|
64
|
+
await Deno.symlink(resolvedInput, inputForAsc);
|
|
65
|
+
} catch (e) {
|
|
66
|
+
if (!(e instanceof Deno.errors.AlreadyExists)) {
|
|
67
|
+
const content = await Deno.readTextFile(resolvedInput);
|
|
68
|
+
await Deno.writeTextFile(inputForAsc, content);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
const compileCommand = new Deno.Command(asmPath, {
|
|
73
|
+
args: [inputForAsc, "-o", wasmPath],
|
|
74
|
+
stdout: "piped",
|
|
75
|
+
stderr: "piped"
|
|
76
|
+
});
|
|
77
|
+
const compileProcess = compileCommand.spawn();
|
|
78
|
+
const { success, stdout, stderr } = await compileProcess.output();
|
|
79
|
+
if (cleanupTsFile) {
|
|
80
|
+
try {
|
|
81
|
+
await Deno.remove(inputForAsc);
|
|
82
|
+
} catch {
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (!success) {
|
|
86
|
+
const errorMsg = new TextDecoder().decode(stderr);
|
|
87
|
+
throw new Error(`AssemblyScript compilation failed:
|
|
88
|
+
${errorMsg}`);
|
|
89
|
+
}
|
|
90
|
+
if (verbose) {
|
|
91
|
+
const output = new TextDecoder().decode(stdout);
|
|
92
|
+
if (output) console.log(output);
|
|
93
|
+
}
|
|
94
|
+
} else {
|
|
95
|
+
if (verbose) console.log("[2/4] Input is WASM, skipping compilation...");
|
|
96
|
+
wasmPath = resolvedInput;
|
|
97
|
+
}
|
|
98
|
+
if (verbose) console.log("[3/4] Reading WASM binary...");
|
|
99
|
+
const wasmBytes = await Deno.readFile(wasmPath);
|
|
100
|
+
if (verbose) {
|
|
101
|
+
console.log(` WASM size: ${wasmBytes.length} bytes`);
|
|
102
|
+
console.log("[4/4] Compiling WASM to WGSL using Gasm...");
|
|
103
|
+
}
|
|
104
|
+
const demotionPolicy = {};
|
|
105
|
+
if (denyF64Demotion) demotionPolicy.f64 = "deny";
|
|
106
|
+
if (allowI64Demotion) demotionPolicy.i64 = "allow-lossy";
|
|
107
|
+
const validLevels = ["none", "minimal", "normal", "detailed", "verbose"];
|
|
108
|
+
let sourceMappingLevel;
|
|
109
|
+
if (sourceMapping) {
|
|
110
|
+
if (validLevels.includes(sourceMapping)) {
|
|
111
|
+
sourceMappingLevel = sourceMapping;
|
|
112
|
+
} else {
|
|
113
|
+
console.warn(`Warning: Unknown source-mapping level "${sourceMapping}", using "normal"`);
|
|
114
|
+
sourceMappingLevel = "normal";
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
const result = compileWithDiagnostics(wasmBytes, {
|
|
118
|
+
optimize,
|
|
119
|
+
demotionPolicy,
|
|
120
|
+
warningsAsErrors,
|
|
121
|
+
sourceMapping: sourceMappingLevel
|
|
122
|
+
});
|
|
123
|
+
printDiagnostics(result.diagnostics, verbose);
|
|
124
|
+
if (!result.ok) {
|
|
125
|
+
const first = result.diagnostics.errors[0];
|
|
126
|
+
throw new Error(first?.message ?? "Compilation failed");
|
|
127
|
+
}
|
|
128
|
+
const wgslCode = result.wgsl;
|
|
129
|
+
if (watOutputFile) {
|
|
130
|
+
if (verbose) console.log("[4a/4] Generating WAT disassembly...");
|
|
131
|
+
const parseResult = parseWasmModule(wasmBytes);
|
|
132
|
+
if (!isParseError(parseResult)) {
|
|
133
|
+
const watCode = disassembleToWAT(parseResult);
|
|
134
|
+
const resolvedWatOutput = resolve(watOutputFile);
|
|
135
|
+
await ensureFile(resolvedWatOutput);
|
|
136
|
+
await Deno.writeTextFile(resolvedWatOutput, watCode);
|
|
137
|
+
if (verbose) {
|
|
138
|
+
console.log(`\u2713 WAT disassembly written to: ${resolvedWatOutput}`);
|
|
139
|
+
} else {
|
|
140
|
+
console.log(`\u2713 WAT written to: ${watOutputFile}`);
|
|
141
|
+
}
|
|
142
|
+
} else {
|
|
143
|
+
console.warn(`Warning: Failed to parse WASM for WAT disassembly: ${parseResult.message}`);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
if (outputFile) {
|
|
147
|
+
const resolvedOutput = resolve(outputFile);
|
|
148
|
+
await ensureFile(resolvedOutput);
|
|
149
|
+
await Deno.writeTextFile(resolvedOutput, wgslCode);
|
|
150
|
+
if (verbose) {
|
|
151
|
+
console.log(`\u2713 Successfully compiled to: ${resolvedOutput}`);
|
|
152
|
+
} else {
|
|
153
|
+
console.log(`\u2713 Compiled to: ${outputFile}`);
|
|
154
|
+
}
|
|
155
|
+
} else {
|
|
156
|
+
console.log(wgslCode);
|
|
157
|
+
}
|
|
158
|
+
if (!keepWasm && !isWasm) {
|
|
159
|
+
try {
|
|
160
|
+
await Deno.remove(wasmPath);
|
|
161
|
+
if (verbose) console.log(" Cleaned up intermediate WASM file");
|
|
162
|
+
} catch {
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
} catch (error) {
|
|
166
|
+
if (error instanceof Error) {
|
|
167
|
+
throw error;
|
|
168
|
+
}
|
|
169
|
+
throw new Error(`Unknown error: ${String(error)}`);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
async function getAssemblyScriptPath() {
|
|
173
|
+
const scriptDir = new URL(".", import.meta.url).pathname;
|
|
174
|
+
const possiblePaths = [
|
|
175
|
+
// Relative to CLI package
|
|
176
|
+
resolve(scriptDir, "../../node_modules/.bin/asc"),
|
|
177
|
+
resolve(scriptDir, "../../node_modules/.pnpm/assemblyscript@0.28.9/node_modules/assemblyscript/node_modules/.bin/asc"),
|
|
178
|
+
resolve(scriptDir, "../node_modules/.bin/asc"),
|
|
179
|
+
resolve(scriptDir, "../examples/node_modules/.bin/asc"),
|
|
180
|
+
// Relative to workspace root
|
|
181
|
+
resolve(scriptDir, "../../node_modules/.bin/asc"),
|
|
182
|
+
resolve(scriptDir, "../../../node_modules/.bin/asc"),
|
|
183
|
+
// AssemblyScript toy example
|
|
184
|
+
resolve(scriptDir, "../../assemblyscript-toy/node_modules/.bin/asc")
|
|
185
|
+
];
|
|
186
|
+
for (const path of possiblePaths) {
|
|
187
|
+
try {
|
|
188
|
+
const stat = await Deno.stat(path);
|
|
189
|
+
if (stat.isFile) {
|
|
190
|
+
return path;
|
|
191
|
+
}
|
|
192
|
+
} catch {
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
return "asc";
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// src/cli.ts
|
|
199
|
+
var VERSION = "0.1.0";
|
|
200
|
+
async function main() {
|
|
201
|
+
const args = parseArgs(Deno.args, {
|
|
202
|
+
string: ["output", "wat-output", "source-mapping"],
|
|
203
|
+
boolean: [
|
|
204
|
+
"help",
|
|
205
|
+
"version",
|
|
206
|
+
"verbose",
|
|
207
|
+
"keep-wasm",
|
|
208
|
+
"optimize",
|
|
209
|
+
"deny-f64-demotion",
|
|
210
|
+
"allow-i64-demotion",
|
|
211
|
+
"warnings-as-errors"
|
|
212
|
+
],
|
|
213
|
+
default: {
|
|
214
|
+
verbose: false,
|
|
215
|
+
"keep-wasm": false,
|
|
216
|
+
optimize: false
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
if (args.version) {
|
|
220
|
+
console.log(`Gasm Compiler CLI v${VERSION}`);
|
|
221
|
+
Deno.exit(0);
|
|
222
|
+
}
|
|
223
|
+
if (args.help || args._.length === 0) {
|
|
224
|
+
printHelp();
|
|
225
|
+
Deno.exit(args.help ? 0 : 1);
|
|
226
|
+
}
|
|
227
|
+
const command = args._[0];
|
|
228
|
+
try {
|
|
229
|
+
if (command === "compile") {
|
|
230
|
+
if (args._.length < 2) {
|
|
231
|
+
console.error("Error: compile requires an input file");
|
|
232
|
+
console.error("Usage: cli compile <input.as|wasm> [--output <output.wgsl>]");
|
|
233
|
+
Deno.exit(1);
|
|
234
|
+
}
|
|
235
|
+
const inputFile = args._[1];
|
|
236
|
+
const options = {
|
|
237
|
+
output: args.output,
|
|
238
|
+
watOutput: args["wat-output"],
|
|
239
|
+
verbose: args.verbose,
|
|
240
|
+
keepWasm: args["keep-wasm"],
|
|
241
|
+
optimize: args.optimize,
|
|
242
|
+
denyF64Demotion: args["deny-f64-demotion"],
|
|
243
|
+
allowI64Demotion: args["allow-i64-demotion"],
|
|
244
|
+
warningsAsErrors: args["warnings-as-errors"],
|
|
245
|
+
sourceMapping: args["source-mapping"]
|
|
246
|
+
};
|
|
247
|
+
await compileAssemblyScriptToWGSL(inputFile, options);
|
|
248
|
+
} else {
|
|
249
|
+
console.error(`Unknown command: ${command}`);
|
|
250
|
+
printHelp();
|
|
251
|
+
Deno.exit(1);
|
|
252
|
+
}
|
|
253
|
+
} catch (error) {
|
|
254
|
+
console.error("Error:", error instanceof Error ? error.message : String(error));
|
|
255
|
+
if (args.verbose && error instanceof Error && error.stack) {
|
|
256
|
+
console.error("\nStack trace:");
|
|
257
|
+
console.error(error.stack);
|
|
258
|
+
}
|
|
259
|
+
Deno.exit(1);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
function printHelp() {
|
|
263
|
+
console.log(`
|
|
264
|
+
Gasm Compiler CLI v${VERSION}
|
|
265
|
+
Compile WebAssembly or AssemblyScript to WGSL using the Gasm compiler
|
|
266
|
+
|
|
267
|
+
USAGE:
|
|
268
|
+
gasm-compiler <COMMAND> [OPTIONS] [ARGS]
|
|
269
|
+
|
|
270
|
+
COMMANDS:
|
|
271
|
+
compile <input.wasm|.as> Compile WebAssembly or AssemblyScript to WGSL
|
|
272
|
+
help Show this help message
|
|
273
|
+
version Show version information
|
|
274
|
+
|
|
275
|
+
OPTIONS:
|
|
276
|
+
--output <file> Write WGSL output to file (default: stdout)
|
|
277
|
+
--wat-output <file> Also write WAT (WebAssembly Text) disassembly to file
|
|
278
|
+
--verbose Show detailed compilation steps
|
|
279
|
+
--keep-wasm Keep intermediate WASM files
|
|
280
|
+
--optimize Apply optimization passes
|
|
281
|
+
--deny-f64-demotion Fail if f64 would be demoted to f32
|
|
282
|
+
--allow-i64-demotion Allow lossy i64\u2192i32 demotion (mod 2^32)
|
|
283
|
+
--warnings-as-errors Treat compiler warnings as errors
|
|
284
|
+
--source-mapping <level> Add source mapping comments (none, minimal, normal, detailed, verbose)
|
|
285
|
+
--help Show this help message
|
|
286
|
+
--version Show version information
|
|
287
|
+
|
|
288
|
+
EXAMPLES:
|
|
289
|
+
# Compile WASM to stdout
|
|
290
|
+
deno run --allow-all src/cli.ts compile input.wasm
|
|
291
|
+
|
|
292
|
+
# Compile WASM to file
|
|
293
|
+
deno run --allow-all src/cli.ts compile input.wasm --output output.wgsl
|
|
294
|
+
|
|
295
|
+
# Compile with verbose output
|
|
296
|
+
deno run --allow-all src/cli.ts compile input.wasm --verbose --output output.wgsl
|
|
297
|
+
|
|
298
|
+
# Compile with optimization
|
|
299
|
+
deno run --allow-all src/cli.ts compile input.wasm --optimize --output output.wgsl
|
|
300
|
+
|
|
301
|
+
DOCUMENTATION:
|
|
302
|
+
https://github.com/MartinEricsson/gasm-compiler
|
|
303
|
+
`);
|
|
304
|
+
}
|
|
305
|
+
main().catch((error) => {
|
|
306
|
+
console.error("Fatal error:", error);
|
|
307
|
+
Deno.exit(1);
|
|
308
|
+
});
|
|
309
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cli.ts","../src/compiler.ts"],"sourcesContent":["/**\n * Gasm Compiler CLI - Main Entry Point\n *\n * Provides a command-line interface for compiling AssemblyScript to WGSL\n * using the Gasm compiler.\n */\n\nimport { parseArgs } from \"jsr:@std/cli/parse-args\";\nimport { compileAssemblyScriptToWGSL } from \"./compiler.ts\";\n\nconst VERSION = \"0.1.0\";\n\ninterface CLIOptions {\n help?: boolean;\n version?: boolean;\n output?: string;\n \"wat-output\"?: string;\n verbose?: boolean;\n \"keep-wasm\"?: boolean;\n optimize?: boolean;\n \"deny-f64-demotion\"?: boolean;\n \"allow-i64-demotion\"?: boolean;\n \"warnings-as-errors\"?: boolean;\n \"source-mapping\"?: string;\n _: string[];\n}\n\nasync function main() {\n const args = parseArgs(Deno.args, {\n string: [\"output\", \"wat-output\", \"source-mapping\"],\n boolean: [\n \"help\",\n \"version\",\n \"verbose\",\n \"keep-wasm\",\n \"optimize\",\n \"deny-f64-demotion\",\n \"allow-i64-demotion\",\n \"warnings-as-errors\",\n ],\n default: {\n verbose: false,\n \"keep-wasm\": false,\n optimize: false,\n },\n }) as CLIOptions;\n\n // Handle --version\n if (args.version) {\n console.log(`Gasm Compiler CLI v${VERSION}`);\n Deno.exit(0);\n }\n\n // Handle --help or no command\n if (args.help || args._.length === 0) {\n printHelp();\n Deno.exit(args.help ? 0 : 1);\n }\n\n const command = args._[0];\n\n try {\n if (command === \"compile\") {\n if (args._.length < 2) {\n console.error(\"Error: compile requires an input file\");\n console.error(\"Usage: cli compile <input.as|wasm> [--output <output.wgsl>]\");\n Deno.exit(1);\n }\n\n const inputFile = args._[1] as string;\n const options = {\n output: args.output as string | undefined,\n watOutput: args[\"wat-output\"] as string | undefined,\n verbose: args.verbose as boolean,\n keepWasm: args[\"keep-wasm\"] as boolean,\n optimize: args.optimize as boolean,\n denyF64Demotion: args[\"deny-f64-demotion\"] as boolean,\n allowI64Demotion: args[\"allow-i64-demotion\"] as boolean,\n warningsAsErrors: args[\"warnings-as-errors\"] as boolean,\n sourceMapping: args[\"source-mapping\"] as string | undefined,\n };\n\n await compileAssemblyScriptToWGSL(inputFile, options);\n } else {\n console.error(`Unknown command: ${command}`);\n printHelp();\n Deno.exit(1);\n }\n } catch (error) {\n console.error(\"Error:\", error instanceof Error ? error.message : String(error));\n if (args.verbose && error instanceof Error && error.stack) {\n console.error(\"\\nStack trace:\");\n console.error(error.stack);\n }\n Deno.exit(1);\n }\n}\n\nfunction printHelp() {\n console.log(`\nGasm Compiler CLI v${VERSION}\nCompile WebAssembly or AssemblyScript to WGSL using the Gasm compiler\n\nUSAGE:\n gasm-compiler <COMMAND> [OPTIONS] [ARGS]\n\nCOMMANDS:\n compile <input.wasm|.as> Compile WebAssembly or AssemblyScript to WGSL\n help Show this help message\n version Show version information\n\nOPTIONS:\n --output <file> Write WGSL output to file (default: stdout)\n --wat-output <file> Also write WAT (WebAssembly Text) disassembly to file\n --verbose Show detailed compilation steps\n --keep-wasm Keep intermediate WASM files\n --optimize Apply optimization passes\n --deny-f64-demotion Fail if f64 would be demoted to f32\n --allow-i64-demotion Allow lossy i64→i32 demotion (mod 2^32)\n --warnings-as-errors Treat compiler warnings as errors\n --source-mapping <level> Add source mapping comments (none, minimal, normal, detailed, verbose)\n --help Show this help message\n --version Show version information\n\nEXAMPLES:\n # Compile WASM to stdout\n deno run --allow-all src/cli.ts compile input.wasm\n\n # Compile WASM to file\n deno run --allow-all src/cli.ts compile input.wasm --output output.wgsl\n\n # Compile with verbose output\n deno run --allow-all src/cli.ts compile input.wasm --verbose --output output.wgsl\n\n # Compile with optimization\n deno run --allow-all src/cli.ts compile input.wasm --optimize --output output.wgsl\n\nDOCUMENTATION:\n https://github.com/MartinEricsson/gasm-compiler\n `);\n}\n\n// Run main\nmain().catch((error) => {\n console.error(\"Fatal error:\", error);\n Deno.exit(1);\n});\n","/**\n * Gasm Compiler CLI - Compilation Orchestration\n *\n * Handles the compilation pipeline:\n * AssemblyScript → WASM → Gasm Validation → IR → WGSL\n * \n * Note: This Deno-based CLI wrapper will be deprecated in favor of\n * the Node.js compiler exported from @gasm-compiler/core/compiler\n */\n\nimport { resolve } from \"jsr:@std/path\";\nimport { ensureFile } from \"jsr:@std/fs\";\nimport { \n compileWithDiagnostics, \n disassembleToWAT,\n parseWasmModule,\n isParseError,\n type CompileDiagnostics \n} from \"@gasm-compiler/core\";\n\nexport interface CompileOptions {\n output?: string;\n watOutput?: string;\n verbose?: boolean;\n keepWasm?: boolean;\n optimize?: boolean;\n denyF64Demotion?: boolean;\n allowI64Demotion?: boolean;\n warningsAsErrors?: boolean;\n sourceMapping?: string;\n}\n\nfunction printDiagnostics(diagnostics: CompileDiagnostics, verbose: boolean): void {\n for (const w of diagnostics.warnings) {\n const where = w.functionName ? ` (${w.functionName})` : \"\";\n console.error(`warning${where}: ${w.message}`);\n }\n\n if (verbose && diagnostics.demotions.length > 0) {\n const counts = new Map<string, number>();\n for (const d of diagnostics.demotions) {\n counts.set(d.kind, (counts.get(d.kind) ?? 0) + 1);\n }\n const parts = [...counts.entries()].map(([kind, count]) => `${kind} (${count})`);\n console.error(`demotions: ${parts.join(\", \")}`);\n }\n}\n\n/**\n * Compiles an AssemblyScript file to WGSL using the Gasm compiler.\n *\n * Pipeline:\n * 1. Validate input file exists\n * 2. Compile AssemblyScript to WASM using asc\n * 3. Read WASM binary\n * 4. Compile WASM to WGSL using Gasm\n * 5. Write output to file or stdout\n *\n * @param inputFile - Path to .as file\n * @param options - Compilation options\n */\nexport async function compileAssemblyScriptToWGSL(\n inputFile: string,\n options: CompileOptions = {},\n) {\n const {\n output: outputFile,\n watOutput: watOutputFile,\n verbose = false,\n keepWasm = false,\n optimize = false,\n denyF64Demotion = false,\n allowI64Demotion = false,\n warningsAsErrors = false,\n sourceMapping,\n } = options;\n\n try {\n // 1. Validate input file\n if (verbose) console.log(`[1/4] Validating input file: ${inputFile}`);\n\n const resolvedInput = resolve(inputFile);\n const stats = await Deno.stat(resolvedInput);\n\n if (!stats.isFile) {\n throw new Error(`Not a file: ${inputFile}`);\n }\n\n const isWasm = resolvedInput.endsWith(\".wasm\");\n\n if (!isWasm && !resolvedInput.endsWith(\".as\") && !resolvedInput.endsWith(\".ts\")) {\n console.warn(\"Warning: Input file does not have .as, .ts, or .wasm extension\");\n }\n\n let wasmPath = resolvedInput.replace(/\\.(as|ts)$/, \".wasm\");\n\n // 2. Compile AssemblyScript to WASM (if input is not already WASM)\n if (!isWasm) {\n if (verbose) console.log(\"[2/4] Compiling AssemblyScript to WASM...\");\n\n const asmPath = await getAssemblyScriptPath();\n\n // If input ends with .as, create a temporary .ts file for asc\n // (asc appends .ts to .as files, causing lookup failures)\n let inputForAsc = resolvedInput;\n let cleanupTsFile = false;\n\n if (resolvedInput.endsWith(\".as\")) {\n inputForAsc = resolvedInput.replace(/\\.as$/, \".ts\");\n cleanupTsFile = true;\n\n try {\n // Create a symlink from .as to .ts\n await Deno.symlink(resolvedInput, inputForAsc);\n } catch (e) {\n if (!(e instanceof Deno.errors.AlreadyExists)) {\n // If symlink fails for other reasons, copy the file instead\n const content = await Deno.readTextFile(resolvedInput);\n await Deno.writeTextFile(inputForAsc, content);\n }\n }\n }\n\n const compileCommand = new Deno.Command(asmPath, {\n args: [inputForAsc, \"-o\", wasmPath],\n stdout: \"piped\",\n stderr: \"piped\",\n });\n\n const compileProcess = compileCommand.spawn();\n const { success, stdout, stderr } = await compileProcess.output();\n\n // Clean up temporary .ts file if we created it\n if (cleanupTsFile) {\n try {\n await Deno.remove(inputForAsc);\n } catch {\n // Ignore cleanup errors\n }\n }\n\n if (!success) {\n const errorMsg = new TextDecoder().decode(stderr);\n throw new Error(`AssemblyScript compilation failed:\\n${errorMsg}`);\n }\n\n if (verbose) {\n const output = new TextDecoder().decode(stdout);\n if (output) console.log(output);\n }\n } else {\n if (verbose) console.log(\"[2/4] Input is WASM, skipping compilation...\");\n wasmPath = resolvedInput;\n }\n\n // 3. Read WASM binary and compile to WGSL\n if (verbose) console.log(\"[3/4] Reading WASM binary...\");\n\n const wasmBytes = await Deno.readFile(wasmPath);\n\n if (verbose) {\n console.log(` WASM size: ${wasmBytes.length} bytes`);\n console.log(\"[4/4] Compiling WASM to WGSL using Gasm...\");\n }\n\n const demotionPolicy: {\n f64?: \"allow\" | \"deny\";\n i64?: \"deny\" | \"allow-lossy\";\n } = {};\n if (denyF64Demotion) demotionPolicy.f64 = \"deny\";\n if (allowI64Demotion) demotionPolicy.i64 = \"allow-lossy\";\n\n // Parse source mapping level\n type SourceMappingLevel = \"none\" | \"minimal\" | \"normal\" | \"detailed\" | \"verbose\";\n const validLevels: SourceMappingLevel[] = [\"none\", \"minimal\", \"normal\", \"detailed\", \"verbose\"];\n let sourceMappingLevel: SourceMappingLevel | undefined;\n if (sourceMapping) {\n if (validLevels.includes(sourceMapping as SourceMappingLevel)) {\n sourceMappingLevel = sourceMapping as SourceMappingLevel;\n } else {\n console.warn(`Warning: Unknown source-mapping level \"${sourceMapping}\", using \"normal\"`);\n sourceMappingLevel = \"normal\";\n }\n }\n\n const result = compileWithDiagnostics(wasmBytes, {\n optimize,\n demotionPolicy,\n warningsAsErrors,\n sourceMapping: sourceMappingLevel,\n });\n\n printDiagnostics(result.diagnostics, verbose);\n\n if (!result.ok) {\n const first = result.diagnostics.errors[0];\n throw new Error(first?.message ?? \"Compilation failed\");\n }\n\n const wgslCode = result.wgsl;\n\n // 4. Generate WAT disassembly if requested\n if (watOutputFile) {\n if (verbose) console.log(\"[4a/4] Generating WAT disassembly...\");\n \n // Parse the WASM to get the module structure\n const parseResult = parseWasmModule(wasmBytes);\n \n // Check if parsing succeeded\n if (!isParseError(parseResult)) {\n const watCode = disassembleToWAT(parseResult);\n const resolvedWatOutput = resolve(watOutputFile);\n await ensureFile(resolvedWatOutput);\n await Deno.writeTextFile(resolvedWatOutput, watCode);\n \n if (verbose) {\n console.log(`✓ WAT disassembly written to: ${resolvedWatOutput}`);\n } else {\n console.log(`✓ WAT written to: ${watOutputFile}`);\n }\n } else {\n console.warn(`Warning: Failed to parse WASM for WAT disassembly: ${parseResult.message}`);\n }\n }\n\n // 5. Write WGSL output\n if (outputFile) {\n const resolvedOutput = resolve(outputFile);\n await ensureFile(resolvedOutput);\n await Deno.writeTextFile(resolvedOutput, wgslCode);\n\n if (verbose) {\n console.log(`✓ Successfully compiled to: ${resolvedOutput}`);\n } else {\n console.log(`✓ Compiled to: ${outputFile}`);\n }\n } else {\n console.log(wgslCode);\n }\n\n // Clean up intermediate WASM if not keeping (and we generated it)\n if (!keepWasm && !isWasm) {\n try {\n await Deno.remove(wasmPath);\n if (verbose) console.log(\" Cleaned up intermediate WASM file\");\n } catch {\n // Ignore cleanup errors\n }\n }\n } catch (error) {\n if (error instanceof Error) {\n throw error;\n }\n throw new Error(`Unknown error: ${String(error)}`);\n }\n}\n\n/**\n * Locates the AssemblyScript compiler executable\n * Tries multiple common paths\n */\nasync function getAssemblyScriptPath(): Promise<string> {\n // Get the directory of the current script for relative path resolution\n const scriptDir = new URL(\".\", import.meta.url).pathname;\n\n const possiblePaths = [\n // Relative to CLI package\n resolve(scriptDir, \"../../node_modules/.bin/asc\"),\n resolve(scriptDir, \"../../node_modules/.pnpm/assemblyscript@0.28.9/node_modules/assemblyscript/node_modules/.bin/asc\"),\n resolve(scriptDir, \"../node_modules/.bin/asc\"),\n resolve(scriptDir, \"../examples/node_modules/.bin/asc\"),\n \n // Relative to workspace root\n resolve(scriptDir, \"../../node_modules/.bin/asc\"),\n resolve(scriptDir, \"../../../node_modules/.bin/asc\"),\n \n // AssemblyScript toy example\n resolve(scriptDir, \"../../assemblyscript-toy/node_modules/.bin/asc\"),\n ];\n\n for (const path of possiblePaths) {\n try {\n const stat = await Deno.stat(path);\n if (stat.isFile) {\n return path;\n }\n } catch {\n // Path doesn't exist, try next\n }\n }\n\n // If not found, assume 'asc' is in PATH\n return \"asc\";\n}\n"],"mappings":";;;;;AAOA,SAAS,iBAAiB;;;ACG1B,SAAS,eAAe;AACxB,SAAS,kBAAkB;AAC3B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AAcP,SAAS,iBAAiB,aAAiC,SAAwB;AACjF,aAAW,KAAK,YAAY,UAAU;AACpC,UAAM,QAAQ,EAAE,eAAe,KAAK,EAAE,YAAY,MAAM;AACxD,YAAQ,MAAM,UAAU,KAAK,KAAK,EAAE,OAAO,EAAE;AAAA,EAC/C;AAEA,MAAI,WAAW,YAAY,UAAU,SAAS,GAAG;AAC/C,UAAM,SAAS,oBAAI,IAAoB;AACvC,eAAW,KAAK,YAAY,WAAW;AACrC,aAAO,IAAI,EAAE,OAAO,OAAO,IAAI,EAAE,IAAI,KAAK,KAAK,CAAC;AAAA,IAClD;AACA,UAAM,QAAQ,CAAC,GAAG,OAAO,QAAQ,CAAC,EAAE,IAAI,CAAC,CAAC,MAAM,KAAK,MAAM,GAAG,IAAI,KAAK,KAAK,GAAG;AAC/E,YAAQ,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AAgB,KAAK;AACnC,OAAK,KAAK,CAAC;AACb,CAAC;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@gasm-compiler/cli",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "CLI for compiling WebAssembly/AssemblyScript to WGSL using Gasm Compiler",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/cli.js",
|
|
7
|
+
"types": "./dist/cli.d.ts",
|
|
8
|
+
"bin": {
|
|
9
|
+
"gasm-compiler": "./dist/cli.js"
|
|
10
|
+
},
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/cli.d.ts",
|
|
14
|
+
"import": "./dist/cli.js",
|
|
15
|
+
"default": "./dist/cli.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist",
|
|
20
|
+
"LICENSE",
|
|
21
|
+
"README.md"
|
|
22
|
+
],
|
|
23
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public"
|
|
26
|
+
},
|
|
27
|
+
"keywords": [
|
|
28
|
+
"wasm",
|
|
29
|
+
"webassembly",
|
|
30
|
+
"wgsl",
|
|
31
|
+
"webgpu",
|
|
32
|
+
"compiler",
|
|
33
|
+
"gasm",
|
|
34
|
+
"cli"
|
|
35
|
+
],
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@gasm-compiler/core": "0.1.0"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"assemblyscript": "v0.28.9",
|
|
41
|
+
"tsup": "^8.5.1",
|
|
42
|
+
"typescript": "^5.9.3"
|
|
43
|
+
},
|
|
44
|
+
"scripts": {
|
|
45
|
+
"build": "tsup",
|
|
46
|
+
"dev": "deno run --allow-all src/cli.ts",
|
|
47
|
+
"lint": "biome lint ."
|
|
48
|
+
}
|
|
49
|
+
}
|