def run(self):
        package_cutest = ToolBOSSettings.getConfigOption('package_cutest')
        package_toolboslib = ToolBOSSettings.getConfigOption(
            'package_toolboslib')

        if not 'category' in self.values:
            self.values['category'] = 'Libraries'

        if not 'dependencies' in self.values:
            self.values['dependencies'] = [package_toolboslib, package_cutest]

        self.setValidFlags()

        self.createMainPackage()

        srcDir = os.path.join(self.templateDir_core, 'C_Library')
        dstDir = self.dstDir

        self.copyVerbatim(os.path.join(srcDir, 'pkgInfo.py'),
                          os.path.join(dstDir, 'pkgInfo.py'))

        self.templatize(os.path.join(srcDir, 'packageName.c.mako'),
                        os.path.join(dstDir, 'src', '%s.c' % self.packageName))

        self.templatize(os.path.join(srcDir, 'packageName.h.mako'),
                        os.path.join(dstDir, 'src', '%s.h' % self.packageName))

        self.templatize(os.path.join(srcDir, 'unittest.c.mako'),
                        os.path.join(dstDir, 'test', 'unittest.c'))
    def run(self):
        Any.requireMsg(len(self.packageName) > 4, "package name is too short")
        Any.requireMsg(self.packageName.startswith('BBDM'),
                       "package name must start with 'BBDM'")

        package_cutest = ToolBOSSettings.getConfigOption('package_cutest')
        package_libxml = ToolBOSSettings.getConfigOption('package_libxml')
        package_toolboslib = ToolBOSSettings.getConfigOption(
            'package_toolboslib')

        if not 'category' in self.values:
            self.values['category'] = 'Modules/BBDM'

        if not 'dependencies' in self.values:
            self.values['dependencies'] = [
                package_toolboslib, package_cutest, package_libxml
            ]

        self.values['DataType'] = self.packageName[4:]
        self.values['DATATYPE'] = self.packageName[4:].upper()

        self.setValidFlags()

        self.createMainPackage()

        srcDir = os.path.join(self.templateDir, 'C_BBDM')
        dstDir = self.dstDir

        self.templatize(os.path.join(srcDir, 'packageName.c.mako'),
                        os.path.join(dstDir, 'src', '%s.c' % self.packageName))

        self.templatize(os.path.join(srcDir, 'packageName.h.mako'),
                        os.path.join(dstDir, 'src', '%s.h' % self.packageName))

        # overwrite the file from master template
        self.copyVerbatim(os.path.join(srcDir, 'unittest.sh'),
                          os.path.join(dstDir, 'unittest.sh'))

        self.templatize(os.path.join(srcDir, 'TestCopy.c.mako'),
                        os.path.join(dstDir, 'test', 'TestCopy.c'))

        self.templatize(os.path.join(srcDir, 'TestInstanceName.c.mako'),
                        os.path.join(dstDir, 'test', 'TestInstanceName.c'))

        self.templatize(os.path.join(srcDir, 'TestSuite.c.mako'),
                        os.path.join(dstDir, 'test', 'TestSuite.c'))

        self.templatize(os.path.join(srcDir, 'TestTimestep.c.mako'),
                        os.path.join(dstDir, 'test', 'TestTimestep.c'))
    def run(self):
        package_cutest = ToolBOSSettings.getConfigOption('package_cutest')
        package_libxml = ToolBOSSettings.getConfigOption('package_libxml')
        package_toolboslib = ToolBOSSettings.getConfigOption(
            'package_toolboslib')

        if not 'category' in self.values:
            self.values['category'] = 'Modules/BBCM/Testing'

        if not 'dependencies' in self.values:
            self.values['dependencies'] = [
                package_toolboslib, package_cutest, package_libxml
            ]

        Any.requireMsg(
            self.packageName[0].isupper() == True,
            'BBCM template requires package name to start uppercase')

        self.setValidFlags()

        self.createMainPackage()

        srcDir = os.path.join(self.templateDir, 'C_BBCM')
        dstDir = self.dstDir

        self.templatize(os.path.join(srcDir, 'packageName.c.mako'),
                        os.path.join(dstDir, 'src', '%s.c' % self.packageName))

        self.templatize(os.path.join(srcDir, 'packageName.h.mako'),
                        os.path.join(dstDir, 'src', '%s.h' % self.packageName))

        self.templatize(
            os.path.join(srcDir, 'packageName_ext.c.mako'),
            os.path.join(dstDir, 'src', '%s_ext.c' % self.packageName))

        self.templatize(
            os.path.join(srcDir, 'packageName_ext.h.mako'),
            os.path.join(dstDir, 'src', '%s_ext.h' % self.packageName))

        self.templatize(
            os.path.join(srcDir, 'packageName_info.c.mako'),
            os.path.join(dstDir, 'src', '%s_info.c' % self.packageName))

        self.templatize(
            os.path.join(srcDir, 'packageName_init.c.mako'),
            os.path.join(dstDir, 'src', '%s_init.c' % self.packageName))

        self.templatize(os.path.join(srcDir, 'unittest.c.mako'),
                        os.path.join(dstDir, 'test', 'unittest.c'))
Exemplo n.º 4
0
    def setConfiguredUserName(self):
        """
            If a particular account has to be used to log into the server
            this function will auto-insert the username found in ToolBOS.conf
            for this server (if any).

            If no username was configured for the given server fall back to
            clean URL without any username (even if there was one before).
        """
        Any.requireIsTextNonEmpty(self._hostName)

        mapping = ToolBOSSettings.getConfigOption('serverAccounts')
        Any.requireIsDict(mapping)

        userName = None

        for candidate, account in mapping.items():

            if self._hostName.find(candidate) != -1:
                userName = account
                logging.info('found configured username=%s for server=%s',
                             userName, self._hostName)
                break

        self.setUserName(userName)
        logging.debug('modified URL: %s', self.url)
Exemplo n.º 5
0
    def __init__(self, url):
        Any.requireIsTextNonEmpty(url)

        super(RemoteGitRepository, self).__init__(url)

        self._allowedHosts = ToolBOSSettings.getConfigOption(
            'Git_allowedHosts')
Exemplo n.º 6
0
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)
Exemplo n.º 7
0
def getCrossCompilationList():
    """
        Returns the value of the ToolBOS config option
        'BST_defaultPlatforms_xcmp'.
    """
    platformList = list(
        ToolBOSSettings.getConfigOption('BST_defaultPlatforms_xcmp'))

    platformList.sort()

    return platformList
Exemplo n.º 8
0
def startGUI():
    """
        Launches the CLion IDE.

        Note that the program will be opened in background in order not to
        block the caller.
    """
    ProcessEnv.source(ToolBOSSettings.getConfigOption('package_clion'))

    try:
        cmd = 'clion.sh'
        logging.debug('executing: %s', cmd)
        subprocess.Popen(cmd)
    except (subprocess.CalledProcessError, OSError) as details:
        logging.error(details)
Exemplo n.º 9
0
    def __init__(self, url):
        Any.requireIsMatching(url, ".*://.*")
        Any.requireMsg(url[0] != "'", 'invalid repository URL')
        Any.requireMsg(url[0] != '"', 'invalid repository URL')

        # get rid of legacy hostnames
        url = url.replace('svnhost', 'hri-svn')

        # use FQDN
        url = url.replace('hri-svn/', 'hri-svn.honda-ri.de/')

        super(SVNRepository, self).__init__(url)

        self._allowedHosts = ToolBOSSettings.getConfigOption(
            'SVN_allowedHosts')
Exemplo n.º 10
0
def getNativeCompilationList():
    """
        Returns the value of the ToolBOS config option
        'BST_defaultPlatforms_native', defaulting to the current
        host platform if not overwritten by the user.
    """
    platformList = list(
        ToolBOSSettings.getConfigOption('BST_defaultPlatforms_native'))

    if not platformList:
        platformList = [Platforms.getHostPlatform()]

    platformList.sort()

    return platformList
Exemplo n.º 11
0
def getCrossCompileHost(platform):
    """
        Returns the hostname or IP address of the compile host responsible
        for cross-compiling for 'platform', None if not defined.

        Such values are site-specific and hence need to be configured via
        ToolBOS.conf.
    """
    Any.requireIsTextNonEmpty(platform)

    hosts = ToolBOSSettings.getConfigOption('BST_userCrossCompileHosts')

    try:
        return hosts[platform]
    except (KeyError, TypeError):
        # not found in user's configfile
        pass

    hosts = ToolBOSSettings.getConfigOption('BST_crossCompileHosts')

    try:
        return hosts[platform]
    except KeyError:
        return None
Exemplo n.º 12
0
def openToolBOSDocumentation( fileName, parent=None ):
    """
        Opens a webbrowser window which shows the particular HTML file
        within the ToolBOS SDK documentation (e.g. "index").

        Note that ".html" will be added automatically.
    """
    Any.requireIsTextNonEmpty( fileName )

    logging.info( 'opening online documentation' )

    url = ToolBOSSettings.getConfigOption( 'documentationURL_dir' ) + \
          fileName + '.html'

    browser = WebBrowser( 'Documentation', parent )
    browser.open( url )
Exemplo n.º 13
0
def openDocumentation( canonicalPath, parent=None ):
    """
        Opens a webbrowser window which shows the documentation of the
        given SIT package.
    """

    Any.requireIsTextNonEmpty( canonicalPath )

    logging.info( 'opening docu for %s', canonicalPath )

    url = ToolBOSSettings.getConfigOption( 'documentationURL_sit' ) + \
          canonicalPath + '/doc/html/index.html'

    title   = 'Documentation of %s' % canonicalPath
    browser = WebBrowser( title, parent=parent )
    browser.open( url )
Exemplo n.º 14
0
def codeCheck(klocworkDir='klocwork', stdout=None, stderr=None):
    """
        Performs a CLI-analysis of the project.

        Note that the Klocwork-project must have been created before,
        e.g. using createLocalProject().
    """
    Any.requireIsDirNonEmpty(klocworkDir)

    requireOutsideTmpDir()

    ProcessEnv.source(ToolBOSSettings.getConfigOption('package_klocwork'))

    kwlpDir = os.path.join(klocworkDir, '.kwlp')
    Any.requireIsDirNonEmpty(kwlpDir)

    cmd = 'kwcheck run -pd %s' % kwlpDir
    FastScript.execProgram(cmd, stdout=stdout, stderr=stderr)
Exemplo n.º 15
0
def sourceWindowsBSP(msvc):
    """
        Loads the necessary ToolBOSPluginWindows so that Wine and MSVC
        will be found in PATH etc.
    """
    allBSPs = ToolBOSSettings.getConfigOption('BST_crossCompileBSPs')
    Any.requireIsDictNonEmpty(allBSPs)

    if msvc in (2010, 2012):
        canonicalPath = allBSPs['windows-amd64-vs2012']
    elif msvc == 2017:
        canonicalPath = allBSPs['windows-amd64-vs2017']
    else:
        raise RuntimeError('sourceWindowsBSP: unsupported MSVC version: %s' %
                           msvc)

    ProjectProperties.requireIsCanonicalPath(canonicalPath)

    ProcessEnv.source(canonicalPath)
Exemplo n.º 16
0
    def run(self):
        package_toolboslib = ToolBOSSettings.getConfigOption(
            'package_toolboslib')
        if not 'category' in self.values:
            self.values['category'] = 'Applications'

        if not 'dependencies' in self.values:
            self.values['dependencies'] = [package_toolboslib]

        self.createMainPackage()

        srcDir = os.path.join(self.templateDir_core, 'C_MainProgram')
        dstDir = self.dstDir

        self.templatize(os.path.join(srcDir, 'main.c.mako'),
                        os.path.join(dstDir, 'bin', 'main.c'))

        FastScript.remove(os.path.join(dstDir, 'lib'))
        FastScript.remove(os.path.join(dstDir, 'src'))
        FastScript.remove(os.path.join(dstDir, 'unittest.sh'))
Exemplo n.º 17
0
def startGUI(options='', blocking=False):
    """
        Launches the Klocwork Desktop GUI.

        The program can be opened blocking or non-blocking, f.i. in
        background in order not to block the caller.
    """
    requireOutsideTmpDir()

    ProcessEnv.source(ToolBOSSettings.getConfigOption('package_klocwork'))

    try:
        cmd = 'kwgcheck %s' % options
        logging.debug('executing: %s', cmd)

        if blocking:
            FastScript.execProgram(cmd)
        else:
            subprocess.Popen(shlex.split(cmd))

    except (subprocess.CalledProcessError, OSError) as details:
        logging.error(details)
Exemplo n.º 18
0
    def run(self):
        package_toolboslib = ToolBOSSettings.getConfigOption(
            'package_toolboslib')

        if not 'category' in self.values:
            self.values['category'] = 'Libraries'

        if not 'dependencies' in self.values:
            self.values['dependencies'] = [package_toolboslib]

        self.createMainPackage()

        srcDir = os.path.join(self.templateDir_core, 'Cpp_Class')
        dstDir = self.dstDir

        self.templatize(
            os.path.join(srcDir, 'packageName.cpp.mako'),
            os.path.join(dstDir, 'src', '%s.cpp' % self.packageName))

        self.templatize(os.path.join(srcDir, 'packageName.h.mako'),
                        os.path.join(dstDir, 'src', '%s.h' % self.packageName))

        FastScript.remove(os.path.join(dstDir, 'unittest.sh'))
argman.addExample( 'cd MyPackage/1.0' )
argman.addExample( '%(prog)s' )

argman.run()


#----------------------------------------------------------------------------
# Main program
#----------------------------------------------------------------------------


BuildSystemTools.requireTopLevelDir()


ProcessEnv.source( ToolBOSSettings.getConfigOption( 'package_pycharm' ) )


try:
    #PyCharm.createUserConfig()

    logging.info( 'creating config in ./.idea' )
    PyCharm.createProject()
    FastScript.prettyPrintError( 'Now please execute: runPyCharm.sh' )

except ( AssertionError, RuntimeError ) as details:
    logging.error( details )

    # show stacktrace in verbose mode
    if Any.getDebugLevel() >= 5:
        raise
Exemplo n.º 20
0
def getSwitchEnvironmentList(fromPlatform=None):
    """
        This function can be used to fetch a list of platforms to which
        the <fromPlatform> can be switched to. Example:

           getSwitchEnvironmentList( 'lucid64' )

        According to the returned list it is possible to switchEnvironment()
        from 'precise64' to 'windows-amd64-vs2012', but not to 'vxworks'.


        If <fromPlatform> is None, all possible cross-compilation platforms
        are returned.
    """
    if fromPlatform is None:
        xcmpHosts = ToolBOSSettings.getConfigOption('BST_crossCompileHosts')

        # only return those which are not None
        result = filter(bool, xcmpHosts.keys())
        result.sort()

        return result

    Any.requireIsTextNonEmpty(fromPlatform)

    if fromPlatform not in Platforms.getPlatformNames():
        raise ValueError('%s: unsupported platform name' % fromPlatform)

    # get list of all functions in this module, then filter it by name
    # (function-name convention allows us to filter-out the supported target
    # platforms)

    allSymbols = globals().keys()
    criteria = lambda s: s.startswith('_switchEnv_')
    candidates = filter(criteria, allSymbols)

    regexp = re.compile('^_switchEnv_%s_to_(.*)$' % fromPlatform)
    resultList = []

    for candidate in candidates:
        tmp = regexp.search(candidate)

        if tmp is not None:
            targetPlatform = tmp.group(1)
            Any.requireIsTextNonEmpty(targetPlatform)

            # At the time of writing the Windows-platforms are named
            # windows-i386-msvc and windows-amd64-msvc. However names with
            # dashes can't be used as function names thus the above
            # candidates don't contain such dashes.
            #
            # As a hack I'm replacing such well-known names here by hand.
            # Better solutions are highly appreciated. Alternatively the
            # Windows platforms could be renamed, e.g. "win32".
            #
            if targetPlatform == 'windowsi386vs2010':
                targetPlatform = 'windows-i386-vs2010'
            elif targetPlatform == 'windowsamd64vs2010':
                targetPlatform = 'windows-amd64-vs2010'
            elif targetPlatform == 'windowsi386vs2012':
                targetPlatform = 'windows-i386-vs2012'
            elif targetPlatform == 'windowsamd64vs2012':
                targetPlatform = 'windows-amd64-vs2012'
            elif targetPlatform == 'windowsi386vs2017':
                targetPlatform = 'windows-i386-vs2017'
            elif targetPlatform == 'windowsamd64vs2017':
                targetPlatform = 'windows-amd64-vs2017'

            resultList.append(targetPlatform)

    resultList.sort()

    return resultList
Exemplo n.º 21
0
from ToolBOSCore.Settings import ToolBOSSettings
from ToolBOSCore.Storage import SIT
from ToolBOSCore.Storage.BashSrc import BashSrcWriter
from ToolBOSCore.Storage.CmdSrc import CmdSrcWriter
from ToolBOSCore.Storage.PackageVar import PackageVarCmakeWriter
from ToolBOSCore.Storage.PkgInfoWriter import PkgInfoWriter
from ToolBOSCore.Util import Any
from ToolBOSCore.Util import FastScript

# location of core templates such as Master, C_Library etc.
templateDir_core = os.path.join(FastScript.getEnv('TOOLBOSCORE_ROOT'),
                                'etc/mako-templates')

# location of higher-level templates such as BBCMs etc.
templateDir = os.path.join(
    SIT.getPath(), ToolBOSSettings.getConfigOption('package_pkgCreator'),
    'etc/mako-templates')


class PackageCreator(object):

    # some templates should not be directly visible to the users,
    # e.g. the Software Quality Guideline, if False they will be hidden
    # in the Package Creator GUI (TBCORE-1201)

    show = True

    def __init__(self, packageName, packageVersion, values=None, outputDir=''):
        Any.requireIsTextNonEmpty(packageName)
        Any.requireIsTextNonEmpty(packageVersion)
        Any.requireIsText(outputDir)
Exemplo n.º 22
0
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')
Exemplo n.º 23
0
    def run(self):
        from ToolBOSCore.SoftwareQuality import Common, Rules

        if not 'category' in self.values:
            self.values['category'] = 'Intranet'

        if not 'dependencies' in self.values:
            self.values['dependencies'] = []

        srcDir = os.path.join(self.templateDir, 'QualityGuideline')
        dstDir = self.outputDir

        self.templateDir = srcDir

        # fill 'values' with content from actual SQ rules

        rules = Rules.getRules()

        ruleIDs = []
        level_cleanLab = []
        level_basic = []
        level_advanced = []
        level_safety = []

        for (ruleID, rule) in rules:

            ruleIDs.append(ruleID)

            if rule.sqLevel is None:
                # rule is optional, do not put into level categories
                continue

            if 'cleanLab' in rule.sqLevel:
                level_cleanLab.append(ruleID)

            if 'basic' in rule.sqLevel:
                level_basic.append(ruleID)

            if 'advanced' in rule.sqLevel:
                level_advanced.append(ruleID)

            if 'safety' in rule.sqLevel:
                level_safety.append(ruleID)

        self.values['level_cleanLab'] = level_cleanLab
        self.values['level_basic'] = level_basic
        self.values['level_advanced'] = level_advanced
        self.values['level_safety'] = level_safety

        self.values['sectionKeys'] = Common.sectionKeys
        self.values['sectionNames'] = Common.sectionNames
        self.values['sectionObjectives'] = Common.sectionObjectives
        self.values['sqLevelDefault'] = Common.sqLevelDefault
        self.values['sqLevelNames'] = Common.sqLevelNames
        self.values['sqLevels'] = Common.sqLevels
        self.values['rules'] = Rules.getRules()
        self.values['ruleIDs'] = ruleIDs

        self.values['documentationURL_dir'] = ToolBOSSettings.getConfigOption(
            'documentationURL_dir')

        self.templatize(os.path.join(srcDir, 'online.html.mako'),
                        os.path.join(dstDir, 'QualityGuideline.html'))

        self.templatize(
            os.path.join(srcDir, 'printable.html.mako'),
            os.path.join(dstDir, 'QualityGuideline-printable.html'))
Exemplo n.º 24
0
        if os.path.exists(filePath):
            logging.debug('probing for %s: found', filePath)
            return filePath
        else:
            logging.debug('probing for %s: Not found', filePath)

    raise IOError('No %s found' % fileName)


#----------------------------------------------------------------------------
# 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)
Exemplo n.º 25
0
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'))
Exemplo n.º 26
0
    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')
Exemplo n.º 27
0
argman.addArgument('-m',
                   '--msvc-version',
                   type=int,
                   help='SDK version to setup (default: 2017)')

argman.addExample('%(prog)s')

args = vars(argman.run())
path = args['path']
version = args['msvc_version']

if not path:
    path = os.path.expandvars('${HOME}/.wine')

if not version:
    version = ToolBOSSettings.getConfigOption('msvcVersion')

#----------------------------------------------------------------------------
# Main program
#----------------------------------------------------------------------------

logging.info('Wine config directory: %s', path)

if version not in (2008, 2010, 2012, 2017):
    logging.error('Unsupported MSVC version %s', version)

try:
    setupMSVC(path, version)
    logging.info('OK, MSVC compiler is ready.')

except (EnvironmentError, OSError, ValueError) as details:
Exemplo n.º 28
0
def codeCheck():
    """
        Performs a static source code analysis using PyCharm's built-in
        code inspector.

        The default inspection profile of the project is used, which unless
        modified by the developer will be the common HRI-EU profile coming
        from CreatePyCharmProject.py

        If there is no ".idea" directory in the current directory, it will
        be temporarily created and deleted when finished.

        @returns: defects as list of XML strings

        @see: parseCodeCheckResult()

    """
    ProcessEnv.source(ToolBOSSettings.getConfigOption('package_pycharm'))

    output = StringIO()
    FastScript.execProgram('ps aux', stdout=output, stderr=output)

    if output.getvalue().find('pycharm') > 0:
        raise RuntimeError(
            'PyCharm already running, unable to invoke code checker')

    # create project files if not existing
    if os.path.exists('.idea'):
        created = False
    else:
        created = True
        #createUserConfig()
        createProject()

    resultsDir = 'build/PY05'
    FastScript.remove(resultsDir)
    FastScript.mkdir(resultsDir)

    output.truncate(0)

    cmd = 'inspect.sh . HRI-EU %s' % resultsDir

    try:
        logging.info('running analysis...')
        FastScript.execProgram(cmd, stdout=output, stderr=output)

        if Any.getDebugLevel() > 3:
            logging.info('\n' + output.getvalue())

    except subprocess.CalledProcessError:
        if output.getvalue().find('No valid license found') > 0:
            raise RuntimeError('PyCharm: No valid license found')
        else:
            raise RuntimeError(output.getvalue())

    # delete project files if we have created them
    if created:
        FastScript.remove('.idea')

    resultList = []

    for filePath in glob.glob('build/PY05/*.xml'):
        Any.requireIsFile(filePath)
        content = FastScript.getFileContent(filePath)

        resultList.append(content)

    return resultList