Changeset 4ca26c9b in mainline


Ignore:
Timestamp:
2010-06-22T11:37:50Z (14 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
fdaad75d
Parents:
6b80696
Message:

improve support for Vcc, add basic source preprocessing (thx to Ondrej Sery)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/checkers/vcc.py

    r6b80696 r4ca26c9b  
    3636import subprocess
    3737import jobfile
     38import re
    3839
    3940jobs = [
    40         "kernel/kernel.job",
    41         "uspace/srv/clip/clip.job"
     41        "kernel/kernel.job"
    4242]
     43
     44re_attribute = re.compile("__attribute__\s*\(\(.*\)\)")
     45re_va_list = re.compile("__builtin_va_list")
    4346
    4447def usage(prname):
    4548        "Print usage syntax"
    46         print prname + " <ROOT>"
     49        print prname + " <ROOT> [VCC_PATH]"
    4750
    4851def cygpath(upath):
     
    6871       
    6972        for line in preproc.splitlines():
     73               
    7074                # Ignore preprocessor directives
     75               
    7176                if (line.startswith('#')):
    7277                        continue
     78               
     79                # Remove __attribute__((.*)) GCC extension
     80               
     81                line = re.sub(re_attribute, "", line)
     82               
     83                # Ignore unsupported __builtin_va_list type
     84                # (a better solution replacing __builrin_va_list with
     85                # an emulated implementation is needed)
     86               
     87                line = re.sub(re_va_list, "void *", line)
    7388               
    7489                tmpf.write("%s\n" % line)
     
    8095        return True
    8196
    82 def vcc(root, job):
     97def vcc(vcc_path, root, job):
    8398        "Run Vcc on a jobfile"
    8499       
     
    120135                tmpfqname = os.path.join(base, tmpfname)
    121136               
     137                vccfname = "%s.i" % srcfname
     138                vccfqname = os.path.join(base, vccfname);
     139               
    122140                # Only C files are interesting for us
    123141                if (tool != "cc"):
     
    130148               
    131149                # Run Vcc
     150                print " -- %s --" % srcfname           
     151                retval = subprocess.Popen([vcc_path, cygpath(tmpfqname)]).wait()
    132152               
    133                 retval = subprocess.Popen(['vcc', cygpath(tmpfqname)]).wait()
     153                if (retval != 0):
     154                        return False
    134155               
    135                 # Cleanup
     156                # Cleanup, but only if verification was successful
     157                # (to be able to examine the preprocessed file)
    136158               
    137159                if (os.path.isfile(tmpfqname)):
    138160                        os.remove(tmpfqname)
    139                
    140                 if (retval != 0):
    141                         return False
     161                        os.remove(vccfqname)
    142162       
    143163        return True
     
    149169       
    150170        rootdir = os.path.abspath(sys.argv[1])
     171        if (len(sys.argv) > 2):
     172                vcc_path = sys.argv[2]
     173        else:
     174                vcc_path = "/cygdrive/c/Program Files (x86)/Microsoft Research/Vcc/Binaries/vcc"
     175       
     176        if (not os.path.isfile(vcc_path)):
     177                print "%s is not a binary." % vcc_path
     178                print "Please supply the full Cygwin path to Vcc as the second argument."
     179                return
     180       
    151181        config = os.path.join(rootdir, "HelenOS.config")
    152182       
     
    157187       
    158188        for job in jobs:
    159                 if (not vcc(rootdir, job)):
     189                if (not vcc(vcc_path, rootdir, job)):
    160190                        print
    161191                        print "Failed job: %s" % job
Note: See TracChangeset for help on using the changeset viewer.