Skip to content

Instantly share code, notes, and snippets.

@karkhaz

karkhaz/clangify.py

Created Dec 13, 2016
Embed
What would you like to do?
#!/usr/bin/env python
import argparse
import json
import os.path
import re
parser = argparse.ArgumentParser()
parser.add_argument("--clang-path", required=True)
args = parser.parse_args()
clang_path = os.path.abspath(args.clang_path)
with open("compile_commands.json") as f:
data = json.load(f)
for entry in data:
entry["command"] = re.sub("^cc", clang_path, entry["command"])
print(json.dumps(data, f, indent=2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment