forked from JunSuzukiJapan/rust_llvm_sample
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathx.py
42 lines (28 loc) · 814 Bytes
/
x.py
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
#!/usr/bin/python3
import subprocess
import sys
def build():
subprocess.call("cargo build", shell=True)
def test(args, expected):
command = ["./target/debug/llvm_test"] + args
subprocess.call(command)
subprocess.call("llvm-as compiled.ll", shell=True)
p = subprocess.Popen("lli compiled.bc".split(), stdout=subprocess.PIPE)
streamdata = p.communicate()[0]
print(f"{args} -> {p.returncode}")
assert p.returncode == expected
def clean():
subprocess.call("rm compiled*", shell=True)
def run():
build()
test(["10", "20"], 30)
# test(["111", "222"], 333)
def main(command):
if command == "--clean":
clean()
else:
run()
if __name__ == "__main__":
args = sys.argv
command = args[1] if len(args) > 1 else None
main(command)