Skip to content

Commit

Permalink
change auto selete current configuration of MDK project
Browse files Browse the repository at this point in the history
  • Loading branch information
tianxiaoMCU committed Jun 24, 2018
1 parent 2d06b6f commit e9c1736
Showing 1 changed file with 32 additions and 57 deletions.
89 changes: 32 additions & 57 deletions si4project_filelist.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,64 +29,39 @@

elif entry.name.endswith('.uvproj') or entry.name.endswith('.uvprojx'):
projectfilename = entry.name

if entry.name.endswith('.uvproj'):
uvoptfile = entry.name.replace('.uvproj', '.uvopt')
elif entry.name.endswith('.uvprojx'):
uvoptfile = entry.name.replace('.uvprojx', '.uvoptx')

tree = ET.ElementTree(file=uvoptfile)
for tag in tree.findall('Target'):
TargetOption = tag.find('TargetOption')
OPTFL = TargetOption.find('OPTFL')
IsCurrentTarget = int(OPTFL.find('IsCurrentTarget').text)
if IsCurrentTarget:
TargetName = tag.find('TargetName').text

tree = ET.ElementTree(file=entry.name)
tag_cfg_list = tree.find('Targets').findall('Target')
listsize = len(tag_cfg_list)
if listsize > 1:
print("There are multiple configuration:")
for index in range(0, listsize):
print("%d %s" % (index+1, tag_cfg_list[index].find('TargetName').text))

print("Enter the index num to selete:")
strin = input()
if strin.isdigit():
selnum = int(strin)
if (selnum < (listsize + 1)):
TargetName = tag_cfg_list[selnum - 1].find('TargetName').text
TargetOption = tag_cfg_list[selnum - 1].find('TargetOption')
TargetCommonOption = TargetOption.find('TargetCommonOption')
OutputDirectory = TargetCommonOption.find('OutputDirectory').text
OutputDirectory = os.path.normpath(os.path.join(os.getcwd(), OutputDirectory))

depfilename = os.path.splitext(projectfilename)[0] + '_' + TargetName + '.dep'

for entry in os.scandir(OutputDirectory):
if entry.is_file() and entry.name == depfilename:
sourcefile = os.path.join(OutputDirectory, entry.name)
outputfile = os.path.splitext(entry.name)[0]
break
if '' == sourcefile:
print('Please build the project once')
input()
sys.exit(0)
else:
print("Please restart the tool, the input shounld be a number")
input()
sys.exit(0)

elif listsize == 1:
TargetName = tag_cfg_list[selnum - 1].find('TargetName').text
TargetOption = tag_cfg_list[selnum - 1].find('TargetOption')
TargetCommonOption = TargetOption.find('TargetCommonOption')
OutputDirectory = TargetCommonOption.find('OutputDirectory').text
OutputDirectory = os.path.normpath(os.path.join(os.getcwd(), OutputDirectory))

depfilename = projectfilename + '_' + TargetName + '.dep'

for entry in os.scandir(OutputDirectory):
if entry.is_file() and entry.name == depfilename:
sourcefile = os.path.join(OutputDirectory, entry.name)
outputfile = os.path.splitext(entry.name)[0]
break
if '' == sourcefile:
print('Please build the project once')
input()
sys.exit(0)
else:
print("Please check the project configuration")
input()
sys.exit(0)
break
for tag in tree.find('Targets').findall('Target'):
if tag.find('TargetName').text == TargetName:
TargetOption = tag.find('TargetOption')
TargetCommonOption = TargetOption.find('TargetCommonOption')
OutputDirectory = TargetCommonOption.find('OutputDirectory').text
OutputDirectory = os.path.normpath(os.path.join(os.getcwd(), OutputDirectory))

depfilename = os.path.splitext(projectfilename)[0] + '_' + TargetName + '.dep'

for entry in os.scandir(OutputDirectory):
if entry.is_file() and entry.name == depfilename:
sourcefile = os.path.join(OutputDirectory, entry.name)
outputfile = os.path.splitext(entry.name)[0]
break
if '' == sourcefile:
print('Please build the project once')
input()
sys.exit(0)

if '' == projectfilename:
print('Can not find project file, enter any key to exit')
Expand Down

0 comments on commit e9c1736

Please sign in to comment.