generator.py can be ran with or without arguments (it can be double clicked, when not using scons)

This commit is contained in:
jacob1
2013-03-03 19:51:01 -05:00
parent 55f090b4d2
commit 78cdc39455

View File

@@ -18,7 +18,11 @@ def generateElements(elementFiles, outputCpp, outputH):
directives = [] directives = []
for elementFile in elementFiles: for elementFile in elementFiles:
try:
f = open(elementFile, "r") f = open(elementFile, "r")
except:
f = open("src/simulation/elements/"+elementFile, "r")
fileData = f.read() fileData = f.read()
f.close() f.close()
@@ -145,7 +149,10 @@ def generateTools(toolFiles, outputCpp, outputH):
directives = [] directives = []
for toolFile in toolFiles: for toolFile in toolFiles:
try:
f = open(toolFile, "r") f = open(toolFile, "r")
except:
f = open("src/simulation/tools/"+toolFile, "r")
fileData = f.read() fileData = f.read()
f.close() f.close()
@@ -210,7 +217,11 @@ def generateTools(toolFiles, outputCpp, outputH):
f.write(toolContent) f.write(toolContent)
f.close() f.close()
if(len(sys.argv) > 3):
if(sys.argv[1] == "elements"): if(sys.argv[1] == "elements"):
generateElements(sys.argv[4:], sys.argv[2], sys.argv[3]) generateElements(sys.argv[4:], sys.argv[2], sys.argv[3])
elif(sys.argv[1] == "tools"): elif(sys.argv[1] == "tools"):
generateTools(sys.argv[4:], sys.argv[2], sys.argv[3]) generateTools(sys.argv[4:], sys.argv[2], sys.argv[3])
else:
generateElements(os.listdir("src/simulation/elements"), "generated/ElementClasses.cpp", "generated/ElementClasses.h")
generateTools(os.listdir("src/simulation/tools"), "generated/ToolClasses.cpp", "generated/ToolClasses.h")