-
Notifications
You must be signed in to change notification settings - Fork 1
/
compiler.py
75 lines (65 loc) · 2.34 KB
/
compiler.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
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
# run this script, it accepts the arguments and user input before running the compiler/compiler.py module
# also reloads all modules for every run
import sys
#import pprint
import argparse
import re
import glob
import json
import subprocess
import os.path
import shutil
import traceback
import datetime
from pathlib import Path
from timeit import default_timer as timer
from importlib import reload, invalidate_caches
import compiler.base
import compiler.preprocessor
import compiler.reader
import compiler.writer
import compiler.tester
import compiler.compiler
parser = argparse.ArgumentParser(description='Deus Ex Injecting Compiler')
parser.add_argument('--profile', help='Which profile(s) to use from the settings file')
parser.add_argument('--verbose', action="store_true", help="Output way more to the screen")
parser.add_argument('--once', action="store_true", help="Only run once and exit")
args = parser.parse_args()
#pp.pprint(args)
print(repr(args))
if args.profile is None:
args.profile = input("type in a profile name to compile, or just press enter for all: ")
if args.profile == '':
args.profile = 'all'
rerun = ""
while rerun != "exit":
try:
print("")
print("loading modules...")
invalidate_caches()
args.base = reload(compiler.base)
args.compiler = reload(compiler.compiler)
args.reader = reload(compiler.reader)
args.writer = reload(compiler.writer)
args.tester = reload(compiler.tester)
args.preprocessor = reload(compiler.preprocessor)
if rerun != "":
args.profile = rerun
print(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") + ": compiling "+args.profile+"...")
args.compiler.run(args)
except Exception as e:
args.base.printError('\n\ncompile error: ')
if args.verbose:
tb = traceback.TracebackException.from_exception(e, capture_locals=True)
print("\n----------\n".join(tb.format()))
else:
print(traceback.format_exc())
args.base.printError("----------------")
print("\n")
if args.once:
break
print( datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
+ ": \npress enter to compile "+args.profile+" again")
print("- or type in a new profile name")
rerun = input("- otherwise type exit: ")
input("press enter to continue")