diff options
author | Al Stone <ahs3@redhat.com> | 2012-11-26 12:23:17 -0700 |
---|---|---|
committer | Al Stone <ahs3@redhat.com> | 2012-11-26 12:23:17 -0700 |
commit | 69c6f928b5589e3f50fad870da1e8b345d466a98 (patch) | |
tree | e3cd40819325b05cbe861dbb035fc390498dd1e3 /scanners | |
download | portdep-69c6f928b5589e3f50fad870da1e8b345d466a98.tar.gz portdep-69c6f928b5589e3f50fad870da1e8b345d466a98.tar.xz portdep-69c6f928b5589e3f50fad870da1e8b345d466a98.zip |
initial commit
Signed-off-by: Al Stone <ahs3@redhat.com>
Diffstat (limited to 'scanners')
-rwxr-xr-x | scanners/dot-s-files.sh | 15 | ||||
-rwxr-xr-x | scanners/ifdefs.py | 56 | ||||
-rwxr-xr-x | scanners/which-asm.sh | 43 |
3 files changed, 114 insertions, 0 deletions
diff --git a/scanners/dot-s-files.sh b/scanners/dot-s-files.sh new file mode 100755 index 0000000..0fb7f18 --- /dev/null +++ b/scanners/dot-s-files.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +scanner="Dot-S-Files" + +workdir="$1" +src="$2" + +if [ -d "$src" ] +then + count=$(find "$src" -name '*\.[sS]' -print | wc -l) +else + count="-1" +fi +echo "${scanner}: $count" + diff --git a/scanners/ifdefs.py b/scanners/ifdefs.py new file mode 100755 index 0000000..ba817fa --- /dev/null +++ b/scanners/ifdefs.py @@ -0,0 +1,56 @@ +#!/usr/bin/env python + +import os +import os.path +import re +import subprocess +import sys + +def main(): + '''this scanner counts up the number of instances of #ifdef that + have an architecture name in them. + ''' + path = sys.argv[2] + + arches = ['__alpha__', '__alpha_ev[0-9]+__', + '__amd64__', '__x64_64__', + '__arm__', '__thumb__', '__TARGET_ARM_[0-9A-Z]+__', + '__convex__', '__convex_[0-9]+__', + '__epiphany__', + '__hppa__', '__PA_RISC[0-9]_[0-9]__', '__HPPA[0-9]+__', + '__PA[0-9][0-9]00__', + '__i[3-6]86__', + '__ia64__', + '__m68k__', '__mc680[0-9]0__', '__MC680[0-9]0__', + '__mips__', '__MIPS_ISA_MIPS[0-9]__', + '__powerpc__', '__ppc[0-9]*__', + '__sparc__', + '__sh[0-9]__', + '__s390__', '__s390x__', + '__TMS320[0-9A-Z]*__', + '__TMS470__', + ] + + cmd = 'grep -hr \'^#if[ \\t]*def.*\' %s' % path + count = 0 + findings = "" + try: + prog = re.compile('|'.join(arches)) + findings = subprocess.check_output(cmd, shell=True) + if findings: + for ii in findings.split('\n'): + if prog.search(ii): + count += 1 + except subprocess.CalledProcessError, e: + if e.returncode == 1: # usually means nothing found + count = 0 + else: + count = -1 + + result = 'Ifdef-Arch: %d' % count + return result + +if __name__ == '__main__': + result = main() + +print result diff --git a/scanners/which-asm.sh b/scanners/which-asm.sh new file mode 100755 index 0000000..6e63ed2 --- /dev/null +++ b/scanners/which-asm.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +scanner="Which-Asm" + +workdir="$1" +src="$2" + +WHICHASM=whichasm + +count=0 +if [ -d "$src" ] +then + find "$src" \( -name '*\.[cCsShH]' \ + -o -name '*\.cc' \ + -o -name '*\.cxx' \ + -o -name '*\.cpp' \ + \) -print > /tmp/$$ + if [ -s /tmp/$$ ] + then + count=$(cat /tmp/$$ | ( + count=0 + read line + while [ ! -z $line ] + do + res=$(${WHICHASM} $line) + if [ "$(echo $res | grep ^error:)" ] || \ + [ "$(echo $res | grep '.*: unknown')" ] + then + true + else + count+=1 + fi + read line + done + echo $count + )) + fi + rm -f /tmp/$$ +else + count="-1" +fi +echo "${scanner}: $count" + |