def __init__(self, appName, defaultDir, userDir, machineDir='/etc', addFiles=None): Any.requireIsDirNonEmpty(defaultDir) Any.requireIsTextNonEmpty(machineDir) Any.requireIsTextNonEmpty(userDir) if addFiles is not None: Any.requireIsListNonEmpty(addFiles) for filePath in addFiles: Any.requireIsText(filePath) # check for existence later fileName = appName + '.conf' self._defaultFile = os.path.join(defaultDir, fileName) self._machineFile = os.path.join(machineDir, fileName) self._userFile = os.path.join(userDir, fileName) self._cwdFile = os.path.join(os.getcwd(), fileName) self._addFiles = addFiles if addFiles is not None else [] Any.requireIsFileNonEmpty(self._defaultFile) self._defaultSettings = {} self._machineSettings = {} self._userSettings = {} self._cwdSettings = {} self._allSettings = {} # load all settings into memory self._readFiles()
def setContent(self, filePath): """ Allows setting content from original file, in order to evolve an existing pkgInfo.py over time. """ Any.requireIsFileNonEmpty(filePath) self.content = FastScript.getFileContent(filePath)
def _open_details(self): logging.debug('dependency detection started') exe = os.path.join(FastScript.getEnv('TOOLBOSCORE_ROOT'), 'include/ZenBuildMode/DependencyDetector.py') Any.requireIsFileNonEmpty(exe) cmd = '%s --quiet %s %s' % (exe, self._bstpkg_src.detector.topLevelDir, self._bstpkg_src.detector.canonicalPath) self._depDetectorData = six.BytesIO() self._depDetector = ProcessExecutor.ProcessExecutor() self._depDetector.setCommand(cmd) self._depDetector.newStdOut.connect(self._onDepDetectorOutput) self._depDetector.newStdErr.connect(self._onDepDetectorError) self._depDetector.finished.connect(self._onDepDetectorFinished) self._depDetector.start() logging.debug( 'dependency detection in progress (helper-process started)') logging.debug('SQ-check setup started') self._sqPreparer = self.QualityCheckPreparationThread(self._bstpkg_src) # noinspection PyUnresolvedReferences self._sqPreparer.finished.connect(self._onSQPreparerFinished) self._sqPreparer.start() self._updateCheckThread = self.UpdatesAvailableThread() self._updateCheckThread.updatesAvailable.connect( self._onUpdatesAvailable) self._updateCheckThread.start()
def test_addGlobalInstallLog( self ): msgType = 'NEW' message = 'Test message (unittest)' # create log entry logEntry = GlobalInstallLog( ToolBOSSettings.canonicalPath, isFirstInstall=False, msgType=msgType, message=message ) fileName = tempfile.mkstemp( prefix='test-' )[1] logEntry.setFileName( fileName ) logEntry.writeFile() Any.requireIsFileNonEmpty( fileName ) content = FastScript.getFileContent( fileName ) # check result self.assertTrue( content.find( msgType ) > 0, "log file incorrect" ) self.assertTrue( content.find( message ) > 0, "log file incorrect" ) # clean-up FastScript.remove( fileName )
def _createMainDoxyfile(self): if self.details.isPythonPackage() and \ getConfigOption( 'BST_useDoxypy' ) == True: fileName = 'Doxyfile-Python' else: fileName = 'Doxyfile' content = '' template = os.path.join(FastScript.getEnv('TOOLBOSCORE_ROOT'), 'etc', fileName) Any.requireIsFileNonEmpty(template) if os.path.isdir(os.path.join(self.details.topLevelDir, 'examples')): logging.debug('doxygen: indexing examples') content += 'EXAMPLE_PATH = ../examples\n' + \ 'EXAMPLE_PATTERNS =\n' + \ 'EXAMPLE_RECURSIVE = YES\n' if self.details.isComponent(): logging.debug('doxygen: indexing src/*.{c,cpp}') content += 'FILE_PATTERNS = *.c *.cpp *.h\n' content = FastScript.getFileContent(template) + content FastScript.setFileContent(self.mainDoxyfile, content)
def getStdSwitches(targetPlatform, targetName): """ Returns a string with the compiler std switch. NOTE: CMake supports that compiler definitions may be different for various target platforms, and even per executable and/or library. Therefore you need to specify both of them. A rule of thumb is targetName='<PROJECTNAME>-global'. """ Any.requireIsTextNonEmpty(targetPlatform) Any.requireIsTextNonEmpty(targetName) # We need defaults because the macro parser needs the switch to # correctly parse c++ code. fileName = os.path.join('build/%s/CMakeFiles/%s.dir/flags.make' % (targetPlatform, targetName)) Any.requireIsDirNonEmpty('build/%s' % targetPlatform) Any.requireIsFileNonEmpty(fileName) # read-in ground truth information logging.debug('parsing %s', fileName) content = FastScript.getFileContent(fileName, splitLines=True) raw_C_CFLAGS = '' raw_CPP_CFLAGS = '' regexp_C_CFLAGS = re.compile(r'^C_FLAGS\s=\s+(.*)$') regexp_CPP_CFLAGS = re.compile(r'^CXX_FLAGS\s=\s+(.*)$') for line in content: tmp = regexp_C_CFLAGS.search(line) if tmp: raw_C_CFLAGS = tmp.group(1) tmp = regexp_CPP_CFLAGS.search(line) if tmp: raw_CPP_CFLAGS = tmp.group(1) # get the default language standards standards = Compilers.getDefaultLanguageStandard(targetPlatform) cStdSwitch = '-std={}'.format(standards['c']) cppStdSwitch = '-std={}'.format(standards['c++']) # look if the user specified different standards in the C_FLAGS/CPP_FLAGS # CMake variables candidates = shlex.split(raw_C_CFLAGS) for candidate in candidates: if candidate.startswith('-std='): cStdSwitch = candidate candidates = shlex.split(raw_CPP_CFLAGS) for candidate in candidates: if candidate.startswith('-std='): cppStdSwitch = candidate return Switches(c=cStdSwitch, cpp=cppStdSwitch)
def parseOutput(statusFile, details): Any.requireIsFileNonEmpty(statusFile) out = etree.parse(statusFile) errors = [errorParser(error, details) for error in out.findall('error')] return bool(errors), errors
def test_proxyInstallation(self): oldcwd = os.getcwd() packageName = 'ExamplePackage' packageVersion = '1.0' category = 'Applications' projectRoot = os.path.join('.', packageName, packageVersion) output = StringIO() if Any.getDebugLevel() <= 3 else None platform = Platforms.getHostPlatform() sitPath = SIT.getPath() # build + install package FastScript.changeDirectory(projectRoot) bst = BuildSystemTools() bst.setStdOut(output) bst.setStdErr(output) bst.compile() Any.requireIsDirNonEmpty('build') Any.requireIsDirNonEmpty(os.path.join('build', platform)) Any.requireIsDirNonEmpty('examples') Any.requireIsDirNonEmpty(os.path.join('examples', platform)) for fileName in ('ThreadingExampleAtomicOperation', 'ThreadingExampleJoin', 'ThreadingExampleTraps'): Any.requireIsFileNonEmpty(os.path.join('bin', platform, fileName)) if not ProxyDir.isProxyDir(sitPath): self.skip("%s: Is not a proxy directory" % sitPath) bst.makeDocumentation() bst.proxyInstall() installRoot = os.path.join(sitPath, category, packageName, packageVersion) # check result Any.requireIsDir(installRoot) Any.requireIsDirNonEmpty(os.path.join(installRoot, 'bin', platform)) Any.requireIsDirNonEmpty(os.path.join(installRoot, 'doc/html')) Any.requireIsFileNonEmpty( os.path.join(installRoot, 'doc/html/index.html')) Any.requireIsFileNonEmpty(os.path.join(installRoot, 'pkgInfo.py')) Any.requireIsFileNonEmpty(os.path.join(installRoot, 'packageVar.cmake')) for fileName in ('ThreadingExampleAtomicOperation', 'ThreadingExampleJoin', 'ThreadingExampleTraps'): Any.requireIsFileNonEmpty( os.path.join(installRoot, 'bin', platform, fileName)) # clean-up bst.uninstall(cleanGlobalInstallation=False) bst.distclean() self.assertFalse(os.path.exists(installRoot)) FastScript.changeDirectory(oldcwd)
def _getConfigOptionFromFile(varName, fileName): """ This function attempts to find a variable 'varName' defined in the file 'fileName'. """ Any.requireIsTextNonEmpty(varName) Any.requireIsFileNonEmpty(fileName) value = FastScript.execFile(fileName)[varName] return value
def getIncludePathsAsString(targetPlatform, targetName): """ Returns a long string with all include paths set for the package using include_directories() in CMakeLists.txt (in this package or included ones). This means all paths where the compiler would search for header files (beside system defaults), in the form "-I/path1 -I/path2...". If no additional paths are set, an empty string will be returned. NOTE: CMake supports that include directories may be different for various target platforms, and even per executable and/or library. Therefore you need to specify both of them. A rule of thumb is targetName='<PROJECTNAME>-global'. """ Any.requireIsTextNonEmpty(targetPlatform) Any.requireIsTextNonEmpty(targetName) fileName = os.path.join('build/%s/CMakeFiles/%s.dir/flags.make' % (targetPlatform, targetName)) Any.requireIsDirNonEmpty('build/%s' % targetPlatform) Any.requireIsFileNonEmpty(fileName) # read-in ground truth information logging.debug('parsing %s' % fileName) content = FastScript.getFileContent(fileName, splitLines=True) raw_C = '' raw_CPP = '' regexp_C = re.compile('^(?:C_FLAGS|C_INCLUDES)\s=\s+(.*)$') regexp_CPP = re.compile('^(?:CXX_FLAGS|CXX_INCLUDES)\s=\s+(.*)$') result = '' for line in content: tmp = regexp_C.search(line) if tmp: raw_C = tmp.group(1) # logging.debug( 'raw C flags: %s' % raw_C ) tmp = regexp_CPP.search(line) if tmp: raw_CPP = tmp.group(1) # logging.debug( 'raw CPP flags: %s' % raw_CPP ) for candidate in (shlex.split(raw_C) + shlex.split(raw_CPP)): if candidate.startswith('-I'): result += candidate + ' ' return result
def _switchEnv_toMinGW(targetPlatform): fileName = os.path.join(FastScript.getEnv('TOOLBOSCORE_ROOT'), 'include', 'CMake', 'MinGW-linux.cmake') Any.requireIsFileNonEmpty(fileName) FastScript.setEnv('TARGETOS', 'windows') FastScript.setEnv('TARGETARCH', targetPlatform) FastScript.setEnv('COMPILER', 'gcc') FastScript.setEnv('MINGW_PLATFORM', targetPlatform) FastScript.setEnv('MAKEFILE_PLATFORM', targetPlatform) oldOptions = FastScript.getEnv('BST_CMAKE_OPTIONS') or '' newOptions = '-DCMAKE_TOOLCHAIN_FILE:FILEPATH=%s %s' % (fileName, oldOptions) FastScript.setEnv('BST_CMAKE_OPTIONS', newOptions)
def _msvc2012SpecificChecks(): if not os.path.exists(os.path.join(configDir, 'user.reg')): setupWineDotNet(configDir, postfix) linkPath = os.path.join(configDir, 'drive_c', 'msvc-sdk') if not os.path.exists(linkPath): # considers broken links logging.debug('%s not found', linkPath) setupMSVC(configDir, sdk) # sometimes it happens that the registry gets screwed up userReg = os.path.join(configDir, 'user.reg') Any.requireIsFileNonEmpty(userReg) content = FastScript.getFileContent(userReg) if content.find('1413877490') == -1: logging.debug('found broken registry: rebuilding %s', configDir) setupMSVC(configDir, sdk)
def test_serializeUtility_convert(self): tcRoot = FastScript.getEnv('TOOLBOSCORE_ROOT') platform = Platforms.getHostPlatform() exe = os.path.join(tcRoot, 'bin', platform, 'ConvertSerializedData') inFile = 'BBDMArrayBlockF32-binary.ser' outFile = tempfile.mkstemp(prefix='test-')[1] cmd = '%s -i %s -f Ascii -o %s' % (exe, inFile, outFile) tmp = StringIO() try: FastScript.execProgram(cmd, stdout=tmp, stderr=tmp) except OSError: raise RuntimeError("Please compile this package first!") output = tmp.getvalue() # typical error could be: # # [... SerializeUtility.c:809 Error] Could not load data library # 'BBDMArrayBlockF32' (libBBDMArrayBlockF32.so): Reason # 'libBBDMArrayBlockF32.so: cannot open shared object file: # No such file or directory' # # [... SerializeUtility.c:653 Error] The input file # 'test/miscInputFiles/BBDMArrayBlockF32-binary.ser' # does not contain valid data # check result self.assertTrue(output.find('libBBDMArrayBlockF32.so') == -1) self.assertTrue(output.find('Could not load data library') == -1) self.assertTrue(output.find('No such file or directory') == -1) self.assertTrue( output.find('Aborting serialization function') > 0) # at EOF self.assertTrue(output.find('does not contain valid data') == -1) Any.requireIsFileNonEmpty(outFile) content = FastScript.getFileContent(outFile) # there must be 3x "HRIS" in the ASCII representation of this file matches = re.findall('HRIS', content) self.assertTrue(len(matches) == 3) # clean-up FastScript.remove(outFile)
def test_serializeUtility_createSerializedData(self): random.seed(self) tcRoot = FastScript.getEnv('TOOLBOSCORE_ROOT') platform = Platforms.getHostPlatform() exe = os.path.join(tcRoot, 'bin', platform, 'CreateSerializedData') count = random.randint(3, 20) outFile = tempfile.mkstemp(prefix='test-')[1] cmd = '%s -t BBDMArrayBlockF32 -c %d -r -f Ascii -o %s' % (exe, count, outFile) tmp = StringIO() try: FastScript.execProgram(cmd, stdout=tmp, stderr=tmp) except OSError: raise RuntimeError("Please compile this package first!") output = tmp.getvalue() # typical error could be: # # [... SerializeUtility.c:809 Error] Could not load data library # 'BBDMBaseF32' (libBBDMBaseF32.so): Reason 'libBBDMBaseF32.so: # cannot open shared object file: No such file or directory' # # SerializeUtility.c:1083 BBDMBaseF32: unsupported datatype # (BBDMBaseF32_new() not found) # check result self.assertTrue(output.find('libBBDMArrayBlockF32.so') == -1) self.assertTrue(output.find('cannot open shared object file') == -1) self.assertTrue(output.find('No such file or directory') == -1) self.assertTrue(output.find('unsupported datatype') == -1) Any.requireIsFileNonEmpty(outFile) content = FastScript.getFileContent(outFile) # we must find "count"-times the keyword "HRIS" inside the file matches = re.findall('HRIS', content) self.assertTrue(len(matches) == count) # clean-up FastScript.remove(outFile)
def test_serializeUtility_printSerializedData(self): tcRoot = FastScript.getEnv('TOOLBOSCORE_ROOT') platform = Platforms.getHostPlatform() exe = os.path.join(tcRoot, 'bin', platform, 'PrintSerializedData') inFile = os.path.join('BBDMArrayBlockF32-binary.ser') outFile = os.path.join('BBDMArrayBlockF32-ascii.ser') cmd = '%s -f %s' % (exe, inFile) tmp = StringIO() Any.requireIsFileNonEmpty(inFile) Any.requireIsFileNonEmpty(outFile) try: # do not redirect stderr to file, otherwise we can't compare with # the expected output (ANY_LOG timestamps would differ), there is # at least stderr-message "Aborting serialization function" at EOF FastScript.execProgram(cmd, stdout=tmp) except OSError: raise RuntimeError("Please compile this package first!") expected = FastScript.getFileContent(outFile) output = tmp.getvalue() # typical error could be: # # [... SerializeUtility.c:809 Error] Could not load data library # 'BBDMArrayBlockF32' (libBBDMArrayBlockF32.so): Reason # 'libBBDMArrayBlockF32.so: cannot open shared object file: # No such file or directory' # # [... SerializeUtility.c:591 Error] The input file # 'test/miscInputFiles/BBDMArrayBlockF32-binary.ser' does not # contain valid data # check result self.assertTrue(output.find('libBBDMArrayBlockF32.so') == -1) self.assertTrue(output.find('cannot open shared object file') == -1) self.assertTrue(output.find('No such file or directory') == -1) self.assertTrue(output.find('does not contain valid data') == -1) self.assertEqual(expected, output)
def setupLegacyMSVC(configDir): from ToolBOSCore.Storage.SIT import getPath sitRootPath = getPath() packageName = 'Data/wine.net/0.1' handmadeDir = os.path.join(sitRootPath, packageName, 'config') userName = FastScript.getCurrentUserName() if not os.path.exists(handmadeDir): raise AssertionError('%s: No such package in SIT' % packageName) if not userName: raise AssertionError('Unable to query username :-(') # replace 'Program Files' and 'windows' directories in configDir by # symlinks to handmade directories in SIT for item in ('Program Files', 'windows'): path = os.path.join(configDir, 'drive_c', item) Any.requireIsDir(path) FastScript.remove(path) target = os.path.join(handmadeDir, 'drive_c', item) FastScript.link(target, path) # copy all the handmade *.reg files regFiles = glob.glob("%s/*.reg" % handmadeDir) Any.requireIsListNonEmpty(regFiles) for srcFilePath in regFiles: fileName = os.path.basename(srcFilePath) dstFilePath = os.path.join(configDir, fileName) logging.debug('cp %s %s', srcFilePath, dstFilePath) shutil.copyfile(srcFilePath, dstFilePath) Any.requireIsFileNonEmpty(dstFilePath) # replace occurrences of 'roberto' by username oldContent = FastScript.getFileContent(dstFilePath) newContent = oldContent.replace('roberto', userName) FastScript.setFileContent(dstFilePath, newContent)
def test_makeDocumentation( self ): tmpDir = tempfile.mkdtemp( prefix='test-' ) packageName = 'HelloWorld' packageVersion = '42.0' projectRoot = os.path.join( tmpDir, packageName, packageVersion ) # create package on-the-fly PackageCreator_C_Library( packageName, packageVersion, outputDir=tmpDir ).run() Any.requireIsDirNonEmpty( tmpDir ) # create docu output = StringIO() if Any.getDebugLevel() <= 3 else None d = DocumentationCreator( projectRoot, stdout=output, stderr=output ) d.generate() # check result Any.requireIsDirNonEmpty( os.path.join( projectRoot, 'doc' ) ) Any.requireIsDirNonEmpty( os.path.join( projectRoot, 'doc/html' ) ) Any.requireIsFileNonEmpty( os.path.join( projectRoot, 'doc/html/index.html' ) ) Any.requireIsFileNonEmpty( os.path.join( projectRoot, 'doc/html/doxygen.css' ) ) Any.requireIsFileNonEmpty( os.path.join( projectRoot, 'doc/html/doxygen.png' ) ) FastScript.remove( tmpDir )
def getDependenciesFromCurrentPackage(recursive=False, systemPackages=False): """ Assuming the current working directory to be a source package, it queries the dependencies and optionally all the recursive dependencies, too. """ from ToolBOSCore.Storage import CMakeLists from ToolBOSCore.Storage.PkgInfo import getPkgInfoContent Any.requireIsBool(recursive) Any.requireIsBool(systemPackages) fileName = 'CMakeLists.txt' Any.requireIsFileNonEmpty(fileName) fileContent = FastScript.getFileContent(fileName) Any.requireIsTextNonEmpty(fileContent) try: depList = getPkgInfoContent(dirName='.')['depends'] except (AssertionError, IOError, KeyError): depList = CMakeLists.getDependencies(fileContent) Any.requireIsList(depList) if recursive: result = [] cache = {} for dep in depList: result.append(dep) tmp = getDependencies(dep, recursive, cache, systemPackages) if tmp: # do not add empty lists result.append(tmp) else: result = depList return result
def execInAllProjects(command): Any.requireIsTextNonEmpty(command) # determine list of packages (and versions) to visit dirList = [] oldcwd = os.getcwd() if listfile: Any.requireIsFileNonEmpty(listfile) # read subdirectories from file, and remove trailing newlines dirList = FastScript.getFileContent(listfile, splitLines=True) dirList = map(str.strip, dirList) else: noSVN = re.compile("^.svn$") for path in FastScript.getDirsInDirRecursive(excludePattern=noSVN): if os.path.isfile(os.path.join(path, 'CMakeLists.txt')): dirList.append(path) # execute the task for entry in dirList: workingDir = os.path.realpath(os.path.join(oldcwd, entry)) logging.debug('cd %s' % workingDir) logging.info('workingDir=%s', workingDir) FastScript.changeDirectory(workingDir) try: FastScript.execProgram(command) except subprocess.CalledProcessError as e: if ignoreErrors: logging.warning(e) else: raise FastScript.changeDirectory(oldcwd)
def test_jsonSerialization(self): bbmlFile = 'TestSerializeToJSON.bbml' cmlFile = 'TestSerializeToJSON.cml' outputFile = 'serialized.json' # run RTBOS to create JSON-serialized output file Any.requireIsFileNonEmpty(bbmlFile) cmd = 'RTBOS.sh %s' % bbmlFile output = StringIO() if Any.getDebugLevel() <= 3 else None FastScript.remove(outputFile) # ensure it's not there FastScript.execProgram(cmd, stdout=output, stderr=output) # verify output file has been created Any.requireIsFileNonEmpty(outputFile) # check result data = json.load(open(outputFile)) arrayBlock = data['bBDMArrayBlockF32'] self.assertEqual(arrayBlock['m_dims'], 1) self.assertEqual(arrayBlock['m_totalSize'], 2) self.assertEqual(len(arrayBlock['m_data']), arrayBlock['m_totalSize']) self.assertEqual( arrayBlock['elementsPerDimension']['elementsPerDimension'], [2, 0, 0, 0]) for block in arrayBlock['m_data']: self.assertEqual(block['owner'], 1) self.assertEqual(len(block['data']['data']), 16) self.assertEqual(block['size']['width'], 4) self.assertEqual(block['size']['height'], 4) # clean-up FastScript.remove('LibIndex') FastScript.remove(outputFile) FastScript.remove(cmlFile)
def _switchEnv_linuxIntelToARM(targetPlatform): from ToolBOSCore.Settings import ProcessEnv from ToolBOSCore.Settings import ToolBOSSettings Any.requireIsTextNonEmpty(targetPlatform) # source cross-compiler package if not already done bspMap = ToolBOSSettings.getConfigOption('BST_crossCompileBSPs') Any.requireIsDictNonEmpty(bspMap) neededBSP = bspMap[targetPlatform] Any.requireIsTextNonEmpty(neededBSP) ProcessEnv.source(neededBSP) # setup arguments which will be passed to CMake if targetPlatform is 'peakcan': fileName = os.path.join(FastScript.getEnv('TOOLBOSCORE_ROOT'), 'include/CMake/Peakcan-cross.cmake') Any.requireIsFileNonEmpty(fileName) FastScript.setEnv('TARGETOS', 'peakcan') FastScript.setEnv('TARGETARCH', 'peakcan') FastScript.setEnv('COMPILER', 'gcc') FastScript.setEnv('BST_CMAKE_OPTIONS', '-DCMAKE_TOOLCHAIN_FILE=%s' % fileName) elif targetPlatform is 'phyboardwega': fileName = os.path.join(FastScript.getEnv('TOOLBOSCORE_ROOT'), 'include/CMake/phyBOARD-WEGA-cross.cmake') Any.requireIsFileNonEmpty(fileName) FastScript.setEnv('TARGETOS', 'phyboardwega') FastScript.setEnv('TARGETARCH', 'phyboardwega') FastScript.setEnv('COMPILER', 'gcc') FastScript.setEnv('BST_CMAKE_OPTIONS', '-DCMAKE_TOOLCHAIN_FILE=%s' % fileName) else: fileName = os.path.join(FastScript.getEnv('TOOLBOSCORE_ROOT'), 'include/CMake/Linux-ARMv7-cross.cmake') Any.requireIsFileNonEmpty(fileName) FastScript.setEnv('TARGETOS', 'linux') FastScript.setEnv('TARGETARCH', 'armv7') FastScript.setEnv('COMPILER', 'gcc') FastScript.setEnv('BST_CMAKE_OPTIONS', '-DCMAKE_TOOLCHAIN_FILE=%s' % fileName)
def _switchEnv_linuxToWindows(targetPlatform): import logging from ToolBOSCore.Settings import ProcessEnv from ToolBOSCore.Settings import UserSetup from ToolBOSCore.Settings import ToolBOSSettings Any.requireIsTextNonEmpty(targetPlatform) def _set_msvc_2017_conf(): UserSetup.ensureMSVCSetup(sdk, postfix='.' + targetPlatform) Any.requireMsg(FastScript.getEnv('WINEPREFIX'), '$WINEPREFIX not set') msvcBasePath = r'c:\BuildTools\VC' msvcToolsBasePath = r'{}\Tools\MSVC\14.13.26128'.format(msvcBasePath) msvcAuxiliaryBasePath = r'{}\Auxiliary\VS'.format(msvcBasePath) wkitBasePath = r'c:\Program Files\Windows Kits\10' wsdkBasePath = r'c:\Program Files\Microsoft SDKs\Windows\v10.0A' wkitVersion = '10.0.16299.0' cpu = 'x64' if targetArch == 'amd64' else 'x86' FastScript.setEnv('TARGETOS', 'windows') FastScript.setEnv('TARGETARCH', targetArch) FastScript.setEnv('COMPILER', 'vs2017') FastScript.setEnv('INCLUDE', r'{}\include'.format(msvcBasePath)) FastScript.setEnv( 'LIB', r'{0}\lib\{3};{0}\lib\onecore\{3};{1}\Lib\{4}\um\{3};{1}\Lib\{4}\ucrt\{3};{2}\Lib' .format(msvcToolsBasePath, wkitBasePath, wsdkBasePath, cpu, wkitVersion)) FastScript.setEnv( 'CL', r'/I"{0}\UnitTest\include" /I"{0}\include" /I"{1}\atlmfc\include" /I"{1}\include" /I"{2}\Include\{3}\ucrt" /I"{2}\Include\{3}\um" /I"{2}\Include\{3}\shared"' .format(msvcAuxiliaryBasePath, msvcToolsBasePath, wkitBasePath, wkitVersion)) FastScript.setEnv( 'CL_CMD', r'{0}\bin\Host{1}\{1}\cl.exe'.format(msvcToolsBasePath, cpu)) FastScript.setEnv( 'LINK_CMD', r'{0}\bin\Host{1}\{1}\link.exe'.format(msvcToolsBasePath, cpu)) FastScript.setEnv('RC_CMD', r'{0}\bin\{1}\rc.Exe'.format(wkitBasePath, cpu)) FastScript.setEnv('MT_CMD', r'{0}\bin\{1}\mt.Exe'.format(wkitBasePath, cpu)) FastScript.setEnv( 'DUMPBIN_CMD', r'{0}\bin\Host{1}\{1}\dumpbin.exe'.format(msvcToolsBasePath, cpu)) FastScript.setEnv( 'WindowsLibPath', r'{0}\UnionMetadata\{1};{0}\References\{1}'.format( wkitBasePath, wkitVersion)) FastScript.setEnv( 'LIBPATH', r'{0}\atlmfc\lib\{2};{0}\lib\{2};{0}\lib\{2}\store\references;{1}\UnionMetadata\{3};{1}\References\{3}' .format(msvcToolsBasePath, wkitBasePath, cpu, wkitVersion)) if cpu == 'x86': compilerBasePath = r'{0}\bin\Hostx86\x86'.format(msvcToolsBasePath) compilerBasePath += r';{0}\bin\Hostx86\x86;{0}\bin\Hostx86\x64\1033;{0}\bin\Hostx86\x86\1033'.format( msvcToolsBasePath) elif cpu == 'x64': compilerBasePath = r'{0}\bin\Hostx64\x64'.format(msvcToolsBasePath) compilerBasePath += r';{0}\bin\Hostx64\x64\1033'.format( msvcToolsBasePath) FastScript.setEnv('Path', compilerBasePath) def _set_msvc_legacy_conf(): if sdk == 2008: compilerSuite = 'msvc' pdkVersion = 'v6.1' else: compilerSuite = 'vs%d' % sdk pdkVersion = 'v7.1' UserSetup.ensureMSVCSetup(sdk, postfix='.' + targetPlatform) Any.requireMsg(FastScript.getEnv('WINEPREFIX'), '$WINEPREFIX not set') basePath = '''c:\\msvc-sdk\\''' + compilerSuite + '''\\''' compilerBasePath = basePath + '''VC\\''' pdkBasePath = '''c:\\msvc-sdk\\Windows\\''' + pdkVersion + '''\\''' compilerCrossPath = '' x64 = '' amd64 = '' if targetArch == 'amd64': compilerCrossPath = '''\\x86_amd64''' x64 = '''\\x64''' amd64 = '''\\amd64''' FastScript.setEnv('TARGETOS', 'windows') FastScript.setEnv('TARGETARCH', targetArch) FastScript.setEnv('COMPILER', compilerSuite) FastScript.setEnv( 'Include', pdkBasePath + '''Include;''' + compilerBasePath + '''include''') FastScript.setEnv( 'Lib', compilerBasePath + '''lib''' + amd64 + ''';''' + pdkBasePath + '''Lib''' + x64) FastScript.setEnv( 'Path', compilerBasePath + '''bin''' + compilerCrossPath + ''';''' + compilerBasePath + '''bin''' + compilerCrossPath + '''\\1033;''' + compilerBasePath + '''bin;''' + basePath + '''Common7\\IDE;''' + pdkBasePath + '''Bin''') FastScript.setEnv( 'CL_CMD', compilerBasePath + '''bin''' + compilerCrossPath + '''\\cl.exe''') FastScript.setEnv( 'LINK_CMD', compilerBasePath + '''bin''' + compilerCrossPath + '''\\link.exe''') FastScript.setEnv('RC_CMD', pdkBasePath + '''Bin\\RC.Exe''') FastScript.setEnv('MT_CMD', pdkBasePath + '''Bin\\mt.exe''') FastScript.setEnv('DUMPBIN_CMD', compilerBasePath + '''Bin\\dumpbin.exe''') tmp = re.match("^(\S+)-(\S+)-vs(\d+)$", targetPlatform) targetArch = tmp.group(2) sdk = int(tmp.group(3)) Any.requireIsTextNonEmpty(targetArch) Any.requireIsIntNotZero(sdk) # source "ToolBOSPluginWindows" if not already done bspMap = ToolBOSSettings.getConfigOption('BST_crossCompileBSPs') Any.requireIsDictNonEmpty(bspMap) neededBSP = bspMap[targetPlatform] Any.requireIsTextNonEmpty(neededBSP) ProcessEnv.source(neededBSP) logging.debug('using wine from: %s', ProcessEnv.which('wine')) # setup Wine if not FastScript.getEnv('WINEDEBUG'): FastScript.setEnv('WINEDEBUG', '-all') if sdk == 2017: _set_msvc_2017_conf() else: _set_msvc_legacy_conf() # setup arguments which will be passed to CMake fileName = os.path.join(FastScript.getEnv('TOOLBOSCORE_ROOT'), 'include/CMake/Windows-WineMSVC.cmake') Any.requireIsFileNonEmpty(fileName) oldOptions = FastScript.getEnv('BST_CMAKE_OPTIONS') if oldOptions: newOptions = '-DCMAKE_TOOLCHAIN_FILE=%s %s' % (fileName, oldOptions) else: newOptions = '-DCMAKE_TOOLCHAIN_FILE=%s' % fileName FastScript.setEnv('BST_CMAKE_OPTIONS', newOptions) FastScript.unsetEnv('GLIBC_ALIAS') FastScript.unsetEnv('GLIBC_VERSION')
def getCDefinesAsString(targetPlatform, targetName): """ Returns a long string with all compiler definitions set for the package using the addDefinitions() directive. This means all definitions passed to the compiler in the given path (beside system defaults), in the form "-DDEFINE1 -DFOO=BAR...". If no additional definitions are set, an empty string will be returned. NOTE: CMake supports that compiler definitions may be different for various target platforms, and even per executable and/or library. Therefore you need to specify both of them. A rule of thumb is targetName='<PROJECTNAME>-global'. """ Any.requireIsTextNonEmpty(targetPlatform) Any.requireIsTextNonEmpty(targetName) fileName = os.path.join('build/%s/CMakeFiles/%s.dir/flags.make' % (targetPlatform, targetName)) Any.requireIsDirNonEmpty('build/%s' % targetPlatform) Any.requireIsFileNonEmpty(fileName) # read-in ground truth information logging.debug('parsing %s' % fileName) content = FastScript.getFileContent(fileName, splitLines=True) raw_C = '' raw_CPP = '' raw_C_CFLAGS = '' raw_CPP_CFLAGS = '' regexp_C = re.compile('^C_DEFINES\s=\s+(.*)$') regexp_CPP = re.compile('^CXX_DEFINES\s=\s+(.*)$') regexp_C_CFLAGS = re.compile('^C_FLAGS\s=\s+(.*)$') regexp_CPP_CFLAGS = re.compile('^CXX_FLAGS\s=\s+(.*)$') result = '' for line in content: tmp = regexp_C.search(line) if tmp: raw_C = tmp.group(1) # logging.debug( 'raw C defines: %s' % raw_C ) tmp = regexp_CPP.search(line) if tmp: raw_CPP = tmp.group(1) # logging.debug( 'raw CPP defines: %s' % raw_CPP ) tmp = regexp_C_CFLAGS.search(line) if tmp: raw_C_CFLAGS = tmp.group(1) tmp = regexp_CPP_CFLAGS.search(line) if tmp: raw_CPP_CFLAGS = tmp.group(1) candidates = (shlex.split(raw_C) + shlex.split(raw_CPP) + shlex.split(raw_C_CFLAGS) + shlex.split(raw_CPP_CFLAGS)) for candidate in candidates: if candidate.startswith('-D'): result += candidate + ' ' return result
def addComponentInterface(self): """ In case of BBCM/BBDM packages generates the section about inputs, outputs, and references. """ if not self.details.isComponent() or self.details.isRTMapsPackage(): # no need to create ToolBOS-style component interface info return '' try: from Middleware.InfoParser import BBCMInfoParser, BBDMInfoParser, Utils except ImportError as e: pkg = ToolBOSSettings.getConfigOption('package_toolbosmiddleware') msg = 'To work with Middleware-related packages, please run ' \ '"source ${SIT}/%s/BashSrc" first.' % pkg logging.debug(e) raise EnvironmentError(msg) srcDir = os.path.join(self.details.topLevelDir, 'src') infoFileExtensionSet = ['.c', '.cpp', '.cxx', '.cc', '.c++'] if self.details.isOldBBCM(): bbcmInfo = Utils.collectOldStyleBBCMInfos(self.details.packageName, srcDir) cm = Utils.createCodeModule(bbcmInfo) initRefs = cm.referenceSettings.values() inputEvents = cm.inputEvents.values() inputs = cm.inputs.values() outputEvents = cm.outputEvents.values() outputs = cm.outputs.values() sysRefs = cm.systemReferences.values() return self.writeTable({ 'description': cm.description, 'systemModule': cm.isSystemModule, 'longDescription': cm.longDescription, 'computingMode': cm.computingMode, 'references': _generateReferences(initRefs), 'systemReferences': _generateReferences(sysRefs), 'outputEvents': _generateEvents(outputEvents, outputs, 'output'), 'inputEvents': _generateEvents(inputEvents, inputs, 'input'), 'outputs': _generatePorts(outputs), 'inputs': _generatePorts(inputs), 'initFromXML': False, 'moduleType': cm.moduleType, 'isOldStyleBBCM': True }) elif self.details.isNewBBCM(): infoFiles = glob.glob( os.path.join(srcDir, '{}_info.*'.format(self.details.packageName))) validInfoFiles = [] hasInitFromXML = Utils.hasInitFromXML('BBCM', srcDir, self.details.packageName) Any.requireIsListNonEmpty(infoFiles) for f in infoFiles: name, ext = os.path.splitext(f) if ext.lower() in infoFileExtensionSet: validInfoFiles.append(f) numValid = len(validInfoFiles) Any.requireMsg(numValid == 1, 'expected one *_info.c file, found %d' % numValid) infoFilePath = validInfoFiles[0] Any.requireIsFileNonEmpty(infoFilePath) parser = BBCMInfoParser.BBCMInfoParser() infos = parser.parse(FastScript.getFileContent(infoFilePath)) cm = Utils.createCodeModule(infos) initRefs = cm.referenceSettings.values() inputEvents = cm.inputEvents.values() inputs = cm.inputs.values() outputEvents = cm.outputEvents.values() outputs = cm.outputs.values() sysRefs = cm.systemReferences.values() return self.writeTable({ 'description': cm.description, 'systemModule': cm.isSystemModule, 'longDescription': cm.longDescription, 'computingMode': cm.computingMode, 'references': _generateReferences(initRefs), 'systemReferences': _generateReferences(sysRefs), 'outputEvents': _generateEvents(outputEvents, outputs, 'output'), 'inputEvents': _generateEvents(inputEvents, inputs, 'input'), 'outputs': _generatePorts(outputs), 'inputs': _generatePorts(inputs), 'moduleType': cm.moduleType, 'initFromXML': hasInitFromXML, 'isOldStyleBBCM': False }) elif self.details.isBBDM(): # BBDMAll is special, it does not have its own interface if self.details.packageName == 'BBDMAll': return '' srcFiles = glob.glob( os.path.join(srcDir, '{}.*'.format(self.details.packageName))) validSrcFiles = [] hasInitFromXML = Utils.hasInitFromXML('BBDM', srcDir, self.details.packageName) for f in srcFiles: name, ext = os.path.splitext(f) if ext.lower() in infoFileExtensionSet: validSrcFiles.append(f) numValid = len(validSrcFiles) Any.requireMsg(numValid == 1, 'expected one source file, found %d' % numValid) infoFilePath = validSrcFiles[0] Any.requireIsFileNonEmpty(infoFilePath) parser = BBDMInfoParser.BBDMInfoParser() infos = parser.parse(FastScript.getFileContent(infoFilePath)) cm = Utils.createDataModule(infos) initRefs = cm.referenceSettings.values() inputs = cm.inputs.values() outputs = cm.outputs.values() sysRefs = cm.systemReferences.values() return self.writeTable({ 'description': cm.description, 'references': _generateReferences(initRefs), 'outputs': _generatePorts(outputs), 'inputs': _generatePorts(inputs), 'moduleType': cm.moduleType, 'initFromXML': hasInitFromXML, 'systemReferences': _generateReferences(sysRefs) }) elif self.details.isVirtualModule(): from Middleware.BBMLv1.LoadBBML import loadVirtualModule projectName = self.details.packageName projectVersion = self.details.packageVersion canonicalPath = self.details.canonicalPath category = self.details.packageCategory Any.requireIsTextNonEmpty(projectName) Any.requireIsTextNonEmpty(projectVersion) Any.requireIsTextNonEmpty(canonicalPath) Any.requireIsTextNonEmpty(category) sourcePath = _getSourceFile(projectName, srcDir) interfacePath = _getInterfaceFile(projectName, srcDir) sourcePathExt = os.path.splitext(sourcePath)[1] Any.requireIsFileNonEmpty(sourcePath) Any.requireIsFileNonEmpty(interfacePath) # generate content virtualModule = loadVirtualModule(sourcePath, interfacePath, synthesizable=True) inputs = virtualModule.inputs.values() outputs = virtualModule.outputs.values() inputEvents = virtualModule.inputEvents.values() outputEvents = virtualModule.outputEvents.values() return self.writeTable({ 'inputEvents': _generateVirtualModulePorts(inputEvents), 'inputs': _generateVirtualModulePorts(inputs), 'library': 'VirtualModule', 'moduleType': 'VirtualModule', 'outputEvents': _generateVirtualModulePorts(outputEvents), 'outputs': _generateVirtualModulePorts(outputs), 'references': _generateVirtualModuleReferences(virtualModule), 'sourcePath': os.path.join(r'${SIT}', canonicalPath, 'include', projectName + sourcePathExt), 'virtualExecutor': _generateVirtualExecutors(virtualModule) }) else: raise ValueError('unknown component type')
#---------------------------------------------------------------------------- # Main program #---------------------------------------------------------------------------- # discover SVN server to use, package name and category cwd = os.getcwd() server = ToolBOSSettings.getConfigOption('defaultSVNServer') reposPath = ToolBOSSettings.getConfigOption('defaultSVNRepositoryPath') packageName = os.path.basename(cwd) category = None try: # search for CMakeLists.txt filePath = findFile('CMakeLists.txt') Any.requireIsFileNonEmpty(filePath) content = FastScript.getFileContent(filePath) Any.requireIsTextNonEmpty(content) category = CMakeLists.getCategory(content) Any.requireIsTextNonEmpty(category) except IOError: msg = 'It seems you are not calling this script from the ' + \ '"PackageName" directory (the one that contains all the ' + \ 'version directories). Maybe need "cd MyPackage" ' + \ 'or "cd .."?' FastScript.prettyPrintError(msg)
def createLocalProject(klocworkDir='klocwork', stdout=None, stderr=None): """ Creates a local .kwlp directory so that the analysis can be performed. @Retuns: nothing. Throws an RuntimeError in case of problems. """ Any.requireIsTextNonEmpty(klocworkDir) requireOutsideTmpDir() kwPackage = ToolBOSSettings.getConfigOption('package_klocwork') buildSpec = os.path.join(klocworkDir, 'kwinject.out') kwlpDir = os.path.join(klocworkDir, '.kwlp') # KW local project kwpsDir = os.path.join(klocworkDir, '.kwps') # KW project settings hostPlatform = Platforms.getHostPlatform() licenseServerHost = ToolBOSSettings.getConfigOption('kwLicenseServerHost') licenseServerPort = ToolBOSSettings.getConfigOption('kwLicenseServerPort') Any.requireIsTextNonEmpty(kwPackage) Any.requireIsTextNonEmpty(hostPlatform) ProcessEnv.source(kwPackage) FastScript.mkdir(klocworkDir) # ensure this exists FastScript.remove(kwlpDir) # but those should not exist FastScript.remove(kwpsDir) # but those should not exist if ProcessEnv.which('kwinject') is None: msg = '%s not installed for platform=%s' % (kwPackage, hostPlatform) raise EnvironmentError(msg) # inspect the build process to capture source files, defines, flags,... cmd = 'kwinject -o %s %s' % (buildSpec, 'BST.py -sb') FastScript.execProgram(cmd, stdout=stdout, stderr=stderr) Any.requireIsFileNonEmpty(buildSpec) # create Klocwork project directory cmd = 'kwcheck create --license-host %s --license-port %d -pd %s -sd %s %s' % \ ( licenseServerHost, licenseServerPort, kwlpDir, kwpsDir, buildSpec ) FastScript.execProgram(cmd, stdout=stdout, stderr=stderr) Any.requireIsDir(kwlpDir) Any.requireIsDir(kwpsDir) # import the build specification into project directory cmd = 'kwcheck import -pd %s %s' % (kwlpDir, buildSpec) FastScript.execProgram(cmd, stdout=stdout, stderr=stderr) # install the HIS-Subset taxonomy so that the user may select it tcRoot = FastScript.getEnv('TOOLBOSCORE_ROOT') fileName = 'HIS_Subset_MISRA_C_1.0.2.tconf' srcFile = os.path.join(tcRoot, 'external/emenda.com', fileName) dstDir = os.path.join(kwpsDir, 'servercache') dstFile = os.path.join(dstDir, fileName) Any.requireIsFileNonEmpty(srcFile) FastScript.mkdir(dstDir) FastScript.copy(srcFile, dstFile) # auto-detect source code directories (exclude some blacklisted ones) dirList = [] cwd = os.getcwd() for dirName in FastScript.getDirsInDir(): if dirName not in ('build', 'doc', 'external', 'lib'): dirList.append(os.path.join(cwd, dirName)) # create workingset values = {'dirList': dirList} creator = PackageCreator.PackageCreator('dummy', '1.0', values) srcDir = os.path.join(creator.templateDir, 'KlocworkProject') dstDir = kwlpDir creator.templatize(os.path.join(srcDir, 'workingsets.xml'), os.path.join(dstDir, 'workingsets.xml'))
# ?_R4 - RTTI Complete Object Locator # ?_S - local vftable # ?_T - local vftable constructor closure # ?_U - new[] # ?_V - delete[] reg = "[0-9a-fA-F]+ (?P<length>([0-9a-fA-F]+)) (?P<table>(SECT[0-9A-F]+|UNDEF)).*notype.*(?P<alloc>(Static|External)) .*\| (?P<token>[\?\.\@\$_A-Za-z0-9]+)" # This will filter the function name, we are interested only the part containing the symbol without @<number> reg1 = "(?P<token>.*)@[0-9]+$" filt = re.compile(reg) tokfilt = re.compile(reg1) Any.requireMsg(filt, "Invalid regex pattern \"%s\"" % reg) if inputFile: Any.requireIsFileNonEmpty(inputFile) logging.debug('reading from %s', inputFile) else: logging.debug('reading from stdin') inputFile = sys.stdin sectionNamePrefixes = ('.text$x', '.text$mn', '.debug$S', '.debug$T') with open(inputFile, 'r') as fd: for line in fd: res = filt.match(line) if res is None: continue # Get the allocation match
def setupMSVC2012(configDir): """ Configures the Microsoft Visual Compiler to be used with Wine from the ToolBOS build system. You may provide a path to the directory where your Wine configuration is. If omitted, the path returned from getWineConfigDir() will be used. """ from ToolBOSCore.Storage.SIT import getPath if not os.path.exists(os.path.join(configDir, 'user.reg')): setupWineDotNet(configDir) Any.requireIsDir(configDir) if not os.path.exists(os.path.join(configDir, 'dosdevices')): setupWineDotNet(configDir) logging.info('setting up Visual Studio...') linkPath = os.path.join(configDir, 'dosdevices', 'c:') linkTarget = '../drive_c' FastScript.remove(linkPath) FastScript.link(linkTarget, linkPath) linkPath = os.path.join(configDir, 'dosdevices', 'z:') linkTarget = '/' FastScript.remove(linkPath) FastScript.link(linkTarget, linkPath) # create temp. directories driveC = os.path.join(configDir, 'drive_c') userName = FastScript.getCurrentUserName() userTempDir = os.path.join(driveC, 'users', userName, 'Temp') sysTempDir = os.path.join(driveC, 'temp') logging.debug('userTempDir=%s', userTempDir) FastScript.mkdir(userTempDir) FastScript.mkdir(sysTempDir) # ensure to NOT have the "h:" link, else wine would not find some links FastScript.remove(os.path.join(configDir, 'dosdevices', 'h:')) # replace "C:\Program Files" by symlink into SIT FastScript.remove(os.path.join(configDir, 'drive_c', 'Program Files')) sitPath = getPath() linkPath = os.path.join(configDir, 'drive_c', 'msvc-sdk') linkTarget = os.path.join(sitPath, 'External/MSVC/10.0/msvc-sdk') FastScript.remove(linkPath) FastScript.link(linkTarget, linkPath) linkPath = os.path.join(configDir, 'drive_c', 'Program Files') linkTarget = os.path.join(sitPath, 'External/MSVC/10.0/Program Files') FastScript.remove(linkPath) FastScript.link(linkTarget, linkPath) # copy a hancrafted system.reg srcFile = os.path.join( sitPath, 'External/MSVC/10.0/otherstuff/winevs2012/system.reg') dstFile = os.path.join(configDir, 'system.reg') shutil.copyfile(srcFile, dstFile) # force wine to use the MSVC native library userReg = os.path.join(configDir, 'user.reg') Any.requireIsFileNonEmpty(userReg) content = FastScript.getFileContent(userReg) if content.find('1413877490') == -1: content += \ ''' [Software\\\\Wine\\\\DllOverrides] 1413877490 "mscoree"="native" "msvcr110"="native" ''' logging.debug('updating %s', userReg) FastScript.setFileContent(userReg, content)
def __init__(self, filepath, isCPlusPlus, langStd, verbose=False, includepaths=None, defines=None, args=None): """ Creates a new CParser instance. The file is indexed at constructor time. :param filepath: the file to parse :param verbose: whether or not to print diagnostic information during parsing. :param includepaths: a list of include paths. All the basic include paths must be specified, including at least: - the most basic include path, on unix usually /usr/include - the clang standard library include path. Distribution and clang version dependent. On Ubuntu Precise 64 with clang 3.4 this is /usr/lib/clang/3.4/include For C++, the C++ include paths are also required. On Precise 64 these are: - /usr/include/c++/4.6/ - /usr/include/c++/4.6/x86_64-linux-gnu/ :param args: extra compiler flags """ Any.requireIsFileNonEmpty(filepath) includepaths = includepaths or [] systemIncludePaths = self._getSystemIncludePaths() defines = defines or [] self.langStd = langStd self.isCPlusPlus = isCPlusPlus self.verbose = verbose try: self._index = cidx.Index.create() except cidx.LibclangError: hostPlatform = Platforms.getHostPlatform() Any.requireIsTextNonEmpty(hostPlatform) libs = ToolBOSConf.getConfigOption('clang_lib') Any.requireIsDictNonEmpty(libs) try: libPath = libs[hostPlatform] except KeyError: logging.error('unsupported platform: %s', hostPlatform) return Any.requireIsFileNonEmpty(libPath) cidx.Config.set_library_file(libPath) self._index = cidx.Index.create() self.filepath = filepath # build a list of include directory compile flags to pass to the parse method of the index. argsIncludeDirs = ["-I{}".format(d) for d in systemIncludePaths] completeArgs = argsIncludeDirs + (args or []) self.args = completeArgs translationUnit = self._index.parse( filepath, options=cidx.TranslationUnit.PARSE_DETAILED_PROCESSING_RECORD, args=completeArgs) self.translationUnit = translationUnit # call super with the translation unit cursor super(CParser, self).__init__(translationUnit.cursor) # macros are extracted separately as the clang C bindings - and thus # the python ones - do not provide helpers to extract the info we need. self._populateMacros(filepath, list(systemIncludePaths) + list(includepaths), defines, langStd)
origEnv = FastScript.getEnv() FastScript.unsetEnv('VERBOSE') FastScript.unsetEnv('BST_BUILD_JOBS') pyScripts = glob.glob(os.path.join(binDirNoArch, '*.py')) shScripts = glob.glob(os.path.join(binDirNoArch, '*.sh')) executables = glob.glob(os.path.join(binDirNoArch, hostPlatform, '*')) for program in pyScripts + shScripts + executables: basename = os.path.basename(program) Any.requireIsTextNonEmpty(basename) logging.info('processing %s', basename) output = StringIO() cmd = '%s --help' % program fileName = os.path.join('ReferenceData', '%s.txt' % basename) Any.requireIsTextNonEmpty(cmd) Any.requireIsTextNonEmpty(fileName) FastScript.execProgram(cmd, stdout=output, stderr=output) content = normalizeOutput(output.getvalue()) Any.requireIsTextNonEmpty(content) FastScript.setFileContent(fileName, content) Any.requireIsFileNonEmpty(fileName) # EOF