Files
SyncHome/trunk/workspace/gcb/PythonBuild.py
2023-03-09 12:51:54 +00:00

50 lines
1.2 KiB
Python

#!/usr/bin/env python
import subprocess
import sys
import os
actionLine = sys.argv[1]
projectFile = sys.argv[2]
codeFile = open(projectFile+".gcb", 'r')
startLine = codeFile.readline()[3:].strip()
boardLine = codeFile.readline()[3:].strip()
endLine = codeFile.readline()[3:].strip()
codeFile.close()
# print projectFile
# print startLine
# print actionLine
# print boardLine
# print portLine
# print endLine
family=boardLine.split(':')[0]
processor=boardLine.split(':')[1]
#projectFile=projectFile.split(".")[0]
if (startLine != "########### start ###########" or endLine != "########### end ###########"):
print("\n Buddy: Error in build-commands - can't process file")
sys.exit()
if actionLine=="flash":
actionLine=actionLine+"_" + family
gcbCommand = "make " + actionLine + " file=" + projectFile + " cpu=" + processor
print(gcbCommand)
#print("\n\n -- GreatCowBasic Command --")
#print(gcbCommand)
#
#print("-- Starting %s --\n" %(actionLine))
#
presult = subprocess.call(gcbCommand, shell=True)
#presult = os.system(gcbCommand)
if presult != 0:
print("\n Buddy: Failed - result code = %s --" %(presult))
else:
print("\n Buddy: -- Success --")