From 57d45f6badc34ad991dc0fd6bd4e0ca151db83a5 Mon Sep 17 00:00:00 2001 From: cylon Date: Tue, 6 Sep 2016 18:11:16 +0200 Subject: [PATCH] Fixed path issue in UVPROJXProject. --- cmake.py | 13 ++++++------- uvprojxproject.py | 22 +++++++++++++++++++--- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/cmake.py b/cmake.py index abe08ef..e5782ed 100644 --- a/cmake.py +++ b/cmake.py @@ -49,17 +49,16 @@ class CMake (object): for inc in self.project['incs']: cmake['incs'].append(inc) cmake['srcs'] = [] - srcs = [] + i=0 - for src in self.project['srcs']: - s = os.path.dirname(src) - if len(s) and s not in srcs: - srcs.append(s) - cmake['srcs'].append({'path': s,'var':'DIR_SRC' + str(i)}) - i = i+1 cmake['files']=[] + for file in self.project['srcs']: + if file.endswith('.c') or file.endswith('.h'): + cmake['files'].append({'path': file,'var':'SRC_FILE' + str(i)}) + i = i+1 + for file in self.project['files']: cmake['files'].append({'path': file,'var':'SRC_FILE' + str(i)}) i = i+1 diff --git a/uvprojxproject.py b/uvprojxproject.py index 51fd955..d731cae 100644 --- a/uvprojxproject.py +++ b/uvprojxproject.py @@ -28,10 +28,26 @@ class UVPROJXProject (object): if hasattr(element,'Files'): for file in element.Files.getchildren(): if not str(file.FilePath.text).endswith('.s'): - self.project['srcs'].append(str(file.FilePath.text).replace('..', self.path)) + s = str(file.FilePath.text) + + if os.path.sep not in s: + if os.path.sep == '\\': + s = s.replace('/','\\') + elif os.path.sep == '/': + s = s.replace('\\','/') + + self.project['srcs'].append(s.replace('..', self.path,1)) for i in range(0, len(self.project['incs'])): - self.project['incs'][i] = self.project['incs'][i].replace('..', self.path) + s = str(self.project['incs'][i]) + + if os.path.sep not in s: + if os.path.sep == '\\': + s = s.replace('/','\\') + elif os.path.sep == '/': + s = s.replace('\\','/') + + self.project['incs'][i] = s.replace('..', self.path,1) self.project['files']=[] @@ -49,7 +65,7 @@ class UVPROJXProject (object): print ('Project chip:' + self.project['chip']) print ('Project includes: ' + ' '.join(self.project['incs'])) print ('Project defines: ' + ' '.join(self.project['defs'])) - print ('Project srcs: ' + ' '.join(self.project['defs'])) + print ('Project srcs: ' + ' '.join(self.project['srcs'])) print ('Project: ' + self.project['mems']) def getProject(self):