#!/usr/bin/python # -*- coding: utf-8 -*- # # $Revision$ # $Date$ # $Id$ # # Simple script to modify compile_commands.json # -> remove generated files (except ours) # import json import sys if len(sys.argv) != 2: print >> sys.stderr, "Usage: %s compile_commands.json" % sys.argv[0] sys.exit(1) try: f = open(sys.argv[1], "r") dataOut = [] for command in json.load(f): fn = command['file'] # ignore build dir if 'build/' in fn or '-build-' in fn: # whilelist some file if not '_impl' in fn and not fn.endswith('_plugin.cpp'): continue if '/moc_' in fn: continue command['command'] = command['command'].replace('''\\\"''', '''\"''') dataOut.append(command) f = open(sys.argv[1], "w") json.dump(dataOut, f) except Exception as e: print >> sys.stderr, "Error modifying file '%s': %s" % (sys.argv[1], e)