Skip to content

Commit 5412c7d

Browse files
committed
make sure not to have duplicates in the transformed compile_commands.json
1 parent fa69f32 commit 5412c7d

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

utility/ThinCompilationsDatabase.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,15 @@ def reportProgress(keepalive, queue, q2):
132132
print "output queue has size " + str(q2.qsize())
133133
time.sleep(1)
134134

135+
#custom function to remove duplicates and return a new list
136+
#set() cannot be used since the entries are not hashable
137+
def removeDuplicates(inputlist):
138+
outputlist=[]
139+
for e in inputlist:
140+
if e not in outputlist:
141+
outputlist.append(e)
142+
return outputlist
143+
135144
#
136145
# THE MAIN FUNCTION
137146
#
@@ -226,7 +235,7 @@ def main():
226235
outputdict.append(outputqueue.get(False))
227236

228237
# write result dictionary to json
229-
outjson = json.dumps(outputdict, sort_keys=True, indent=4, separators=(',', ': '))
238+
outjson = json.dumps(removeDuplicates(outputdict), sort_keys=True, indent=4, separators=(',', ': '))
230239
with open(args.o,'w') as fp:
231240
fp.write(outjson)
232241

0 commit comments

Comments
 (0)