aboutsummaryrefslogtreecommitdiffstats
path: root/extras/scripts/compdb_cleanup.py
blob: 0139b6bb6c51a793fc626d110f2a5e1bbfadbd40 (plain) @media only all and (prefers-color-scheme: dark) { .highlight .hll { background-color: #49483e } .highlight .c { color: #75715e } /* Comment */ .highlight .err { color: #960050; background-color: #1e0010 } /* Error */ .highlight .k { color: #66d9ef } /* Keyword */ .highlight .l { color: #ae81ff } /* Literal */ .highlight .n { color: #f8f8f2 } /* Name */ .highlight .o { color: #f92672 } /* Operator */ .highlight .p { color: #f8f8f2 } /* Punctuation */ .highlight .ch { color: #75715e } /* Comment.Hashbang */ .highlight .cm { color: #75715e } /* Comment.Multiline */ .highlight .cp { color: #75715e } /* Comment.Preproc */ .highlight .cpf { color: #75715e } /* Comment.PreprocFile */ .highlight .c1 { color: #75715e } /* Comment.Single */ .highlight .cs { color: #75715e } /* Comment.Special */ .highlight .gd { color: #f92672 } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highligh
#!/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)