aboutsummaryrefslogtreecommitdiffstats
path: root/extras/scripts
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2020-10-23 17:20:32 +0200
committerDamjan Marion <dmarion@me.com>2020-10-24 09:14:11 +0000
commitf4ca4843dd7b611f2915caedc0abd7988ec1e8cd (patch)
treefda079a0cf50e5fb1ed2bb4c404a1a5b9baad06e /extras/scripts
parentac948ce17fb3207d7f45578ec016089cb6860340 (diff)
build: add compile_commands.json cleanup script
Type: make Change-Id: I8d6a5018bddf029e106df3cb8b8eded4fa28067d Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'extras/scripts')
-rwxr-xr-xextras/scripts/compdb_cleanup.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/extras/scripts/compdb_cleanup.py b/extras/scripts/compdb_cleanup.py
new file mode 100755
index 00000000000..0139b6bb6c5
--- /dev/null
+++ b/extras/scripts/compdb_cleanup.py
@@ -0,0 +1,28 @@
+#!/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)