def validateToolchain(self, configNode): toolchainId = None toolchainNode = None if self.toolchainId != None: toolchainId = self.toolchainId if CommonApplication.isObjectById(toolchainId): toolchainNode = CommonApplication.getObjectById(toolchainId) else: print 'ERROR: param toolchain \'{0}\' not found, ignored'.format( toolchainId) toolchainId = None if toolchainId == None: toolchainId = configNode.getToolchainId() if toolchainId != None and CommonApplication.isObjectById( toolchainId): toolchainNode = CommonApplication.getObjectById(toolchainId) else: print 'ERROR: config toolchain \'{0}\' not found, ignored'.format( toolchainId) toolchainId = None if toolchainNode == None: raise ErrorWithDescription( 'Mandatory toolchain definition missing, quitting') return (toolchainNode, toolchainId)
def process(self): print print '* The dumpConfig tool (part of the XCDL framework) *' print "* Dump the configuration trees *" print if self.verbosity > 1: print 'Verbosity level {0}'.format(self.verbosity) print repoFolderAbsolutePathList = [] if self.configFilePath != None: (configTreesList,repoFolderAbsolutePathList) = self.parseConfigurationFile(self.configFilePath, -1) self.packagesAbsolutePathList.extend(repoFolderAbsolutePathList) print repositoriesList = self.parseRepositories(self.packagesAbsolutePathList, -1) print self.dumpTree(repositoriesList, False) if self.configFilePath != None: print self.dumpConfiguration(configTreesList) if self.desiredConfigurationId != None: print configNode = self.loadConfiguration(configTreesList, self.desiredConfigurationId, -1) print print 'Build preprocessor symbols dictionary...' count = self.processSymbolsDict(repositoriesList) print '- {0} symbol(s) processed.'.format(count) print print 'Process initial \'isEnabled\' properties' self.processInitialIsEnabled(repositoriesList) print print 'Process \'requires\' properties' self.processRequiresProperties(repositoriesList, configNode, False) CommonApplication.clearErrorCount() self.processRequiresProperties(repositoriesList, configNode, False) count = CommonApplication.getErrorCount() if count > 0: print '{0} error(s) encountered'.format(count) print self.dumpTree(repositoriesList, True) print self.dumpPreprocessorDefinitions(repositoriesList) print self.dumpSourceFiles(repositoriesList) return
def run(self): try: (opts, args) = getopt.getopt(self.argv[1:], 'c:r:i:b:t:lhv', [ 'config=', 'repository=', 'id=', 'build=', 'toolchain=', 'linearise', 'help', 'verbose' ]) except getopt.GetoptError as err: # print help information and exit: print str( err) # will print something like "option -a not recognised" self.usage() return 2 retval = 0 try: if len(args) > 0: print 'Unused arguments: ' for arg in args: print '\t{0}'.format(arg) self.usage() return 2 for (o, a) in opts: #a = a if o in ('-c', '--config'): self.configFilePath = a elif o in ('-r', '--repository'): self.packagesAbsolutePathList.append(a) elif o in ('-i', '--id'): self.desiredConfigurationId = a elif o in ('-b', '--build'): self.outputFolder = a elif o in ('-t', '--toolchain'): self.toolchainId = a elif o in ('-l', '--linearise'): self.doLinearise = True elif o in ('-v', '--verbose'): self.verbosity += 1 elif o in ('-h', '--help'): self.usage() return 0 else: assert False, 'option not handled' CommonApplication.setVerbosity(self.verbosity) self.process() except ErrorWithDescription as err: print 'ERROR: {0}'.format(err) retval = 1 finally: if self.verbosity > 0: print print '[done]' return retval
def run(self): try: (opts, args) = getopt.getopt(self.argv[1:], 'c:p:i:hv', ['config=', 'packages=', 'id=', 'help', 'verbose']) except getopt.GetoptError as err: # print help information and exit: print str(err) # will print something like "option -a not recognised" self.usage() return 2 retval = 0 try: if len(args) > 0: print 'unused arguments: ', args self.usage() return 2 for (o, a) in opts: #a = a if o in ('-c', '--config'): self.configFilePath = a elif o in ('-p', '--packages'): self.packagesAbsolutePathList.append(a) elif o in ('-i', '--id'): self.desiredConfigurationId = a elif o in ('-v', '--verbose'): self.verbosity += 1 elif o in ('-h', '--help'): self.usage() return 0 else: assert False, 'option not handled' CommonApplication.setVerbosity(self.verbosity) self.process() except ErrorWithDescription as err: print 'ERROR: {0}'.format(err) retval = 1 finally: print print '[done]' return retval
def run(self): try: (opts, args) = getopt.getopt(self.argv[1:], 'r:c:b:lW:hva', [ 'repository=', 'build_config=', 'build_dir=', 'linearise', 'help', 'verbose', 'always']) except getopt.GetoptError as err: # print help information and exit: print str(err) # will print something like "option -a not recognised" self.usage() return 2 retval = 0 try: if len(args) == 1: self.makeTarget = args[0] elif len(args) > 0: print 'Unused arguments: ' for arg in args: print '\t{0}'.format(arg) self.usage() return 2 for (o, a) in opts: # a = a if o in ('-r', '--repository'): self.packagesAbsolutePathList.append(a) elif o in ('-c', '--build_config'): self.desiredConfigurationName = a elif o in ('-b', '--build_dir'): self.outputFolder = a elif o in ('-l', '--linearise'): self.doLinearise = True elif o in ('-a', '--always'): self.ignoreTimestamps = True elif o in ('-v', '--verbose'): self.verbosity += 1 elif o in ('-h', '--help'): self.usage() return 0 elif o in ('-W'): aa = a.split(',') if aa[0] == 'm': self.makeArguments = aa[1:] elif aa[0] == 'r': self.runArguments = aa[1:] else: assert False, 'option -W{0} not handled'.format(a) elif o in ('all', 'clean'): #print o pass else: assert False, 'option not handled' CommonApplication.setVerbosity(self.verbosity) retval = self.process() except ErrorWithoutDescription as err: retval = 1 except ErrorWithDescription as err: print 'ERROR: {0}'.format(err) retval = 1 except Exception: if True: traceback.print_exc(file=sys.stdout) traceback.print_exc() retval = 3 finally: if self.verbosity > 0: print print '[done]' return retval
def processAndCreate(self, repositoriesList, configNode, outputSubFolder, toolchainNode): if self.verbosity > 0: print configNode = self.loadBuildConfiguration(configNode, 0) # enable configuration nodes too, for a more uniform processing # (of CopyFiles, for example) configNode.setIsEnabledWithCountRecursive() if self.verbosity > 0: print print 'Build preprocessor symbols dictionary...' count = self.processSymbolsDict(repositoriesList) if self.verbosity > 0: print '- {0} symbol(s) processed.'.format(count) if self.verbosity > 0: print print 'Evaluate the initial \'isEnabled\' expressions, if any...' self.processInitialIsEnabled(repositoriesList) if self.verbosity > 0: print print 'Process the \'requirements\' properties...' self.processRequiresProperties(repositoriesList, configNode, False) # and one more time, to report remaining errors CommonApplication.clearErrorCount() self.processRequiresProperties(repositoriesList, configNode, True) count = CommonApplication.getErrorCount() if count > 0: raise ErrorWithDescription('Errors encountered or requirement not satisfied, cannot continue') if self.verbosity > 1: print self.dumpTree(repositoriesList, True) if not os.path.isdir(self.outputFolder): os.makedirs(self.outputFolder) # print outputSubFolder CommonApplication.clearErrorCount() if self.verbosity > 0: print print 'Generate header files...' self.generatePreprocessorDefinitions(repositoriesList, self.outputFolder, outputSubFolder) if self.verbosity > 0: print print 'Copy custom files...' self.copyCustomFiles(repositoriesList, configNode, self.outputFolder, outputSubFolder) if self.verbosity > 0: print print 'Using toolchain \'{0}\'.'.format(toolchainNode.getName()) if self.verbosity > 0: print print 'Generate GNU Make files...' # 'makefile' must be the last file written self.generateAllMakeFiles(repositoriesList, configNode, toolchainNode, self.outputFolder, outputSubFolder) count = CommonApplication.getErrorCount() if count > 0: raise ErrorWithoutDescription() return toolchainNode
def process(self): if self.verbosity > 0: print print '* The configMakefiles tool (part of the XCDL framework) *' print '* Create the build folders with distributed GNU Make files *' print if self.verbosity > 1: print 'Verbosity level {0}'.format(self.verbosity) print self.validate() (configTreesList, repoFolderAbsolutePathList) = self.parseConfigurationFile( self.configFilePath, 0) self.packagesAbsolutePathList.extend(repoFolderAbsolutePathList) if self.verbosity > 1: print self.dumpConfiguration(configTreesList) if self.verbosity > 0: print repositoriesList = self.parseRepositories( self.packagesAbsolutePathList, 0) if self.verbosity > 1: print self.dumpTree(repositoriesList, False) if self.verbosity > 0: print configNode = self.loadConfiguration(configTreesList, self.desiredConfigurationId, 0) if self.verbosity > 0: print print 'Build preprocessor symbols dictionary...' count = self.processSymbolsDict(repositoriesList) if self.verbosity > 0: print '- {0} symbol(s) processed.'.format(count) if self.verbosity > 0: print print 'Evaluate the initial \'isEnabled\' expressions, if any...' self.processInitialIsEnabled(repositoriesList) if self.verbosity > 0: print print 'Process the \'requirements\' properties...' self.processRequiresProperties(repositoriesList, configNode, False) # and one more time, to report remaining errors CommonApplication.clearErrorCount() self.processRequiresProperties(repositoriesList, configNode, True) count = CommonApplication.getErrorCount() if count == 1: raise ErrorWithDescription('1 requirement not satisfied, quitting') elif count > 1: raise ErrorWithDescription( '{0} requirements not satisfied, quitting'.format(count)) if self.verbosity > 1: print self.dumpTree(repositoriesList, True) if not os.path.isdir(self.outputFolder): os.makedirs(self.outputFolder) outputSubFolder = configNode.getBuildFolderRecursiveWithSubstitutions() if self.doLinearise: outputSubFolder = outputSubFolder.replace(os.sep, '_') #print outputSubFolder if self.verbosity > 0: print print 'Generate header files...' self.generatePreprocessorDefinitions( repositoriesList, self.outputFolder, outputSubFolder) (toolchainNode, _) = self.validateToolchain(configNode) if self.verbosity > 0: print print 'Using toolchain \'{0}\'.'.format(toolchainNode.getName()) if self.verbosity > 0: print print 'Generate GNU Make files...' self.generateAllMakeFiles(repositoriesList, configNode, toolchainNode, self.outputFolder, outputSubFolder) return