Changes in tools/checkers/vcc.py [33c4f72:958de16] in mainline


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/checkers/vcc.py

    r33c4f72 r958de16  
    3636import subprocess
    3737import jobfile
    38 import re
    3938
    4039jobs = [
    41         "kernel/kernel.job"
     40        "kernel/kernel.job",
     41        "uspace/srv/clip/clip.job"
    4242]
    43 
    44 re_attribute = re.compile("__attribute__\s*\(\(.*\)\)")
    45 re_va_list = re.compile("__builtin_va_list")
    46 
    47 specification = ""
    4843
    4944def usage(prname):
    5045        "Print usage syntax"
    51         print prname + " <ROOT> [VCC_PATH]"
     46        print prname + " <ROOT>"
    5247
    5348def cygpath(upath):
     
    5954        "Preprocess source using GCC preprocessor and compatibility tweaks"
    6055       
    61         global specification
    62        
    6356        args = ['gcc', '-E']
    6457        args.extend(options.split())
    65         args.extend(['-DCONFIG_VERIFY_VCC=1', srcfname])
     58        args.append(srcfname)
    6659       
    6760        # Change working directory
     
    7366       
    7467        tmpf = file(tmpfname, "w")
    75         tmpf.write(specification)
    7668       
    7769        for line in preproc.splitlines():
    78                
    7970                # Ignore preprocessor directives
    80                
    8171                if (line.startswith('#')):
    8272                        continue
    83                
    84                 # Remove __attribute__((.*)) GCC extension
    85                
    86                 line = re.sub(re_attribute, "", line)
    87                
    88                 # Ignore unsupported __builtin_va_list type
    89                 # (a better solution replacing __builrin_va_list with
    90                 # an emulated implementation is needed)
    91                
    92                 line = re.sub(re_va_list, "void *", line)
    9373               
    9474                tmpf.write("%s\n" % line)
     
    10080        return True
    10181
    102 def vcc(vcc_path, root, job):
     82def vcc(root, job):
    10383        "Run Vcc on a jobfile"
    10484       
     
    140120                tmpfqname = os.path.join(base, tmpfname)
    141121               
    142                 vccfname = "%s.i" % srcfname
    143                 vccfqname = os.path.join(base, vccfname);
    144                
    145122                # Only C files are interesting for us
    146123                if (tool != "cc"):
     
    153130               
    154131                # Run Vcc
    155                 print " -- %s --" % srcfname           
    156                 retval = subprocess.Popen([vcc_path, '/pointersize:32', '/newsyntax', cygpath(tmpfqname)]).wait()
     132               
     133                retval = subprocess.Popen(['vcc', cygpath(tmpfqname)]).wait()
     134               
     135                # Cleanup
     136               
     137                if (os.path.isfile(tmpfqname)):
     138                        os.remove(tmpfqname)
    157139               
    158140                if (retval != 0):
    159141                        return False
    160                
    161                 # Cleanup, but only if verification was successful
    162                 # (to be able to examine the preprocessed file)
    163                
    164                 if (os.path.isfile(tmpfqname)):
    165                         os.remove(tmpfqname)
    166                         os.remove(vccfqname)
    167142       
    168143        return True
    169144
    170145def main():
    171         global specification
    172        
    173146        if (len(sys.argv) < 2):
    174147                usage(sys.argv[0])
     
    176149       
    177150        rootdir = os.path.abspath(sys.argv[1])
    178         if (len(sys.argv) > 2):
    179                 vcc_path = sys.argv[2]
    180         else:
    181                 vcc_path = "/cygdrive/c/Program Files (x86)/Microsoft Research/Vcc/Binaries/vcc"
    182        
    183         if (not os.path.isfile(vcc_path)):
    184                 print "%s is not a binary." % vcc_path
    185                 print "Please supply the full Cygwin path to Vcc as the second argument."
    186                 return
    187        
    188151        config = os.path.join(rootdir, "HelenOS.config")
    189152       
     
    193156                return
    194157       
    195         specpath = os.path.join(rootdir, "tools/checkers/vcc.h")
    196         if (not os.path.isfile(specpath)):
    197                 print "%s not found." % config
    198                 return
    199        
    200         specfile = file(specpath, "r")
    201         specification = specfile.read()
    202         specfile.close()
    203        
    204158        for job in jobs:
    205                 if (not vcc(vcc_path, rootdir, job)):
     159                if (not vcc(rootdir, job)):
    206160                        print
    207161                        print "Failed job: %s" % job
Note: See TracChangeset for help on using the changeset viewer.