-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_examples.py
More file actions
39 lines (31 loc) · 868 Bytes
/
run_examples.py
File metadata and controls
39 lines (31 loc) · 868 Bytes
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
from pathlib import Path
import subprocess
import sys
import os
profile = "debug"
for arg in sys.argv[1:]:
if arg == "-r":
profile = "release"
elif arg != "-d":
print("Usage: python run_examples.py [-r | -d]")
sys.exit(1)
binary_name = "smelt.exe" if os.name == "nt" else "smelt"
compiler = Path(f"./target/{profile}/{binary_name}")
examples_dir = Path("./examples")
if profile == "debug" and not compiler.exists():
print("Debug binary not found, building workspace...")
subprocess.run(
["cargo", "build", "--workspace"],
check=True
)
for file in sorted(examples_dir.glob("*.nbl")):
print(f"Running {file} using {profile} build...")
subprocess.run(
[
str(compiler),
str(file),
"--run",
"--clean",
],
check=True
)