Advertisement
Guest User

Untitled

a guest
Jan 31st, 2015
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. #!/usr/bin/env python
  2. import json
  3. import subprocess
  4. import sys
  5.  
  6.  
  7. def run(cmd):
  8. # print(cmd)
  9. stringCmd = u" ".join(cmd)
  10. subprocess.call(stringCmd, shell=True)
  11.  
  12. def runIWYUGDB(wd, args):
  13. cmd =[u"gdb", u"--args"]
  14. cmd.extend(basecmd)
  15. cmd.extend(args)
  16. run(cmd)
  17.  
  18. def runIWYU(wd, args):
  19. cmd = basecmd[:]
  20. cmd.extend(args)
  21. run(cmd)
  22.  
  23. f = open("compile_commands.json", "r")
  24. tunits = json.load(f)
  25.  
  26. extraArg = u" ".join([u"-Xiwyu " + x for x in sys.argv[1:]])
  27.  
  28. basedir = u"/home/rpavlik/llvm-trunk/"
  29. basecmd = [basedir + u"bin/include-what-you-use", u"-Xiwyu", u"--verbose=2", extraArg] # "-working-directory", wd]
  30.  
  31. srcdir = "/home/rpavlik/src/third-party/llvm/tools/clang/tools/include-what-you-use/"
  32. mappingFiles = ["gcc.libc.imp", "gcc.stl.headers.imp", "gcc.symbols.imp", "google.imp", "third_party.imp"] # "iwyu.gcc.imp"
  33.  
  34. for mapping in mappingFiles:
  35. basecmd.extend(["-Xiwyu", "--mapping_file="+srcdir+mapping])
  36.  
  37.  
  38. for tu in tunits:
  39. oldDriver = tu["command"].split(None)[0]
  40. cmd = tu["command"].replace(oldDriver, u"")
  41. runIWYU(tu["directory"], [cmd])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement