Created
December 19, 2016 19:10
-
-
Save kborkows/0838e72fae0b90a05dee6a797a1b121a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# What this script does is: | |
# split (on '-' char) and list-concat all "command" fields | |
# filter out non-includes (includes start with 'I') | |
# filter out non-component includes | |
# make paths relative to component and print them out | |
component = "mctrl" | |
import sys | |
import json | |
flatten = lambda l : [item for sublist in l for item in sublist] | |
if len(sys.argv) < 2: | |
print("Path to compile_commands.json not provided") | |
filename = sys.argv[1] | |
data = json.load(open(filename)) | |
args = flatten(obj["command"].split('-') for obj in data) | |
includes = filter(lambda x : x and x[0] == "I", args) | |
component_includes = filter(lambda inc : ('/' + component + '/') in inc and "build" not in inc, includes) | |
for include in sorted(set(component_includes)): | |
print(include[include.index(component) + len(component) + 1:]) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment