mirror of
https://github.com/phodina/ProjectConverter.git
synced 2026-07-30 16:26:15 +08:00
UVPROJXProject class now parses also defines.
This commit is contained in:
parent
71f1ae6347
commit
7ab01684c4
12
converter.py
12
converter.py
@ -4,15 +4,17 @@ import argparse
|
|||||||
import ewpproject
|
import ewpproject
|
||||||
import uvprojxproject
|
import uvprojxproject
|
||||||
|
|
||||||
|
# TODO: add Cmake and jinja2 support
|
||||||
|
|
||||||
def findFile (path,fileext):
|
def findFile (path,fileext):
|
||||||
|
|
||||||
file = ''
|
f = ''
|
||||||
for root, dirs, files in os.walk(path):
|
for root, dirs, files in os.walk(path):
|
||||||
for file in files:
|
for file in files:
|
||||||
if file.endswith(fileext):
|
if file.endswith(fileext):
|
||||||
file = os.path.join(root, file)
|
f = os.path.join(root, file)
|
||||||
|
|
||||||
return file
|
return f
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
||||||
@ -30,7 +32,7 @@ if __name__ == '__main__':
|
|||||||
file = findFile(args.path,'.ewp')
|
file = findFile(args.path,'.ewp')
|
||||||
if (len(file)):
|
if (len(file)):
|
||||||
print ('Found project file: ' + file)
|
print ('Found project file: ' + file)
|
||||||
project = ewpproject.EWPProject(file)
|
project = ewpproject.EWPProject(args.path,file)
|
||||||
project.parseProject()
|
project.parseProject()
|
||||||
project.displaySummary()
|
project.displaySummary()
|
||||||
else:
|
else:
|
||||||
@ -41,7 +43,7 @@ if __name__ == '__main__':
|
|||||||
file = findFile(args.path,'.uvprojx')
|
file = findFile(args.path,'.uvprojx')
|
||||||
if (len(file)):
|
if (len(file)):
|
||||||
print ('Found project file: ' + file)
|
print ('Found project file: ' + file)
|
||||||
project = uvprojxproject.UVPROJXProject(file)
|
project = uvprojxproject.UVPROJXProject(args.path,file)
|
||||||
project.parseProject()
|
project.parseProject()
|
||||||
project.displaySummary()
|
project.displaySummary()
|
||||||
else:
|
else:
|
||||||
|
|||||||
@ -4,8 +4,9 @@ from lxml import objectify
|
|||||||
|
|
||||||
class EWPProject (object):
|
class EWPProject (object):
|
||||||
|
|
||||||
def __init__(self, xmlFile):
|
def __init__(self, path, xmlFile):
|
||||||
|
|
||||||
|
self.path = path
|
||||||
self.xmlFile = xmlFile
|
self.xmlFile = xmlFile
|
||||||
xmltree = objectify.parse(xmlFile)
|
xmltree = objectify.parse(xmlFile)
|
||||||
self.root = xmltree.getroot()
|
self.root = xmltree.getroot()
|
||||||
@ -32,23 +33,26 @@ class EWPProject (object):
|
|||||||
self.chip = e.state
|
self.chip = e.state
|
||||||
elif e.name.text == 'CCDefines':
|
elif e.name.text == 'CCDefines':
|
||||||
for d in e.getchildren():
|
for d in e.getchildren():
|
||||||
if d.tag == 'state':
|
if d.tag == 'state' and d.text != None:
|
||||||
self.defines.append(d.text)
|
self.defines.append(d.text)
|
||||||
elif e.name.text == 'CCIncludePath2':
|
elif e.name.text == 'CCIncludePath2':
|
||||||
for d in e.getchildren():
|
for d in e.getchildren():
|
||||||
if d.tag == 'state':
|
if d.tag == 'state' and d.text != None:
|
||||||
self.includes.append(d.text)
|
self.includes.append(d.text)
|
||||||
|
|
||||||
|
for i in range(0, len(self.includes)):
|
||||||
|
self.includes[i] = self.includes[i].replace('$PROJ_DIR$', self.path)
|
||||||
|
|
||||||
|
|
||||||
def displaySummary(self):
|
def displaySummary(self):
|
||||||
|
|
||||||
|
|
||||||
print ('Project Name:' + self.projectName)
|
print ('Project Name:' + self.projectName)
|
||||||
print ('Project chip:' + self.chip)
|
print ('Project chip:' + self.chip)
|
||||||
print ('Project includes: ' + self.includes)
|
print ('Project includes: ' + ' '.join(self.includes))
|
||||||
print ('Project defines: ' + self.defines)
|
print ('Project defines: ' + ' '.join(self.defines))
|
||||||
|
|
||||||
def searchGroups(self, xml):
|
def searchGroups(self, xml):
|
||||||
|
|
||||||
for element in xml.getchildren():
|
for element in xml.getchildren():
|
||||||
|
|
||||||
if element.tag == 'group':
|
if element.tag == 'group':
|
||||||
|
|||||||
@ -3,7 +3,7 @@ from lxml import objectify
|
|||||||
|
|
||||||
class UVPROJXProject (object):
|
class UVPROJXProject (object):
|
||||||
|
|
||||||
def __init__(self, xmlFile):
|
def __init__(self, path, xmlFile):
|
||||||
|
|
||||||
self.xmlFile = xmlFile
|
self.xmlFile = xmlFile
|
||||||
xmltree = objectify.parse(xmlFile)
|
xmltree = objectify.parse(xmlFile)
|
||||||
@ -14,22 +14,26 @@ class UVPROJXProject (object):
|
|||||||
self.projectName = self.root.Targets.Target.TargetName
|
self.projectName = self.root.Targets.Target.TargetName
|
||||||
self.chip = self.root.Targets.Target.TargetOption.TargetCommonOption.Device
|
self.chip = self.root.Targets.Target.TargetOption.TargetCommonOption.Device
|
||||||
self.svd = self.root.Targets.Target.TargetOption.TargetCommonOption.SFDFile
|
self.svd = self.root.Targets.Target.TargetOption.TargetCommonOption.SFDFile
|
||||||
self.includes = self.root.Targets.Target.TargetOption.TargetArmAds.Cads.VariousControls.IncludePath.text
|
self.includes = self.root.Targets.Target.TargetOption.TargetArmAds.Cads.VariousControls.IncludePath.text.split(';')
|
||||||
self.memories = self.root.Targets.Target.TargetOption.TargetCommonOption.Cpu
|
self.memories = self.root.Targets.Target.TargetOption.TargetCommonOption.Cpu
|
||||||
|
self.defines = self.root.Targets.Target.TargetOption.TargetArmAds.Cads.VariousControls.Define.text.split(',')
|
||||||
|
|
||||||
|
self.sources = []
|
||||||
for element in self.root.Targets.Target.Groups.getchildren():
|
for element in self.root.Targets.Target.Groups.getchildren():
|
||||||
|
|
||||||
|
|
||||||
print ('GroupName: ' + element.GroupName.text)
|
print ('GroupName: ' + element.GroupName.text)
|
||||||
for file in element.Files.getchildren():
|
if hasattr(element,'Files'):
|
||||||
print ('FileName: ' + file.FileName.text)
|
for file in element.Files.getchildren():
|
||||||
print ('FilePath: ' + file.FilePath.text)
|
#print ('FileName: ' + file.FileName.text)
|
||||||
|
print ('FilePath: ' + file.FilePath.text)
|
||||||
|
|
||||||
def displaySummary(self):
|
def displaySummary(self):
|
||||||
|
|
||||||
print ('Project Name:' + self.projectName)
|
print ('Project Name:' + self.projectName)
|
||||||
print ('Project chip:' + self.chip)
|
print ('Project chip:' + self.chip)
|
||||||
print ('Project svd:' + self.svd)
|
print ('Project svd:' + self.svd)
|
||||||
print ('Project includes: ' + self.includes)
|
print ('Project includes: ' + ' '.join(self.includes))
|
||||||
|
print ('Project defines: ' + ' '.join(self.defines))
|
||||||
print ('Project: ' + self.memories)
|
print ('Project: ' + self.memories)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user