Files
vpp/extras/scripts/compdb_cleanup.py
Damjan Marion f4ca4843dd build: add compile_commands.json cleanup script
Type: make
Change-Id: I8d6a5018bddf029e106df3cb8b8eded4fa28067d
Signed-off-by: Damjan Marion <damarion@cisco.com>
2020-10-24 09:14:11 +00:00

29 lines
629 B
Python
Executable File

#!/usr/bin/env python3
import sys
import json
objects = json.load(sys.stdin)
for i in range(len(objects) - 1, -1, -1):
obj = objects[i]
# Remove everything except .c files
if not obj["file"].endswith(".c"):
objects.remove(obj)
continue
# remove duplicates introduced my multiarch
if "CLIB_MARCH_VARIANT" in obj["command"]:
objects.remove(obj)
continue
# remove ccache prefix
s = str.split(obj["command"])
if s[0] == "ccache":
s.remove(s[0])
s[0] = s[0].split("/")[-1]
obj["command"] = " ".join(s)
json.dump(objects, sys.stdout, indent=2)