From aa64e11f4b9c888ff4885f5a2e3ef26a5bd6dd71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E5=85=B4?= <704168417@qq.com> Date: Sat, 30 Jun 2018 20:47:38 +0800 Subject: [PATCH] Implement parse the dep file of MDK project --- si4project_filelist.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/si4project_filelist.py b/si4project_filelist.py index cc71a54..d56adfd 100644 --- a/si4project_filelist.py +++ b/si4project_filelist.py @@ -7,6 +7,7 @@ import sys import xml.etree.ElementTree as ET from datetime import datetime +import re # 1、Find .dep file projectfilename = '' @@ -71,7 +72,6 @@ #2、parse the seleted dep file parsefile = open(sourcefile, 'r') si4filelist = [] -print(projectfilename) if projectfilename.endswith('.eww'): tree = ET.ElementTree(file=parsefile) tag_cfg_list = tree.findall('configuration') @@ -109,7 +109,12 @@ si4filelist.append(os.path.abspath(elem.text.replace('$PROJ_DIR$', os.getcwd()))+'\n') elif projectfilename.endswith('.uvproj') or projectfilename.endswith('.uvprojx'): - print('Parse MDK dep file') + for line in parsefile.readlines(): + m = re.search(r"^F \(.*?\)|^I \(.*?\)", line) + if None != m: + relpath = m.group(0)[3:-1] + si4filelist.append(os.path.abspath(relpath)+'\n') + si4filelist = set(si4filelist) #3、save the lists outputfile = open(outputfile + '.si4project_filelist.txt', 'w')