aboutsummaryrefslogtreecommitdiffstats
path: root/main.py
diff options
context:
space:
mode:
authorbloodstalker <thabogre@gmail.com>2018-07-01 12:10:17 +0000
committerbloodstalker <thabogre@gmail.com>2018-07-01 12:10:17 +0000
commit3f7a6e1cb02d2743b8343df21368d2aadfe81d8c (patch)
tree977f9058136c901d7c5106bb58272d5783365b5e /main.py
parentupdated the makefiles (diff)
downloadfaultreiber-3f7a6e1cb02d2743b8343df21368d2aadfe81d8c.tar.gz
faultreiber-3f7a6e1cb02d2743b8343df21368d2aadfe81d8c.zip
update
Diffstat (limited to 'main.py')
-rwxr-xr-xmain.py35
1 files changed, 33 insertions, 2 deletions
diff --git a/main.py b/main.py
index 5940d8a..f848cbc 100755
--- a/main.py
+++ b/main.py
@@ -3,7 +3,10 @@
import argparse
import code
+import fileinput
+import json
import readline
+from shutil import copy
import signal
import sys
@@ -14,15 +17,43 @@ def SigHandler_SIGINT(signum, frame):
class Argparser(object):
def __init__(self):
parser = argparse.ArgumentParser()
- parser.add_argument("--string", type=str, help="string")
- parser.add_argument("--bool", action="store_true", help="bool", default=False)
+ parser.add_argument("--targetname", type=str, help="main target name")
+ parser.add_argument("--outdir", type=str, help="path to output dir")
+ parser.add_argument("--structs", type=str, help="the structs json file")
parser.add_argument("--dbg", action="store_true", help="debug", default=False)
self.args = parser.parse_args()
+def dupemake(path, main_name):
+ copy("./resources/makefile", path)
+ makefile_path = str()
+ if path[-1] == "/": makefile_path = path + "makefile"
+ else: makefile_path = path + "/makefile"
+ for line in fileinput.input(makefile_path, inplace=True):
+ if "XXX" in line:
+ line = line.replace("XXX", main_name)
+ sys.stdout.write(line)
+
+class CodeGen(object):
+ def __init__(self, argparser):
+ self.argparser = argparser
+ self.struct_json = json.load(open(self.argparser.args.structs))
+
+ def init_hook(self):
+ pass
+
+ def init(self):
+ dupemake(self.argparser.args.outdir, self.argparser.args.targetname)
+
+ def run(self):
+ self.init()
+ self.init_hook()
+
# write code here
def premain(argparser):
signal.signal(signal.SIGINT, SigHandler_SIGINT)
#here
+ codegen = CodeGen(argparser)
+ codegen.run()
def main():
argparser = Argparser()