From 88b2e3682be6303973fc59c3c62141d64a9e10d7 Mon Sep 17 00:00:00 2001 From: Damjan Marion Date: Thu, 29 Apr 2021 18:47:25 +0200 Subject: misc: experimental configure script Type: make Change-Id: Iaeb9d22eec9a7a763b63899814a44e78c8050f1f Signed-off-by: Damjan Marion --- src/scripts/compdb_cleanup.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 src/scripts/compdb_cleanup.py (limited to 'src/scripts') diff --git a/src/scripts/compdb_cleanup.py b/src/scripts/compdb_cleanup.py new file mode 100755 index 00000000000..0302fc2f87c --- /dev/null +++ b/src/scripts/compdb_cleanup.py @@ -0,0 +1,33 @@ +#!/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 if there is no command + if 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) -- cgit 1.2.3-korg