Skip to content

Instantly share code, notes, and snippets.

@Hinidu
Created May 8, 2014 11:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Hinidu/25c1147c4e46e6caa823 to your computer and use it in GitHub Desktop.
Save Hinidu/25c1147c4e46e6caa823 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import json
import subprocess
import sys
def run(cmd):
stringCmd = u" ".join(cmd)
subprocess.call(stringCmd, shell=True)
def runIWYU(wd, args):
cmd = basecmd[:]
cmd.extend(args)
run(cmd)
f = open("build/compile_commands.json", "r")
tunits = json.load(f)
extraArg = u" ".join([u"-Xiwyu " + x for x in sys.argv[1:]])
basecmd = [u"include-what-you-use", u"-Xiwyu", u"--verbose=2", extraArg]
for tu in tunits:
oldDriver = tu["command"].split(None)[0]
cmd = tu["command"].replace(oldDriver, u"")
runIWYU(tu["directory"], [cmd])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment