예제 #1
0
파일: gcc.py 프로젝트: jondo2010/cuppa
 def version_from_command( cls, cxx ):
     command = "{} --version".format( cxx )
     if command_available( command ):
         reported_version = Popen( shlex.split( command ), stdout=PIPE).communicate()[0]
         reported_version = 'gcc' + re.search( r'(\d)\.(\d)', reported_version ).expand(r'\1\2')
         return reported_version
     return None
예제 #2
0
 def version_from_command(cls, cxx):
     command = "{} --version".format(cxx)
     if command_available(command):
         reported_version = None
         version_string = as_str(
             Popen(shlex.split(command), stdout=PIPE).communicate()[0])
         matches = re.search(r'based on LLVM (?P<major>\d+)\.(?P<minor>\d)',
                             version_string)
         if not matches:
             matches = re.search(
                 r'Apple LLVM version (?P<major>\d+)\.(?P<minor>\d)',
                 version_string)
             if not matches:
                 matches = re.search(
                     r'clang version (?P<major>\d+)\.(?P<minor>\d)',
                     version_string)
         if matches:
             major = matches.group('major')
             minor = matches.group('minor')
             reported_version = {}
             reported_version['toolchain'] = 'clang'
             reported_version['name'] = 'clang' + major + minor
             reported_version['major'] = int(major)
             reported_version['minor'] = int(minor)
             reported_version['version'] = major + "." + minor
             reported_version['short_version'] = major + minor
         return reported_version
     return None
예제 #3
0
    def _run_gcovr(self, build_dir, output_dir, working_dir, sconscript_id):
        command = 'gcovr -h'
        if not command_available(command):
            print "cuppa: gcov: Skipping gcovr output as not available"
            return

        base_name = coverage_base_name(sconscript_id)

        index_file = base_name + ".html"

        regex_filter = re.escape(os.path.join(build_dir, ""))
        regex_filter = ".*" + regex_filter + ".*\.gcov"

        command = 'gcovr -g --gcov-filter="{}" -k -r . --html --html-details -o {}'.format(
            regex_filter, index_file)

        return_code, output = run_command(command, working_dir)

        new_index_file = os.path.join(output_dir, "coverage.html")
        try:
            os.rename(index_file, new_index_file)
        except OSError as e:
            print "cuppa: gcov: Failed moving coverage file from [{}] to [{}] with error: {}".format(
                index_file, new_index_file, str(e))

        coverage_files = Glob(base_name + '*.html')
        for coverage_file in coverage_files:
            new_coverage_file = os.path.join(output_dir, str(coverage_file))
            try:
                os.rename(str(coverage_file), new_coverage_file)
            except OSError as e:
                print "cuppa: gcov: Failed moving coverage file from [{}] to [{}] with error: {}".format(
                    str(coverage_file), new_coverage_file, str(e))
        print output
예제 #4
0
파일: gcc.py 프로젝트: KieronAllsop/cuppa
 def version_from_command( cls, cxx ):
     command = "{} --version".format( cxx )
     if command_available( command ):
         reported_version = Popen( shlex.split( command ), stdout=PIPE).communicate()[0]
         reported_version = 'gcc' + re.search( r'(\d)\.(\d)', reported_version ).expand(r'\1\2')
         return reported_version
     return None
예제 #5
0
    def _run_gcovr( self, build_dir, output_dir, working_dir, sconscript_id ):
        command = 'gcovr -h'
        if not command_available( command ):
            print "coverage: skipping gcovr output as not available"
            return

        base_name = coverage_base_name( sconscript_id )

        index_file = base_name + ".html"

        regex_filter = re.escape( os.path.join( build_dir, "" ) )
        regex_filter = ".*" + regex_filter + ".*\.gcov"

        command = 'gcovr -g --gcov-filter="{}" -k -r . --html --html-details -o {}'.format( regex_filter, index_file )

        return_code, output = run_command( command, working_dir )

        if return_code == 0:
            os.rename( index_file, os.path.join( output_dir, "coverage.html" ) )
            coverage_files = Glob( base_name + '*.html' )
            for coverage_file in coverage_files:
                new_coverage_file = os.path.join( output_dir, str( coverage_file ) )
                os.rename( str( coverage_file ), new_coverage_file )
            print output
        else:
            print output
예제 #6
0
    def _run_gcovr(self, build_dir, output_dir, working_dir, sconscript_id):
        command = 'gcovr -h'
        if not command_available(command):
            print "coverage: skipping gcovr output as not available"
            return

        base_name = coverage_base_name(sconscript_id)

        index_file = base_name + ".html"

        regex_filter = re.escape(os.path.join(build_dir, ""))
        regex_filter = ".*" + regex_filter + ".*\.gcov"

        command = 'gcovr -g --gcov-filter="{}" -k -r . --html --html-details -o {}'.format(
            regex_filter, index_file)

        return_code, output = run_command(command, working_dir)

        if return_code == 0:
            os.rename(index_file, os.path.join(output_dir, "coverage.html"))
            coverage_files = Glob(base_name + '*.html')
            for coverage_file in coverage_files:
                new_coverage_file = os.path.join(output_dir,
                                                 str(coverage_file))
                os.rename(str(coverage_file), new_coverage_file)
            print output
        else:
            print output
예제 #7
0
파일: clang.py 프로젝트: ja11sop/cuppa
 def llvm_version_from( cls, llvm_tool ):
     command = "{} --version".format( llvm_tool )
     if command_available( command ):
         reported_version = Popen( shlex.split( command ), stdout=PIPE).communicate()[0]
         version = re.search( r'LLVM version (\d)\.(\d)\.(\d)', reported_version )
         reported_version = version.expand(r'\1')
         return reported_version
     return None
예제 #8
0
파일: cl.py 프로젝트: KieronAllsop/cuppa
 def available_versions( cls ):
     if not hasattr( cls, '_available_versions' ):
         cls._available_versions = []
         for version in cls.supported_versions():
             command = "cl"
             if command_available( command ):
                 cls._available_versions = [ "cl" ]
     return cls._available_versions
예제 #9
0
파일: clang.py 프로젝트: svisser/cuppa
 def default_version( cls ):
     if not hasattr( cls, '_default_version' ):
         command = "clang++ --version"
         if command_available( command ):
             version = Popen( shlex.split( command ), stdout=PIPE).communicate()[0]
             cls._default_version = 'clang' + re.search( r'based on LLVM (\d)\.(\d)', version ).expand(r'\1\2')
         else:
             cls._default_version = None
     return cls._default_version
예제 #10
0
 def default_version( cls ):
     if not hasattr( cls, '_default_version' ):
         command = "g++ --version"
         if command_available( command ):
             version = Popen( shlex.split( command ), stdout=PIPE).communicate()[0]
             cls._default_version = 'gcc' + re.search( r'(\d)\.(\d)', version ).expand(r'\1\2')
         else:
             cls._default_version = None
     return cls._default_version
예제 #11
0
 def version_from_command( cls, cxx ):
     command = "{} --version".format( cxx )
     if command_available( command ):
         reported_version = Popen( shlex.split( command ), stdout=PIPE).communicate()[0]
         version = re.search( r'based on LLVM (\d)\.(\d)', reported_version )
         if not version:
             version = re.search( r'clang version (\d)\.(\d+)', reported_version )
         reported_version = 'clang' + version.expand(r'\1\2')
         return reported_version
     return None
예제 #12
0
 def version_from_command( cls, cxx ):
     command = "{} --version".format( cxx )
     if command_available( command ):
         reported_version = Popen( shlex.split( command ), stdout=PIPE).communicate()[0]
         version = re.search( r'based on LLVM (\d)\.(\d)', reported_version )
         if not version:
             version = re.search( r'clang version (\d)\.(\d+)', reported_version )
         reported_version = 'clang' + version.expand(r'\1\2')
         return reported_version
     return None
예제 #13
0
 def llvm_version_from(cls, llvm_tool):
     command = "{} --version".format(llvm_tool)
     if command_available(command):
         reported_version = Popen(shlex.split(command),
                                  stdout=PIPE).communicate()[0]
         version = re.search(r'LLVM version (\d)\.(\d)\.(\d)',
                             reported_version)
         reported_version = version.expand(r'\1')
         return reported_version
     return None
예제 #14
0
파일: clang.py 프로젝트: svisser/cuppa
 def available_versions( cls ):
     if not hasattr( cls, '_available_versions' ):
         cls._available_versions = []
         for version in cls.supported_versions():
             if version == "clang":
                 continue
             command = "clang++-{} --version".format( re.search( r'(\d)(\d)', version ).expand(r'\1.\2') )
             if command_available( command ):
                 reported_version = Popen( shlex.split( command ), stdout=PIPE).communicate()[0]
                 reported_version = 'clang' + re.search( r'based on LLVM (\d)\.(\d)', reported_version ).expand(r'\1\2')
                 if version == reported_version:
                     cls._available_versions.append( version )
                 else:
                     raise ClangException("CLANG toolchain [{}] reporting version as [{}].".format( version, reported_version ) )
         if cls._available_versions or cls.default_version():
             cls._available_versions.append( "clang" )
     return cls._available_versions
예제 #15
0
 def available_versions( cls ):
     if not hasattr( cls, '_available_versions' ):
         cls._available_versions = []
         for version in cls.supported_versions():
             if version == "gcc":
                 continue
             command = "g++-{} --version".format( re.search( r'(\d)(\d)', version ).expand(r'\1.\2') )
             if command_available( command ):
                 reported_version = Popen( shlex.split( command ), stdout=PIPE).communicate()[0]
                 reported_version = 'gcc' + re.search( r'(\d)\.(\d)', reported_version ).expand(r'\1\2')
                 if version == reported_version:
                     cls._available_versions.append( version )
                 else:
                     raise GccException("GCC toolchain [{}] reporting version as [{}].".format( version, reported_version ) )
         if cls._available_versions:
             cls._available_versions.append( "gcc" )
     return cls._available_versions
예제 #16
0
    def _run_gcovr( self, build_dir, output_dir, working_dir, sconscript_id ):
        command = 'gcovr -h'
        if not command_available( command ):
            print "cuppa: gcov: Skipping gcovr output as not available"
            return

        base_name = coverage_base_name( sconscript_id )

        index_file = base_name + ".html"

        regex_filter = re.escape( os.path.join( build_dir, "" ) )
        regex_filter = ".*" + regex_filter + ".*\.gcov"

        command = 'gcovr -g --gcov-filter="{}" -k -r . --html --html-details -o {}'.format( regex_filter, index_file )

        return_code, output = run_command( command, working_dir )

        new_index_file = os.path.join( output_dir, "coverage.html" )
        try:
            os.rename( index_file, new_index_file )
        except OSError as e:
            print "cuppa: gcov: Failed moving coverage file from [{}] to [{}] with error: {}".format(
                        index_file,
                        new_index_file,
                        str(e)
                )

        coverage_files = Glob( base_name + '*.html' )
        for coverage_file in coverage_files:
            new_coverage_file = os.path.join( output_dir, str( coverage_file ) )
            try:
                os.rename( str( coverage_file ), new_coverage_file )
            except OSError as e:
                print "cuppa: gcov: Failed moving coverage file from [{}] to [{}] with error: {}".format(
                        str( coverage_file ),
                        new_coverage_file,
                        str(e)
                )
        print output
예제 #17
0
 def available_versions(cls):
     if not hasattr(cls, '_available_versions'):
         cls._available_versions = []
         for version in cls.supported_versions():
             if version == "clang":
                 continue
             command = "clang++-{} --version".format(
                 re.search(r'(\d)(\d)', version).expand(r'\1.\2'))
             if command_available(command):
                 reported_version = Popen(shlex.split(command),
                                          stdout=PIPE).communicate()[0]
                 reported_version = 'clang' + re.search(
                     r'based on LLVM (\d)\.(\d)',
                     reported_version).expand(r'\1\2')
                 if version == reported_version:
                     cls._available_versions.append(version)
                 else:
                     raise ClangException(
                         "CLANG toolchain [{}] reporting version as [{}].".
                         format(version, reported_version))
         if cls._available_versions or cls.default_version():
             cls._available_versions.append("clang")
     return cls._available_versions
예제 #18
0
    def _run_gcovr(self, target, build_dir, output_dir, working_dir,
                   sconscript_id, include_regexes, exclude_regexes):

        cuppa.path.lazy_create_path(output_dir)

        command = 'gcovr -h'
        if not command_available(command):
            logger.warning("Skipping gcovr output as not available")
            return

        html_base_name = url_coverage_base_name(
            sconscript_id) + "." + self._program_id[2:]

        index_file = html_base_name + ".html"
        regex_filter = re.escape(os.path.join(build_dir, "")).replace(
            "\_", "_").replace("\#", "#")
        regex_filter = ".*" + regex_filter + ".*" + self._program_id + "\.gcov"

        gcov_includes = ""
        for include_regex in include_regexes:
            gcov_includes += ' --gcov-filter="{}"'.format(include_regex)

        if not gcov_includes:
            gcov_includes = ' --gcov-filter="{}"'.format(regex_filter)

        gcov_excludes = ""
        for exclude_regex in exclude_regexes:
            gcov_excludes += ' --gcov-exclude="{}"'.format(exclude_regex)

        command = 'gcovr -g {gcov_includes} {gcov_excludes} -s -k -r . --html --html-details -o {index_file}'.format(
            regex_filter=regex_filter,
            gcov_includes=gcov_includes,
            gcov_excludes=gcov_excludes,
            index_file=index_file)

        return_code, output = run_command(command, working_dir,
                                          self._scons_env)

        coverage_index_basename = "coverage" + self._url_program_id + ".html"
        new_index_file = os.path.join(output_dir, coverage_index_basename)
        try:
            os.rename(index_file, new_index_file)
        except OSError as e:
            logger.error(
                "Failed moving coverage file from [{}] to [{}] with error: {}".
                format(as_notice(index_file), as_notice(new_index_file),
                       as_error(str(e))))

        coverage_summary_path = os.path.splitext(new_index_file)[0] + ".log"
        with open(coverage_summary_path, 'w') as coverage_summary_file:
            coverage_summary_file.write(coverage_index_basename + "\n" +
                                        output)

        logger.trace("gcovr HTML file filter = [{}]".format(
            as_notice(html_base_name)))
        coverage_files = Glob(html_base_name + '*.html')

        for coverage_file in coverage_files:
            new_coverage_file = os.path.join(output_dir, str(coverage_file))
            target.append(new_coverage_file)
            try:
                os.rename(str(coverage_file), new_coverage_file)
            except OSError as e:
                logger.error(
                    "Failed moving coverage file from [{}] to [{}] with error: {}"
                    .format(as_notice(str(coverage_file)),
                            as_notice(new_coverage_file), as_error(str(e))))

        coverage_filter_path = os.path.join(
            output_dir, "coverage" + self._url_program_id + ".cov_filter")
        with open(coverage_filter_path, 'w') as coverage_filter_file:
            coverage_filter_file.write(html_base_name + '*.html')

        sys.stdout.write(output + "\n")