]> Witch of Git - ivy/blob - tools/run.py
[Docs] Mention run.py and trace.py in the README
[ivy] / tools / run.py
1 #!/usr/bin/env python3
2 import argparse
3 import subprocess
4 import tempfile
5 import trace
6 from pathlib import Path
7
8 root = Path(__file__).parent.parent
9 ivy = root / "target" / "release" / "ivy"
10 library_path = root / "rt" / "target" / "release"
11
12
13 def compile(source, output):
14 subprocess.run(
15 [ivy, source, "-o", output],
16 env={"LIBRARY_PATH": library_path},
17 check=True,
18 )
19
20
21 def run(script, only_debug=True):
22 with tempfile.TemporaryDirectory() as d:
23 binary = Path(d) / "a.out"
24 compile(script, output=binary)
25 trace.trace(binary, only_debug)
26
27
28 def main():
29 parser = argparse.ArgumentParser()
30 parser.add_argument("script")
31 parser.add_argument("-v", "--verbose", action="store_true")
32 args = parser.parse_args()
33 run(args.script, not args.verbose)
34
35
36 if __name__ == "__main__":
37 main()