コード例 #1
0
def clang(root, job):
    "Run Clang on a jobfile"

    inname = os.path.join(root, job)

    if (not os.path.isfile(inname)):
        print("Unable to open %s" % inname)
        print("Did you run \"make precheck\" on the source tree?")
        return False

    inf = open(inname, "r")
    records = inf.read().splitlines()
    inf.close()

    for record in records:
        arg = jobfile.parse_arg(record)
        if (not arg):
            return False

        if (len(arg) < 6):
            print("Not enough jobfile record arguments")
            return False

        srcfname = arg[0]
        tgtfname = arg[1]
        tool = arg[2]
        category = arg[3]
        base = arg[4]
        options = arg[5].split()

        srcfqname = os.path.join(base, srcfname)
        if (not os.path.isfile(srcfqname)):
            print("Source %s not found" % srcfqname)
            return False

        # Only C files are interesting for us
        if (tool != "cc"):
            continue

        args = [
            'clang', '-Qunused-arguments', '--analyze', '-Xanalyzer',
            '-analyzer-opt-analyze-headers', '-Xanalyzer', '-checker-cfref'
        ]
        args.extend(options)
        args.extend(['-o', tgtfname, srcfname])

        cwd = os.getcwd()
        os.chdir(base)
        retval = subprocess.Popen(args).wait()
        os.chdir(cwd)

        if (retval != 0):
            return False

    return True
コード例 #2
0
ファイル: clang.py プロジェクト: narke/Einherjar.tmp
def clang(root, job):
	"Run Clang on a jobfile"
	
	inname = os.path.join(root, job)
	
	if (not os.path.isfile(inname)):
		print("Unable to open %s" % inname)
		print("Did you run \"make precheck\" on the source tree?")
		return False
	
	inf = open(inname, "r")
	records = inf.read().splitlines()
	inf.close()
	
	for record in records:
		arg = jobfile.parse_arg(record)
		if (not arg):
			return False
		
		if (len(arg) < 6):
			print("Not enough jobfile record arguments")
			return False
		
		srcfname = arg[0]
		tgtfname = arg[1]
		tool = arg[2]
		category = arg[3]
		base = arg[4]
		options = arg[5].split()
		
		srcfqname = os.path.join(base, srcfname)
		if (not os.path.isfile(srcfqname)):
			print("Source %s not found" % srcfqname)
			return False
		
		# Only C files are interesting for us
		if (tool != "cc"):
			continue
		
		args = ['clang', '-Qunused-arguments', '--analyze',
			'-Xanalyzer', '-analyzer-opt-analyze-headers',
			'-Xanalyzer', '-checker-cfref']
		args.extend(options)
		args.extend(['-o', tgtfname, srcfname])
		
		cwd = os.getcwd()
		os.chdir(base)
		retval = subprocess.Popen(args).wait()
		os.chdir(cwd)
		
		if (retval != 0):
			return False
		
	return True
コード例 #3
0
def stanse(root, job):
    "Run Stanse on a jobfile"

    # Convert generic jobfile to Stanse-specific jobfile format

    inname = os.path.join(root, job)
    outname = os.path.join(root, "_%s" % os.path.basename(job))

    if (not os.path.isfile(inname)):
        print("Unable to open %s" % inname)
        print("Did you run \"make precheck\" on the source tree?")
        return False

    inf = open(inname, "r")
    records = inf.read().splitlines()
    inf.close()

    output = []
    for record in records:
        arg = jobfile.parse_arg(record)
        if (not arg):
            return False

        if (len(arg) < 6):
            print("Not enough jobfile record arguments")
            return False

        srcfname = arg[0]
        tgtfname = arg[1]
        tool = arg[2]
        category = arg[3]
        base = arg[4]
        options = arg[5]

        srcfqname = os.path.join(base, srcfname)
        if (not os.path.isfile(srcfqname)):
            print("Source %s not found" % srcfqname)
            return False

        # Only C files are interesting for us
        if (tool != "cc"):
            continue

        output.append([srcfname, tgtfname, base, options])

    outf = open(outname, "w")
    for record in output:
        outf.write("{%s},{%s},{%s},{%s}\n" %
                   (record[0], record[1], record[2], record[3]))
    outf.close()

    # Run Stanse

    retval = subprocess.Popen(
        ['stanse', '--checker', 'ReachabilityChecker', '--jobfile',
         outname]).wait()

    # Cleanup

    os.remove(outname)
    for record in output:
        tmpfile = os.path.join(record[2], "%s.preproc" % record[1])
        if (os.path.isfile(tmpfile)):
            os.remove(tmpfile)

    if (retval == 0):
        return True

    return False
コード例 #4
0
ファイル: vcc.py プロジェクト: narke/Einherjar.tmp
def vcc(vcc_path, root, job):
	"Run Vcc on a jobfile"
	
	# Parse jobfile
	
	inname = os.path.join(root, job)
	
	if (not os.path.isfile(inname)):
		print("Unable to open %s" % inname)
		print("Did you run \"make precheck\" on the source tree?")
		return False
	
	inf = open(inname, "r")
	records = inf.read().splitlines()
	inf.close()
	
	for record in records:
		arg = jobfile.parse_arg(record)
		if (not arg):
			return False
		
		if (len(arg) < 6):
			print("Not enough jobfile record arguments")
			return False
		
		srcfname = arg[0]
		tgtfname = arg[1]
		tool = arg[2]
		category = arg[3]
		base = arg[4]
		options = arg[5]
		
		srcfqname = os.path.join(base, srcfname)
		if (not os.path.isfile(srcfqname)):
			print("Source %s not found" % srcfqname)
			return False
		
		tmpfname = "%s.preproc" % srcfname
		tmpfqname = os.path.join(base, tmpfname)
		
		vccfname = "%s.i" % srcfname
		vccfqname = os.path.join(base, vccfname);
		
		# Only C files are interesting for us
		if (tool != "cc"):
			continue
		
		# Preprocess sources
		
		if (not preprocess(srcfname, tmpfname, base, options)):
			return False
		
		# Run Vcc
		print(" -- %s --" % srcfname)
		retval = subprocess.Popen([vcc_path, '/pointersize:32', '/newsyntax', cygpath(tmpfqname)]).wait()
		
		if (retval != 0):
			return False
		
		# Cleanup, but only if verification was successful
		# (to be able to examine the preprocessed file)
		
		if (os.path.isfile(tmpfqname)):
			os.remove(tmpfqname)
			os.remove(vccfqname)
	
	return True
コード例 #5
0
ファイル: vcc.py プロジェクト: solotic/helenos
def vcc(vcc_path, root, job):
    "Run Vcc on a jobfile"

    # Parse jobfile

    inname = os.path.join(root, job)

    if (not os.path.isfile(inname)):
        print("Unable to open %s" % inname)
        print("Did you run \"make precheck\" on the source tree?")
        return False

    inf = open(inname, "r")
    records = inf.read().splitlines()
    inf.close()

    for record in records:
        arg = jobfile.parse_arg(record)
        if (not arg):
            return False

        if (len(arg) < 6):
            print("Not enough jobfile record arguments")
            return False

        srcfname = arg[0]
        tgtfname = arg[1]
        tool = arg[2]
        category = arg[3]
        base = arg[4]
        options = arg[5]

        srcfqname = os.path.join(base, srcfname)
        if (not os.path.isfile(srcfqname)):
            print("Source %s not found" % srcfqname)
            return False

        tmpfname = "%s.preproc" % srcfname
        tmpfqname = os.path.join(base, tmpfname)

        vccfname = "%s.i" % srcfname
        vccfqname = os.path.join(base, vccfname)

        # Only C files are interesting for us
        if (tool != "cc"):
            continue

        # Preprocess sources

        if (not preprocess(srcfname, tmpfname, base, options)):
            return False

        # Run Vcc
        print(" -- %s --" % srcfname)
        retval = subprocess.Popen(
            [vcc_path, '/pointersize:32', '/newsyntax',
             cygpath(tmpfqname)]).wait()

        if (retval != 0):
            return False

        # Cleanup, but only if verification was successful
        # (to be able to examine the preprocessed file)

        if (os.path.isfile(tmpfqname)):
            os.remove(tmpfqname)
            os.remove(vccfqname)

    return True
コード例 #6
0
ファイル: stanse.py プロジェクト: fhector/helenOS-0.5-Hector
def stanse(root, job):
	"Run Stanse on a jobfile"
	
	# Convert generic jobfile to Stanse-specific jobfile format
	
	inname = os.path.join(root, job)
	outname = os.path.join(root, "_%s" % os.path.basename(job))
	
	if (not os.path.isfile(inname)):
		print("Unable to open %s" % inname)
		print("Did you run \"make precheck\" on the source tree?")
		return False
	
	inf = open(inname, "r")
	records = inf.read().splitlines()
	inf.close()
	
	output = []
	for record in records:
		arg = jobfile.parse_arg(record)
		if (not arg):
			return False
		
		if (len(arg) < 6):
			print("Not enough jobfile record arguments")
			return False
		
		srcfname = arg[0]
		tgtfname = arg[1]
		tool = arg[2]
		category = arg[3]
		base = arg[4]
		options = arg[5]
		
		srcfqname = os.path.join(base, srcfname)
		if (not os.path.isfile(srcfqname)):
			print("Source %s not found" % srcfqname)
			return False
		
		# Only C files are interesting for us
		if (tool != "cc"):
			continue
		
		output.append([srcfname, tgtfname, base, options])
	
	outf = open(outname, "w")
	for record in output:
		outf.write("{%s},{%s},{%s},{%s}\n" % (record[0], record[1], record[2], record[3]))
	outf.close()
	
	# Run Stanse
	
	retval = subprocess.Popen(['stanse', '--checker', 'ReachabilityChecker', '--jobfile', outname]).wait()
	
	# Cleanup
	
	os.remove(outname)
	for record in output:
		tmpfile = os.path.join(record[2], "%s.preproc" % record[1])
		if (os.path.isfile(tmpfile)):
			os.remove(tmpfile)
	
	if (retval == 0):
		return True
	
	return False