commit 3998e6a5707a475de5b0c9aad6be2baa8652579d Author: cylon Date: Wed Aug 31 19:38:32 2016 +0200 Repo init. This project aims to create python script that will take root directory of a IAR System or Keil uVision project and convert it into CMake/Makefile project with the GCC compiler toolchain. Parsing of the most important settings from both project formats is done. diff --git a/converter.py b/converter.py new file mode 100644 index 0000000..f0f9ae5 --- /dev/null +++ b/converter.py @@ -0,0 +1,79 @@ +from lxml import objectify + + +def searchGroups(xml): + + for element in xml.getchildren(): + + if element.tag == 'group': + searchGroups(element) + + elif element.tag == 'file': + print (element.name) + +def parseEWP(): + + xmlFile = "Test.ewp" + xmltree = objectify.parse(xmlFile) + root = xmltree.getroot() + + projectName = root.configuration.name + print ('Project Name:' + projectName) + + chip = '' + + #TODO: parse into tree structure + searchGroups(root) + + defines = [] + includes = [] + + for element in root.configuration.getchildren(): + + if element.tag == 'settings': + for e in element.data.getchildren(): + + if e.tag == 'option': + if e.name.text == 'OGChipSelectEditMenu': + chip = e.state + elif e.name.text == 'CCDefines': + for d in e.getchildren(): + if d.tag == 'state': + defines.append(d.text) + elif e.name.text == 'CCIncludePath2': + for d in e.getchildren(): + if d.tag == 'state': + includes.append(d.text) + + print (includes) + print (defines) + print (chip) + +def parseUVPROJX(): + + xmlFile = 'Test.uvprojx' + xmltree = objectify.parse(xmlFile) + root = xmltree.getroot() + + projectName = root.Targets.Target.TargetName + + chip = root.Targets.Target.TargetOption.TargetCommonOption.Device + svd = root.Targets.Target.TargetOption.TargetCommonOption.SFDFile + includes = root.Targets.Target.TargetOption.TargetArmAds.Cads.VariousControls.IncludePath.text + memories = root.Targets.Target.TargetOption.TargetCommonOption.Cpu + print ('Project Name:' + projectName) + print ('Project chip:' + chip) + print ('Project svd:' + svd) + print ('Project includes: ' + includes) + print ('Project: ' + memories) + + for element in 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 __name__ == '__main__': + + pass \ No newline at end of file diff --git a/ewpproject.py b/ewpproject.py new file mode 100644 index 0000000..9ec7761 --- /dev/null +++ b/ewpproject.py @@ -0,0 +1,7 @@ +# -*- coding: utf-8 -*- + +class EWPProject (object): + + def __init__(self): + + pass \ No newline at end of file diff --git a/uvprojxproject.py b/uvprojxproject.py new file mode 100644 index 0000000..f180bda --- /dev/null +++ b/uvprojxproject.py @@ -0,0 +1,7 @@ +# -*- coding: utf-8 -*- + +class UVPROJXProject (object): + + def __init__(self): + + pass \ No newline at end of file