def copyModuleIndex(srcRoot, dstRoot): """ Copies all <srcDIT>/Modules/Index/*.def and <srcDIT>/Modules/Index/*.py files to <dstSIT>/Modules/Index/ """ Any.requireIsDir(srcRoot) Any.requireIsDir(dstRoot) srcDir = os.path.join(srcRoot, 'Modules', 'Index') dstDir = os.path.join(dstRoot, 'Modules', 'Index') # For the case that srcRoot is an SIT proxy: Some people do not have # any files in their Index directory, furthermore the directory could # be entirely missing if never a BBCM had been installed into the # user's proxy # # Any.requireIsDirNonEmpty( srcDir ) FastScript.mkdir(dstDir) for srcFile in FastScript.getFilesInDir(srcDir): if srcFile.endswith(".def") or srcFile.endswith(".py"): fileName = os.path.basename(srcFile) srcPath = os.path.join(srcDir, fileName) dstPath = os.path.join(dstDir, fileName) FastScript.copy(srcPath, dstPath)
def run(self): if not 'category' in self.values: self.values['category'] = 'External' if not 'buildRules' in self.values: self.values[ 'buildRules'] = '''# This is a dummy file needed by various aux. scripts. # # The actual build instructions can be found in the compile.sh. ''' self.createMainPackage() srcDir = os.path.join(self.templateDir, 'External_without_compilation') dstDir = self.dstDir for fileName in FastScript.getFilesInDir(srcDir, '.php'): srcFile = os.path.join(srcDir, fileName) dstFile = os.path.join(dstDir, fileName) self.copyVerbatim(srcFile, dstFile) self.copyVerbatim(os.path.join(srcDir, 'pkgInfo.py'), os.path.join(dstDir, 'pkgInfo.py')) FastScript.remove(os.path.join(dstDir, 'unittest.sh')) # create exemplarily (fake-)tarball file, and interface-symlink to it tarball = os.path.join(dstDir, 'src', 'Example-1.0-precompiled.tar.bz2') symlink = os.path.join(dstDir, 'src', 'package.tar.bz2') logging.info('processing %s' % tarball) FastScript.setFileContent(tarball, '') logging.info('processing %s' % symlink) os.symlink('Example-1.0-precompiled.tar.bz2', symlink) # create basic packageVar.cmake # # Note: for some reason calling FastScript.changeDirectory() with rel. path failed, # continuing with absolute path as workaround dstDir = os.path.abspath(dstDir) Any.requireIsDir(dstDir) details = PackageDetector(dstDir) details.retrieveMakefileInfo() fileName = os.path.join(dstDir, 'packageVar.cmake') PackageVarCmakeWriter(details).write(fileName)
def run(self): if not 'category' in self.values: self.values['category'] = 'External' self.createMainPackage() srcDir = os.path.join(self.templateDir, 'External_CMake_out_of_tree_build') dstDir = self.dstDir for fileName in FastScript.getFilesInDir(srcDir, '.php'): srcFile = os.path.join(srcDir, fileName) dstFile = os.path.join(dstDir, fileName) self.copyVerbatim(srcFile, dstFile) self.copyVerbatim(os.path.join(srcDir, 'pkgInfo.py'), os.path.join(dstDir, 'pkgInfo.py')) FastScript.remove(os.path.join(dstDir, 'unittest.sh')) # create exemplarily (fake-)tarball file, and interface-symlink to it tarball = os.path.join(dstDir, 'src', 'Example-1.0-src.tar.bz2') symlink = os.path.join(dstDir, 'src', 'sources.tar.bz2') logging.info('processing %s' % tarball) FastScript.setFileContent(tarball, '') logging.info('processing %s' % symlink) os.symlink('Example-1.0-src.tar.bz2', symlink) # create basic packageVar.cmake # # Note: for some reason calling FastScript.changeDirectory() with rel. path failed, # continuing with absolute path as workaround dstDir = os.path.abspath(dstDir) Any.requireIsDir(dstDir) details = PackageDetector(dstDir) details.retrieveMakefileInfo() fileName = os.path.join(dstDir, 'packageVar.cmake') PackageVarCmakeWriter(details).write(fileName)
def _patchCIA989( self, dryRun=False ): """ Removes legacy ANY_DEF_*_TAG macros. """ if self.details.canonicalPath.find( 'DevelopmentTools/ToolBOS' ) == -1 and \ self.details.canonicalPath.find( 'Libraries/ToolBOSLib' ) == -1 and \ self.details.canonicalPath.find( 'Applications/ToolBOS' ) == -1: result = [] ticket = 'CIA-989' pkgNameUpper = self.details.packageName.upper() srcTagPattern = re.compile( '(ANY_DEF_SRCTAG\s?\(.*?\);)', re.DOTALL ) for fileName in FastScript.getFilesInDir( 'src' ): fileName = os.path.join( 'src', fileName ) modified = False new = '' old = 'ANY_DEF_BINTAG;\n' if self._replace( fileName, old, old, new, ticket, dryRun ): modified |= True old = '/* File tag */\n' if self._replace( fileName, old, old, new, ticket, dryRun ): modified |= True old = '/*---------------------------------------------*/\n' + \ '/* File tag */\n' + \ '/*---------------------------------------------*/\n' if self._replace( fileName, old, old, new, ticket, dryRun ): modified |= True old = '#define %s_C_SRCTAG\n' % pkgNameUpper if self._replace( fileName, old, old, new, ticket, dryRun ): modified |= True old = '#undef %s_C_SRCTAG\n' % pkgNameUpper if self._replace( fileName, old, old, new, ticket, dryRun ): modified |= True content = FastScript.getFileContent( fileName ) tmp = srcTagPattern.search( content ) if tmp: old = tmp.group(1) if self._replace( fileName, old, old, new, ticket, dryRun ): modified |= True # use the occasion and replace some more clutter old = '/* Temporary solution for a local debug level */\n' if self._replace( fileName, old, old, new, ticket, dryRun ): modified |= True # remove too many empty lines left-over from previous replacements if modified: old = '\n\n\n\n\n' new = '\n\n' self._replace( fileName, old, old, new, ticket, dryRun ) result.append( fileName ) else: logging.info( 'skipping ToolBOS packages to not patch backward-compatibility layers' ) return []
def addMainPackage( index, canonicalPath ): """ LibIndex filter function similar to addLibraries(), but will also add the "bin" directory. It keeps the original directory structure. """ Any.requireIsTextNonEmpty( canonicalPath ) Any.requireIsList( index.platforms ) if canonicalPath in index.pkgList: logging.debug( 'skipping %s (already added)' % canonicalPath ) return else: logging.debug( 'adding %s' % canonicalPath ) index.pkgList.append( canonicalPath ) installRoot = index.sitPath + os.sep + canonicalPath Any.requireMsg( os.path.exists( installRoot ), "%s: No such package in SIT" % installRoot ) linkAll_fileName = installRoot + os.sep + 'LinkAllLibraries' linkAll = os.path.exists( linkAll_fileName ) match = fnmatch.fnmatch if linkAll: logging.debug( "%s: LinkAllLibraries found" % canonicalPath ) for platform in index.platforms: tail = 'lib' + os.sep + platform libDir = installRoot + os.sep + tail fileList = FastScript.getFilesInDir( libDir ) for fileName in fileList: filePath = libDir + os.sep + fileName if ( linkAll == True ) or \ ( match( fileName, '*.so.*.*' ) == True ) or \ ( match( fileName, '*.dll*' ) == True ) or \ ( match( fileName, '*.so*' ) == True and os.path.islink( filePath ) == False ) or \ ( match( fileName, '*.lib*' ) == True and os.path.islink( filePath ) == False ): srcFile_abs = filePath dstFile_rel = tail + os.sep + fileName if srcFile_abs not in index.fileDict.keys(): index.addFile( srcFile_abs, dstFile_rel ) tail = 'bin' + os.sep + platform binDir = installRoot + os.sep + tail fileList = FastScript.getFilesInDir( binDir ) for fileName in fileList: srcFile_abs = binDir + os.sep + fileName dstFile_rel = tail + os.sep + fileName if srcFile_abs not in index.fileDict.keys(): index.addFile( srcFile_abs, dstFile_rel )
def fuseIntoSingleDirectory( index, canonicalPath ): """ This LibIndex filter function differs from the RTBOS LibIndex filter function in the following way: *All* regular files and symlinks from the lib directories (in both normal and inverse directory layout style) get fused into the same single output directory. This implies that Matlab Mexfiles are included, too. Note that Python *.egg files are excluded for now (no need). The files skipLibIndex and linkAllLibraries are not considered. """ Any.requireIsTextNonEmpty( canonicalPath ) Any.requireIsList( index.platforms ) if canonicalPath in index.pkgList: logging.debug( 'skipping %s (already added)' % canonicalPath ) return else: logging.debug( 'adding %s' % canonicalPath ) index.pkgList.append( canonicalPath ) installRoot = index.sitPath + os.sep + canonicalPath Any.requireMsg( os.path.exists( installRoot ), "%s: No such package in SIT" % installRoot ) #--- above this line it is equal to addLibraries(), below is specific --- # standard directory layout (lib/<platform>) for platform in index.platforms: tail = 'lib' + os.sep + platform libDir = installRoot + os.sep + tail fileList = FastScript.getFilesInDir( libDir ) for fileName in fileList: srcFile_abs = libDir + os.sep + fileName dstFile_rel = platform + os.sep + fileName if not fileName.endswith( '.egg-info' ) and \ not fileName.endswith( '.py' ) and \ not fileName.endswith( '.pth' ) and \ srcFile_abs not in index.fileDict.keys(): index.addFile( srcFile_abs, dstFile_rel ) # reversed directory layout (<platform>/lib), as in OpenCV or Python for platform in index.platforms: tail = platform + os.sep + 'lib' libDir = installRoot + os.sep + tail fileList = FastScript.getFilesInDir( libDir ) for fileName in fileList: srcFile_abs = libDir + os.sep + fileName dstFile_rel = platform + os.sep + fileName if not fileName.endswith( '.egg-info' ) and \ not fileName.endswith( '.py' ) and \ not fileName.endswith( '.pth' ) and \ srcFile_abs not in index.fileDict.keys(): index.addFile( srcFile_abs, dstFile_rel ) # main programs for platform in index.platforms: tail = 'bin' + os.sep + platform libDir = installRoot + os.sep + tail fileList = FastScript.getFilesInDir( libDir ) for fileName in fileList: srcFile_abs = libDir + os.sep + fileName dstFile_rel = platform + os.sep + fileName if srcFile_abs not in index.fileDict.keys(): index.addFile( srcFile_abs, dstFile_rel )
def addLibraries( index, canonicalPath ): """ LibIndex filter function which will generate an RTBOS-compatible index directory. It searches for: * <canonicalPath>/lib/${MAKEFILE_PLATFORM} * <canonicalPath>/${MAKEFILE_PLATFORM}/lib If a file <canonicalPath>/SkipLibIndex exists, this package will be ignored. If a file <canonicalPath>/LinkAllLibraries exists, all libraries in the above directories will be indexed. By default it will only search for a "libMyPackage.1.0.so" (package name / version). It will keep the original directory structure. """ Any.requireIsTextNonEmpty( canonicalPath ) Any.requireIsList( index.platforms ) if canonicalPath in index.pkgList: logging.debug( 'skipping %s (already added)' % canonicalPath ) return else: logging.debug( 'adding %s' % canonicalPath ) index.pkgList.append( canonicalPath ) installRoot = index.sitPath + os.sep + canonicalPath Any.requireMsg( os.path.exists( installRoot ), "%s: No such package in SIT" % installRoot ) linkAll_fileName = installRoot + os.sep + 'LinkAllLibraries' linkAll = os.path.exists( linkAll_fileName ) if linkAll: logging.debug( "%s: LinkAllLibraries found" % canonicalPath ) # standard directory layout (lib/<platform>) match = fnmatch.fnmatch for platform in index.platforms: tail = 'lib' + os.sep + platform libDir = installRoot + os.sep + tail fileList = FastScript.getFilesInDir( libDir ) for fileName in fileList: filePath = libDir + os.sep + fileName if ( linkAll == True ) or \ ( match( fileName, '*.so.*.*' ) == True ) or \ ( match( fileName, '*.syms' ) == True ) or \ ( match( fileName, '*.dll*' ) == True ) or \ ( match( fileName, '*.so*' ) == True and os.path.islink( filePath ) == False ) or \ ( match( fileName, '*.lib*' ) == True and os.path.islink( filePath ) == False ): srcFile_abs = filePath dstFile_rel = tail + os.sep + fileName if srcFile_abs not in index.fileDict.keys(): index.addFile( srcFile_abs, dstFile_rel ) # reversed directory layout (<platform>/lib), as in OpenCV or Python for platform in index.platforms: tail = platform + os.sep + 'lib' libDir = installRoot + os.sep + tail fileList = FastScript.getFilesInDir( libDir ) for fileName in fileList: filePath = libDir + os.sep + fileName # the filename patterns below have been taken 1:1 from original # PHP implementation if ( linkAll == True ) or \ ( match( fileName, '*.so.*.*' ) == True ) or \ ( match( fileName, '*.dll*' ) == True ) or \ ( match( fileName, '*.so*' ) == True and os.path.islink( filePath ) == False ) or \ ( match( fileName, '*.lib*' ) == True and os.path.islink( filePath ) == False ): srcFile_abs = filePath dstFile_rel = tail + os.sep + fileName if srcFile_abs not in index.fileDict.keys(): index.addFile( srcFile_abs, dstFile_rel )