def baseSetupWine(configDir, msvc, stdout, stderr, postfix): if not configDir: configDir = getWineConfigDir(postfix) # safety check: exit if we are within CIA and configdir points to # home directories! if FastScript.getEnv('CIA') == 'TRUE' and configDir.startswith('/home'): raise SystemExit( 'SAFETY GUARD: Do not touch home directory within CIA!') sourceWindowsBSP(msvc) FastScript.setEnv('WINEPREFIX', configDir) FastScript.mkdir(configDir) logging.info('setting up Wine in %s', configDir) # temporarily unset the DISPLAY variable so that the 'winecfg' # utility does not show up oldDisplay = FastScript.getEnv('DISPLAY') FastScript.unsetEnv('DISPLAY') FastScript.execProgram('winecfg', stdout=stdout, stderr=stderr) # wait for wineserver shutdown (default: 3 seconds) waitWineServerShutdown(configDir, postfix) if oldDisplay: FastScript.setEnv('DISPLAY', oldDisplay) logging.info('Microsoft .NET support enabled')
def setup(self): FastScript.setEnv('PROJECT_NAME', self.details.packageName) FastScript.setEnv('PROJECT_VERSION', self.details.packageVersion) self._createMainDoxyfile() self._createUserDoxyfile() self._createAutoDoxyfile()
def checkout(self, revision='HEAD', output=None): """ Fetches the specified revison from the given URL (which needs to point to a valid SVN repository). If the username to use for connecting to the server does not match your current username (e.g. on HRI-EU's Ext.SVN server), please use insertUsernameIntoURL() prior to this call. If 'output' is a StringIO object, the command's output will be redirected there (otherwise printed on screen). """ # suppress interactive password prompt for Ext.SVN (if any), # see JIRA ticket TBCORE-904 oldValue = FastScript.getEnv('SVN_SSH') if oldValue and not '-oBatchMode' in oldValue: # if SVN_SSH was already set then *append* our settings newValue = oldValue + ' -oBatchMode=yes' else: # set SVN_SSH newValue = 'ssh -oBatchMode=yes' FastScript.setEnv('SVN_SSH', newValue) cmd = self.getSourceCodeCommand(revision) return FastScript.execProgram(cmd, stdout=output, stderr=output)
def switchEnvironment(toPlatform): """ Modifies the environment variables to appear as if this was another operating system. This is primary used for cross-compilations. If you would like to later restore the original settings, make sure to call "origEnv = FastScript.getEnv()" before invoking this function. When you are done, you can then reset the whole environment by calling "FastScript.setEnv( origMap )". """ Any.requireIsTextNonEmpty(toPlatform) fromPlatform = Platforms.getHostPlatform() src = fromPlatform.replace('-', '') dst = toPlatform.replace('-', '') funcName = "_switchEnv_%s_to_%s" % (src, dst) if fromPlatform == toPlatform: return try: func = globals()[funcName] except KeyError: msg = "requested platform switch (%s to %s) is not supported" % \ ( fromPlatform, toPlatform ) raise NotImplementedError(msg) func() FastScript.setEnv('MAKEFILE_PLATFORM', toPlatform)
def setParallelJobs( self, number ): Any.requireIsIntNotZero( number ) self._parallelJobs = number self._detectBuildCommand() # set env.var. so that child programs (incl. custom compile.sh # scripts) know about it FastScript.setEnv( 'BST_BUILD_JOBS', str(number) )
def proxyInstall( self ): FastScript.setEnv( 'MAKEFILE_FASTINSTALL', 'TRUE' ) if self.optionsWidget.getVerboseValue(): command = 'BST.py -vx' else: command = 'BST.py -x' self._focusLocalTerminal() self._execProgram( self.terminals[ 'localhost' ], command )
def _switchToHostEnv( self ): if self._crossCompiling: logging.debug( 'switching to host environment (%s)', self._hostPlatform ) if self._targetPlatform.startswith( 'windows' ): from ToolBOSCore.Settings import UserSetup UserSetup.waitWineServerShutdown( UserSetup.getWineConfigDir() ) FastScript.setEnv( self._origEnv )
def _setDebugLevel(self): """ Free scripts from redundant verbose-flag handling. Mind to set VERBOSE=TRUE within this process, so that child processes (incl. CMake) operate in verbose mode. """ if self._result.verbose or FastScript.getEnv('VERBOSE') == 'TRUE': Any.setDebugLevel(logging.DEBUG) FastScript.setEnv('VERBOSE', 'TRUE') else: Any.setDebugLevel(logging.INFO)
def ensureMSVCSetup(sdk, postfix=''): """ Verifies that the Wine / MSVC installation is present and correct. If WINEPREFIX is set, this will be used, otherwise fallback to default wine location. An optional 'postfix' might be specified to separate several Wine config directories for different purposes. """ 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 _msvc2017SpecificChecks(): linkPath = os.path.join(configDir, 'drive_c', 'BuildTools') if not os.path.exists(linkPath): logging.debug('%s not found', linkPath) setupMSVC(configDir, sdk) configDir = FastScript.getEnv('WINEPREFIX') if not configDir: configDir = getWineConfigDir(postfix) FastScript.setEnv('WINEPREFIX', configDir) waitWineServerShutdown(configDir, postfix) if sdk in (2010, 2012): _msvc2012SpecificChecks() elif sdk == 2017: _msvc2017SpecificChecks() else: raise RuntimeError('ensureMSVCSetup: unsupported MSVC version: %s' % sdk)
def startWineServer(configDir=None, postfix=''): """ Start Winserver You may provide a path to the Wine config directory and/or a config name postfix. If omitted, the path returned from getWineConfigDir() will be used. """ if not configDir: configDir = getWineConfigDir(postfix) FastScript.setEnv('WINEPREFIX', configDir) FastScript.execProgram('wineserver')
def test_helpText(self): tcRoot = FastScript.getEnv('TOOLBOSCORE_ROOT') hostPlatform = Platforms.getHostPlatform() binDirNoArch = os.path.join(tcRoot, 'bin') Any.requireIsDirNonEmpty(binDirNoArch) pyScripts = glob.glob(os.path.join(binDirNoArch, '*.py')) shScripts = glob.glob(os.path.join(binDirNoArch, '*.sh')) executables = glob.glob(os.path.join(binDirNoArch, hostPlatform, '*')) # unset VERBOSE and BST_BUILD_JOBS to make output comparable origEnv = FastScript.getEnv() FastScript.unsetEnv('VERBOSE') FastScript.unsetEnv('BST_BUILD_JOBS') 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) expected = FastScript.getFileContent(fileName) result = normalizeOutput(output.getvalue()) Any.isTextNonEmpty(expected) Any.isTextNonEmpty(result) if result != expected: logging.info('differences in output of %s:', basename) logging.info('<result>\n%s', result) logging.info('</result>') logging.info('<expected>\n%s', expected) logging.info('</expected>') self.fail('help text of %s differs' % basename) FastScript.setEnv(origEnv)
def _retrieveMetaInfo(self): """ Invokes "svn info" within a working copy. If 'output' is a StringIO object, the command's output will be redirected there (otherwise printed on screen). """ if not self._infoOutput: output = StringIO() # Temporarily unset the LANG environment variable, in order to always # get English output. Otherwise the "svn info" output might be German # or Japanese which would break the later parsing, see TBCORE-59. origEnv = FastScript.getEnv('LANG') if origEnv: FastScript.unsetEnv('LANG') cmd = 'svn info' FastScript.execProgram(cmd, stdout=output, stderr=output) if origEnv: FastScript.setEnv('LANG', origEnv) self._infoOutput = output.getvalue() self._repoRootFromInfo = re.search("Repository Root: (\S+)\n", self._infoOutput).group(1) logging.debug('found SVN repository root: %s', self._repoRootFromInfo) self._repoUrlFromInfo = re.search("URL: (\S+)\n", self._infoOutput).group(1) logging.debug('found SVN repository URL: %s', self._repoUrlFromInfo) self._revFromInfo = int( re.search("Revision\s?: (\d+?)\s", self._infoOutput).group(1)) logging.debug('found SVN revision: %d', self._revFromInfo) return self._infoOutput
def waitWineServerShutdown(configDir=None, postfix=''): """ Wait Winserver shutdown You may provide a path to the Wine config directory and/or a config name postfix. If omitted, the path returned from getWineConfigDir() will be used. """ if not configDir: configDir = getWineConfigDir(postfix) FastScript.setEnv('WINEPREFIX', configDir) # wait for wineserver shutdown (default: 3 seconds) logging.debug('waiting for wineserver to shut down...') try: FastScript.execProgram('wineserver -k') except subprocess.CalledProcessError: pass
def exportLibraryPath( LibIndexDir, platformName ): """ Adds the two directories within <LibIndexDir> to LD_LIBRARY_PATH: * LibIndexDir/<platform>/lib * LibIndexDir/lib/<platform> """ Any.requireIsDir( LibIndexDir ) oldLDPath = FastScript.getEnv( 'LD_LIBRARY_PATH' ) newLDPath = oldLDPath candidates = [ os.path.join( LibIndexDir, platformName, 'lib' ), os.path.join( LibIndexDir, 'lib', platformName ) ] for dirPath in candidates: if os.path.exists( dirPath ): newLDPath = '%s:%s' % ( dirPath, newLDPath ) FastScript.setEnv( 'LD_LIBRARY_PATH', newLDPath )
def switch(dstPath): """ This function internally resets all variables etc. so that further calls to SIT.getPath() or so return the correct directory name. Attention: You may need to reload or inform other packages about an SIT change. You can do so by registering some callback using SITSwitchObservers.register(). """ FastScript.setEnv('HRI_GLOBAL_ROOT', dstPath) FastScript.setEnv('SIT', dstPath) FastScript.setEnv('SIT_VERSION', os.path.basename(dstPath))
# Main program #---------------------------------------------------------------------------- print('') print('######## ### ####### #### #####') print(' ## ##### ##### ## ## ## ## ## ## ##') print(' ## ## ## ## ## ## ######## ## ## ##') print(' ## ## ## ## ## ## ## ## ## ## ##') print(' ## ## ## ## ## ## ## ## ## ## ## ##') print(' ## ##### ##### ##### ####### #### #####') print('') print(subtitle.center(58)) # 58 == logo width print('') print('') FastScript.setEnv('SIT_VERSION', 'latest') dirName = os.path.expanduser('~/.HRI') if os.path.exists(dirName): logging.warning('%s: directory already exists', dirName) answer = six.moves.input('Overwrite (y/N)? ') if answer is not 'y' and answer is not 'Y': raise SystemExit('Aborted.') try: UserSetup.setupShell() if advanced: UserSetup.setupProxy(sitRootPath, sitProxyPath)
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 _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''')
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 _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 _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)
sourceTree = None binaryTree = None outOfTree = False # proxy- and global-installations are mutually exclusive if globalInstall and proxyInstall: msg = '"--install" and "--proxy" cannot be used together' logging.error(msg) sys.exit(-1) #---------------------------------------------------------------------------- # Main #---------------------------------------------------------------------------- if yes: FastScript.setEnv('MAKEFILE_FASTINSTALL', 'TRUE') if message: FastScript.setEnv('MAKEFILE_GLOBALINSTALLREASON', message) try: if platform == 'help': from ToolBOSCore.Platforms.CrossCompilation import getSwitchEnvironmentList candidates = getSwitchEnvironmentList(hostPlatform) Any.requireIsList(candidates) if not candidates: logging.info('No cross-compilation from %s hosts implemented :-(' % hostPlatform)
def source(package): """ Python equivalent of "source BashSrc" from SIT, in order to setup PATH, LD_LIBRARY_PATH,... within the Python process. @anchor ProcessEnv_source """ ProjectProperties.requireIsCanonicalPath(package) sourced = FastScript.getEnv('TOOLBOSCORE_SOURCED') Any.requireMsg(sourced, '$TOOLBOSCORE_SOURCED must not be empty') # avoid double-sourcing if package in sourced: return True ProjectProperties.requireIsInstalled(package) logging.debug('source %s/pkgInfo.py', package) sourced = '%s %s' % (package, sourced) FastScript.setEnv('TOOLBOSCORE_SOURCED', sourced) # load pkgInfo.py (if exists) try: content = getPkgInfoContent(project=package) except AssertionError: return True # no such file, this is OK except (IOError, OSError) as details: logging.error(details) return False # setup environment of this package try: envVars = content['envVars'] except KeyError: envVars = [] # no such setting, this is OK sitPath = SIT.getPath() for name, value in envVars: # replace known placeholdes value = value.replace('${INSTALL_ROOT}', os.path.join(sitPath, package)) FastScript.setEnv_withExpansion(name, value) # source dependent packages try: # TODO: eventually extend to sourcing recommended/suggested packages depList = content['depends'] except (AssertionError, KeyError): depList = [] # no such setting, this is OK for dep in depList: if not dep.startswith('deb://'): source(SIT.strip(dep)) # special treatment of PYTHONPATH: # After sourcing add new entries in PYTHONPATH to sys.path _expandSysPath() return True