UVPROJXProject class now parses also defines.

This commit is contained in:
cylon 2016-09-01 01:38:22 +02:00
parent 71f1ae6347
commit 7ab01684c4
3 changed files with 30 additions and 20 deletions

View File

@ -4,15 +4,17 @@ import argparse
import ewpproject
import uvprojxproject
# TODO: add Cmake and jinja2 support
def findFile (path,fileext):
file = ''
f = ''
for root, dirs, files in os.walk(path):
for file in files:
if file.endswith(fileext):
file = os.path.join(root, file)
f = os.path.join(root, file)
return file
return f
if __name__ == '__main__':
@ -30,7 +32,7 @@ if __name__ == '__main__':
file = findFile(args.path,'.ewp')
if (len(file)):
print ('Found project file: ' + file)
project = ewpproject.EWPProject(file)
project = ewpproject.EWPProject(args.path,file)
project.parseProject()
project.displaySummary()
else:
@ -41,7 +43,7 @@ if __name__ == '__main__':
file = findFile(args.path,'.uvprojx')
if (len(file)):
print ('Found project file: ' + file)
project = uvprojxproject.UVPROJXProject(file)
project = uvprojxproject.UVPROJXProject(args.path,file)
project.parseProject()
project.displaySummary()
else:

View File

@ -4,8 +4,9 @@ from lxml import objectify
class EWPProject (object):
def __init__(self, xmlFile):
def __init__(self, path, xmlFile):
self.path = path
self.xmlFile = xmlFile
xmltree = objectify.parse(xmlFile)
self.root = xmltree.getroot()
@ -32,23 +33,26 @@ class EWPProject (object):
self.chip = e.state
elif e.name.text == 'CCDefines':
for d in e.getchildren():
if d.tag == 'state':
if d.tag == 'state' and d.text != None:
self.defines.append(d.text)
elif e.name.text == 'CCIncludePath2':
for d in e.getchildren():
if d.tag == 'state':
if d.tag == 'state' and d.text != None:
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):
print ('Project Name:' + self.projectName)
print ('Project chip:' + self.chip)
print ('Project includes: ' + self.includes)
print ('Project defines: ' + self.defines)
print ('Project includes: ' + ' '.join(self.includes))
print ('Project defines: ' + ' '.join(self.defines))
def searchGroups(self, xml):
for element in xml.getchildren():
if element.tag == 'group':

View File

@ -3,7 +3,7 @@ from lxml import objectify
class UVPROJXProject (object):
def __init__(self, xmlFile):
def __init__(self, path, xmlFile):
self.xmlFile = xmlFile
xmltree = objectify.parse(xmlFile)
@ -14,22 +14,26 @@ class UVPROJXProject (object):
self.projectName = self.root.Targets.Target.TargetName
self.chip = self.root.Targets.Target.TargetOption.TargetCommonOption.Device
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.defines = self.root.Targets.Target.TargetOption.TargetArmAds.Cads.VariousControls.Define.text.split(',')
self.sources = []
for element in self.root.Targets.Target.Groups.getchildren():
print ('GroupName: ' + element.GroupName.text)
for file in element.Files.getchildren():
print ('FileName: ' + file.FileName.text)
print ('FilePath: ' + file.FilePath.text)
if hasattr(element,'Files'):
for file in element.Files.getchildren():
#print ('FileName: ' + file.FileName.text)
print ('FilePath: ' + file.FilePath.text)
def displaySummary(self):
print ('Project Name:' + self.projectName)
print ('Project chip:' + self.chip)
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)