def prepareBuildData(self): ''' This function is used in all 'update*.py' scripts and makes sure, that buildData with a valid tools paths exist. Invalid paths are updated (requested from the user). Returns available, valid build data. ''' paths = pth.UpdatePaths() self.checkBuildDataFile() buildData = self.getBuildData() if self.checkToolsPathFile(): # toolsPaths.json exists buildData = self.addToolsPathsData(buildData) buildData = paths.verifyExistingPaths(buildData) return buildData
def prepareBuildData(self, request=False): ''' This function is used in all 'update*.py' scripts and makes sure, that 'toolsPaths.json' and 'buildData.json' with a valid tools/target cofniguration paths exist. Invalid paths are updated (requested from the user). Returns available, valid build data. Note: tools paths listed in 'BuildDataStrings.toolsPaths' are stored in system local 'toolsPaths.json' file, and are copied (overwritten) to 'buildData.json' on first 'Update' task run. This makes it possible for multiple code contributors. ''' paths = pth.UpdatePaths() self.checkBuildDataFile() buildData = self.getBuildData() if self.checkToolsPathFile(): # a valid toolsPaths.json exists toolsPathsData = self.getToolsPathsData() else: # no valid data from 'toolsPaths.json' file # try to get data from current 'buildData.json' - backward compatibility for paths that already exist in 'buildData.json' toolsPathsData = json.loads(tmpStr.toolsPathsTemplate) for path in self.bStr.toolsPaths: if path in buildData: if utils.pathExists(buildData[path]): toolsPathsData[path] = buildData[path] # update/overwrite tools paths file. Don't mind if paths are already valid. toolsPathsData = paths.verifyToolsPaths(toolsPathsData, request) self.createUserToolsFile(toolsPathsData) buildData = self.addToolsPathsToBuildData(buildData, toolsPathsData) templateBuildData = json.loads(tmpStr.buildDataTemplate) buildData = utils.mergeCurrentDataWithTemplate(buildData, templateBuildData) buildData = paths.verifyTargetConfigurationPaths(buildData, request) buildData = paths.copyTargetConfigurationFiles(buildData) return buildData
dataToWrite = json.dumps(data, indent=4, sort_keys=False) buildDataFile.write(dataToWrite) print("'buildData.json' file updated!") except Exception as err: errorMsg = "Exception error overwriting 'buildData.json' file:\n" errorMsg += str(err) utils.printAndQuit(errorMsg) ######################################################################################################################## if __name__ == "__main__": utils.verifyFolderStructure() paths = pth.UpdatePaths() makefile = mkf.Makefile() bData = BuildData() # Makefile must exist makefile.checkMakefileFile( ) # no point in continuing if Makefile does not exist # build data (update tools paths if neccessary) bData.checkBuildDataFile() buildData = bData.getBuildData() if not paths.verifyExistingPaths(buildData): buildData = paths.forceUpdatePaths(buildData) makeExePath = buildData[bData.bStr.buildToolsPath] gccExePath = buildData[bData.bStr.gccExePath]