-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile.toml
289 lines (252 loc) · 8.39 KB
/
Makefile.toml
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
[env]
CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = true
[tasks.verify]
description = "Run most verification tasks"
workspace = false
dependencies = [
"run-tests",
"lint",
"docs",
"spell-check",
"verify-doc-tests",
"verify-formatting",
"deny",
]
[tasks.verify-all]
description = "Run all verification tasks"
workspace = false
dependencies = [
"run-all-tests",
"lint",
"docs",
"spell-check",
"verify-doc-tests",
"verify-formatting",
"deny",
]
[tasks.run-tests]
description = "Run tests using nextest runner for better performance"
command = "cargo"
workspace = false
args = ["nextest", "run", "--workspace", "--all-features"]
install_crate = "cargo-nextest"
[tasks.run-all-tests]
description = "Run all tests including ignored ones"
command = "cargo"
workspace = false
args = [
"nextest",
"run",
"--workspace",
"--all-features",
"--run-ignored",
"all",
]
install_crate = "cargo-nextest"
[tasks.deny]
workspace = false
command = "cargo"
args = ["deny", "check", "bans", "licenses", "sources"]
install_crate = "cargo-deny"
[tasks.spell-check]
workspace = false
command = "typos"
install_crate = "typos-cli"
[tasks.verify-doc-tests]
workspace = false
command = "cargo"
args = ["test", "--workspace", "--doc", "--all-features"]
[tasks.verify-formatting]
workspace = false
command = "cargo"
args = ["fmt", "--check", "--all"]
[tasks.lint]
description = "Run Clippy with warnings treated as errors"
workspace = false
command = "cargo"
args = [
"clippy",
"--workspace",
"--tests",
"--benches",
"--all-features",
"--",
"-D",
"warnings",
]
[tasks.docs]
description = "Generate documentation with warnings treated as errors"
workspace = false
command = "cargo"
env = { "RUSTDOCFLAGS" = "--deny warnings" }
args = [
"doc",
"--workspace",
"--no-deps",
"--all-features",
"--document-private-items",
]
[tasks.get-wasm-cxxlib]
script_runner = "@rust"
workspace = false
script = '''
//! ```cargo
//! [dependencies]
//! ureq = "2"
//! zip = "2"
//! ```
fn main() -> Result<(), Box<dyn std::error::Error>> {
let target_dir = "target/wasm-libcxx";
// Check if library already exists
if std::path::Path::new(target_dir).exists() {
return Ok(());
}
let url = "https://github.com/maximmaxim345/wasm32-unknown-unknown-libcxx/releases/latest/download/wasm32-unknown-unknown-libcxx.zip";
std::fs::create_dir_all(target_dir)?;
println!("Downloading libcxx...");
let response = ureq::get(url).call()?;
let mut content = Vec::new();
response.into_reader().read_to_end(&mut content)?;
println!("Extracting archive to {}...", target_dir);
let reader = std::io::Cursor::new(content);
let mut archive = zip::ZipArchive::new(reader)?;
archive.extract(target_dir)?;
println!("WASM library successfully installed in {}", target_dir);
Ok(())
}
'''
[tasks.ensure-wasm-target]
script_runner = "@rust"
workspace = false
script = '''
fn main() -> Result<(), Box<dyn std::error::Error>> {
let installed_targets = String::from_utf8(
std::process::Command::new("rustup")
.args(["+nightly", "target", "list", "--installed"])
.output()?
.stdout,
)?;
if !installed_targets.contains("wasm32-unknown-unknown") {
println!("Installing wasm32-unknown-unknown target for nightly...");
let status = std::process::Command::new("rustup")
.args(["+nightly", "target", "add", "wasm32-unknown-unknown"])
.status()?;
if !status.success() {
return Err("Failed to install wasm32-unknown-unknown target".into());
}
}
Ok(())
}
'''
[tasks.setup-wasm]
description = "Setup WASM build environment"
workspace = false
dependencies = ["ensure-wasm-target", "get-wasm-cxxlib"]
[tasks.build-wasm-dev]
description = "Build WASM target (development)"
workspace = false
dependencies = ["setup-wasm"]
script_runner = "@shell"
# This works on cmd, bash, zsh and sh
script = '''
WASM32_UNKNOWN_UNKNOWN_STDLIB_DIR="$(pwd)/target/wasm-libcxx/wasm32-unknown-unknown-libcxx" # shell2batch:
. $WASM32_UNKNOWN_UNKNOWN_STDLIB_DIR/env.sh # shell2batch: call target\wasm-libcxx\wasm32-unknown-unknown-libcxx\env.bat
cd crates/cadara
rustup run nightly wasm-pack build --target web --no-typescript --dev
'''
install_crate = "wasm-pack"
[tasks.build-wasm-debug]
description = "Build WASM target (with debug info)"
workspace = false
dependencies = ["build-wasm-dev"]
script_runner = "@shell"
script = '''
WASM32_UNKNOWN_UNKNOWN_STDLIB_DIR="$(pwd)/target/wasm-libcxx/wasm32-unknown-unknown-libcxx" # shell2batch:
. $WASM32_UNKNOWN_UNKNOWN_STDLIB_DIR/env.sh # shell2batch: call target\wasm-libcxx\wasm32-unknown-unknown-libcxx\env.bat
wasm-bindgen target/wasm32-unknown-unknown/debug/cadara_lib.wasm --out-dir crates/cadara/pkg --target web --keep-debug
'''
install_crate = "wasm-bindgen-cli"
[tasks.build-wasm-release]
description = "Build WASM target (release)"
workspace = false
dependencies = ["setup-wasm"]
script_runner = "@shell"
script = '''
WASM32_UNKNOWN_UNKNOWN_STDLIB_DIR="$(pwd)/target/wasm-libcxx/wasm32-unknown-unknown-libcxx" # shell2batch:
. $WASM32_UNKNOWN_UNKNOWN_STDLIB_DIR/env.sh # shell2batch: call target\wasm-libcxx\wasm32-unknown-unknown-libcxx\env.bat
cd crates/cadara
rustup run nightly wasm-pack build --target web --no-typescript
'''
install_crate = "wasm-pack"
[tasks.serve]
description = "Serve the WASM application"
workspace = false
install_crate = "simple-http-server"
command = "simple-http-server"
args = ["--nocache", "-i", "-p", "8080", "-c=wasm,js", "crates/cadara"]
[tasks.dev]
description = "Serve development build"
workspace = false
dependencies = ["build-wasm-dev", "serve"]
[tasks.debug]
description = "Serve debug build"
workspace = false
dependencies = ["build-wasm-debug", "serve"]
[tasks.release]
description = "Serve release build"
workspace = false
dependencies = ["build-wasm-release", "serve"]
[tasks.test-wasm]
description = "Run tests on WASM build"
workspace = false
dependencies = ["setup-wasm"]
script_runner = "@shell"
script = '''
WASM32_UNKNOWN_UNKNOWN_STDLIB_DIR="$(pwd)/target/wasm-libcxx/wasm32-unknown-unknown-libcxx" # shell2batch:
. $WASM32_UNKNOWN_UNKNOWN_STDLIB_DIR/env.sh # shell2batch: call target\wasm-libcxx\wasm32-unknown-unknown-libcxx\env.bat
cd crates/occara
rustup run nightly wasm-pack test --node
'''
install_crate = "wasm-pack"
[tasks.help]
description = "Display help information about available tasks"
workspace = false
script_runner = "@rust"
script = '''
//! ```cargo
//! [dependencies]
//! colored = "2.0"
//! ```
use colored::*;
fn main() {
println!("{}", "CADara Build System".bold().blue());
println!("\n{}", "Usage:".bold());
println!(" cargo make <task-name>\n");
println!(" cargo make verify # Run verification suite");
println!(" cargo make dev # Start WASM development server");
println!(" cargo make test-wasm # Run WASM test suite");
println!("\n{}", "Note:".bold());
println!(" All commands must be executed from the repository root directory\n");
println!("{}", "Primary Commands:".bold().green());
println!(" verify - Run standard verification suite");
println!(" verify-all - Run extended verification suite (including ignored tests)");
println!(" dev - Start WASM server");
println!(" debug - Start WASM server with debug symbols");
println!(" release - Start WASM production server\n");
println!("{}", "Verification Tasks:".bold().yellow());
println!(" run-tests - Run workspace tests (via nextest)");
println!(" run-all-tests - Run all tests including ignored ones");
println!(" lint - Run Clippy");
println!(" docs - Generate documentation");
println!(" spell-check - Check for typos in codebase");
println!(" verify-doc-tests - Verify documentation examples");
println!(" verify-formatting - Check code formatting");
println!(" deny - Check dependencies compliance\n");
println!("{}", "WASM Operations:".bold().magenta());
println!(" build-wasm-dev - Build WASM target (development)");
println!(" build-wasm-debug - Build WASM target (with debug info)");
println!(" build-wasm-release - Build WASM target (production)");
println!(" test-wasm - Run WASM-specific tests");
println!(" serve - Start local web server (port 8080)\n");
}
'''