forked from denoland/wasmbuild
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.ts
117 lines (112 loc) · 3.18 KB
/
main.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/usr/bin/env -S deno run --allow-run --allow-read --allow-write --allow-env
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
import { parseArgs } from "./lib/args.ts";
import { runNewCommand } from "./lib/commands/new_command.ts";
import { runCheckCommand } from "./lib/commands/check_command.ts";
import { runBuildCommand } from "./lib/commands/build_command.ts";
await Deno.permissions.request({ name: "env" });
await Deno.permissions.request({ name: "run" });
await Deno.permissions.request({ name: "read" });
await Deno.permissions.request({ name: "write" });
const command = parseArgs(Deno.args);
switch (command.kind) {
case "new": {
await runNewCommand();
break;
}
case "build": {
await runBuildCommand(command);
break;
}
case "check": {
await runCheckCommand(command);
break;
}
case "help": {
showHelp();
break;
}
default: {
const _assertNever: never = command;
throw new Error("Not implemented.");
}
}
function showHelp() {
console.log("%cWasmBuild", "font-weight: bold");
console.log();
console.log(
"%cnew %c- Scaffold a new project",
"color: green",
"color: reset",
);
console.log();
console.log("%cbuild %c- Build the project", "color: green", "color: reset");
console.log();
console.log("%cBuild options:", "font-style: italic");
console.log();
console.log(
"%c--debug %c- Build without optimizations.",
"font-weight: bold",
"font-weight: normal",
);
console.log();
console.log(
"%c--project <crate_name> / -p <crate_name> %c- Specifies the crate to build when using a Cargo workspace.",
"font-weight: bold",
"font-weight: normal",
);
console.log();
console.log(
"%c--out <dir_path> %c- Specifies the output directory. Defaults to ./lib",
"font-weight: bold",
"font-weight: normal",
);
console.log();
console.log(
"%c--js-ext <ext_no_period> %c- Extension to use for the wasm-bindgen JS file. Defaults to js.",
"font-weight: bold",
"font-weight: normal",
);
console.log();
console.log(
"%c--all-features %c- Build the crate with all features.",
"font-weight: bold",
"font-weight: normal",
);
console.log();
console.log(
"%c--no-default-features %c- Build the crate with no default features.",
"font-weight: bold",
"font-weight: normal",
);
console.log();
console.log(
'%c--features %c- Specify the features to create. Specify multiple features quoted and with spaces (ex. --features "wasm serialization").',
"font-weight: bold",
"font-weight: normal",
);
console.log();
console.log(
"%c--sync %c- Generate a synchronous module that stores the Wasm module inline as base64 text.",
"font-weight: bold",
"font-weight: normal",
);
console.log();
console.log(
"%c--skip-opt %c- Skip running wasm-opt.",
"font-weight: bold",
"font-weight: normal",
);
console.log();
console.log(
"%c--check %c- Checks if the output is up-to-date.",
"font-weight: bold",
"font-weight: normal",
);
console.log();
console.log(
"%c--no-cache %c- Do not generate the code to cache the Wasm file locally.",
"font-weight: bold",
"font-weight: normal",
);
}