Skip to content

Commit

Permalink
add support keil 4
Browse files Browse the repository at this point in the history
  • Loading branch information
tianxiaoMCU committed Jul 7, 2018
1 parent 0ce75a7 commit 36ea24e
Showing 1 changed file with 40 additions and 33 deletions.
73 changes: 40 additions & 33 deletions si4project_filelist.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,12 @@
if entry.is_file():
if entry.name.endswith('.eww'):
projectfilename = entry.name

if os.path.exists('settings'):
sourcefile = entry.name.replace('.eww', '.dep')
outputfile = os.path.splitext(entry.name)[0]
wsdtfilepath = os.path.join(os.getcwd(), 'settings'+'\\'+entry.name.replace('.eww', '.wsdt'))

parsefile = open(wsdtfilepath, 'r')
tree = ET.ElementTree(file=parsefile)
ConfigDictionary = tree.find('ConfigDictionary')
CurrentConfigs = ConfigDictionary.find('CurrentConfigs')
TargetName = CurrentConfigs.find('Project').text
TargetName = os.path.basename(TargetName)
depfilename = entry.name.replace('.eww', '.dep')
if os.path.exists(depfilename):
sourcefile = depfilename
outputfile = os.path.splitext(projectfilename)[0]
break

if '' == sourcefile:
else:
print('Please build the project once')
input()
sys.exit(0)
Expand All @@ -46,6 +37,8 @@
uvoptfile = entry.name.replace('.uvprojx', '.uvoptx')

tree = ET.ElementTree(file=uvoptfile)

# find current target
for tag in tree.findall('Target'):
TargetOption = tag.find('TargetOption')
OPTFL = TargetOption.find('OPTFL')
Expand All @@ -54,25 +47,39 @@
TargetName = tag.find('TargetName').text
break

tree = ET.ElementTree(file=entry.name)
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'
depfilename = os.path.join(OutputDirectory, depfilename)

if os.path.exists(depfilename):
sourcefile = depfilename
outputfile = os.path.splitext(projectfilename)[0]
break
else:
print('Please build the project once')
input()
sys.exit(0)
# find dep file of current target
Extensions = tree.find('Extensions')
if None == Extensions.findtext('nMigrate'):
# ide is keil4
depfilename = os.path.splitext(projectfilename)[0] + '_' + TargetName + '.dep'
if os.path.exists(depfilename):
sourcefile = depfilename
outputfile = os.path.splitext(projectfilename)[0]

else:
# ide is keil5
tree = ET.ElementTree(file=entry.name)
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'
depfilename = os.path.join(OutputDirectory, depfilename)

if os.path.exists(depfilename):
sourcefile = depfilename
outputfile = os.path.splitext(projectfilename)[0]
break

if '' == sourcefile:
print('Please build the project once')
input()
sys.exit(0)

break

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

0 comments on commit 36ea24e

Please sign in to comment.