From 5ba80baaddfcca4bfd0a3307196101130891e766 Mon Sep 17 00:00:00 2001 From: duplo Date: Tue, 30 Mar 2010 14:37:27 +0000 Subject: [PATCH] More efficient way to track BeRTOS files. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@3332 38d2e660-2303-0410-9eaa-f027e97ec537 --- wizard/BProject.py | 22 +++++++++++++--------- wizard/bertos_utils.py | 18 +++++++++--------- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/wizard/BProject.py b/wizard/BProject.py index 6ecd3bc2..eaff6d62 100644 --- a/wizard/BProject.py +++ b/wizard/BProject.py @@ -63,22 +63,26 @@ class BProject(object): def loadSourceTree(self): # Index only the SOURCES_PATH/bertos content bertos_sources_dir = os.path.join(self.info("SOURCES_PATH"), 'bertos') + file_dict = {} if os.path.exists(bertos_sources_dir): - fileList = [f for f in os.walk(bertos_sources_dir)] - else: - fileList = [] - self.setInfo("FILE_LIST", fileList) + for element in os.walk(bertos_sources_dir): + for f in element[2]: + file_dict[f] = file_dict.get(f, []) + [element[0]] + self.setInfo("FILE_DICT", file_dict) + + def searchFiles(self, filename): + file_dict = self.infos["FILE_DICT"] + return [(filename, dirname) for dirname in file_dict.get(filename, [])] def findDefinitions(self, ftype): definitions = self._cached_queries.get(ftype, None) if definitions is not None: return definitions - L = self.infos["FILE_LIST"] + file_dict = self.infos["FILE_DICT"] definitions = [] - for element in L: - for filename in element[2]: - if fnmatch.fnmatch(filename, ftype): - definitions.append((filename, element[0])) + for filename in file_dict: + if fnmatch.fnmatch(filename, ftype): + definitions += [(filename, dirname) for dirname in file_dict.get(filename, [])] self._cached_queries[ftype] = definitions return definitions diff --git a/wizard/bertos_utils.py b/wizard/bertos_utils.py index 0fbb9532..e291f56b 100644 --- a/wizard/bertos_utils.py +++ b/wizard/bertos_utils.py @@ -381,28 +381,28 @@ def findModuleFiles(module, project_info): cfiles = [] sfiles = [] # .c files related to the module and the cpu architecture - for filename, path in project_info.findDefinitions(module + ".c") + \ - project_info.findDefinitions(module + "_" + project_info.info("CPU_INFOS")["TOOLCHAIN"] + ".c"): + for filename, path in project_info.searchFiles(module + ".c") + \ + project_info.searchFiles(module + "_" + project_info.info("CPU_INFOS")["TOOLCHAIN"] + ".c"): path = path.replace(project_info.info("SOURCES_PATH") + os.sep, "") path = replaceSeparators(path) cfiles.append(path + "/" + filename) # .s files related to the module and the cpu architecture - for filename, path in project_info.findDefinitions(module + ".s") + \ - project_info.findDefinitions(module + "_" + project_info.info("CPU_INFOS")["TOOLCHAIN"] + ".s") + \ - project_info.findDefinitions(module + ".S") + \ - project_info.findDefinitions(module + "_" + project_info.info("CPU_INFOS")["TOOLCHAIN"] + ".S"): + for filename, path in project_info.searchFiles(module + ".s") + \ + project_info.searchFiles(module + "_" + project_info.info("CPU_INFOS")["TOOLCHAIN"] + ".s") + \ + project_info.searchFiles(module + ".S") + \ + project_info.searchFiles(module + "_" + project_info.info("CPU_INFOS")["TOOLCHAIN"] + ".S"): path = path.replace(project_info.info("SOURCES_PATH") + os.sep, "") path = replaceSeparators(path) sfiles.append(path + "/" + filename) # .c and .s files related to the module and the cpu tags for tag in project_info.info("CPU_INFOS")["CPU_TAGS"]: - for filename, path in project_info.findDefinitions(module + "_" + tag + ".c"): + for filename, path in project_info.searchFiles(module + "_" + tag + ".c"): path = path.replace(project_info.info("SOURCES_PATH") + os.sep, "") if os.sep != "/": path = replaceSeparators(path) cfiles.append(path + "/" + filename) - for filename, path in project_info.findDefinitions(module + "_" + tag + ".s") + \ - project_info.findDefinitions(module + "_" + tag + ".S"): + for filename, path in project_info.searchFiles(module + "_" + tag + ".s") + \ + project_info.searchFiles(module + "_" + tag + ".S"): path = path.replace(project_info.info("SOURCES_PATH") + os.sep, "") path = replaceSeparators(path) sfiles.append(path + "/" + filename) -- 2.25.1