2 # This is a pretty brute-force approach. It takes several hours to run on a top-spec MacbookAir.
3 # It also produces some false positives, so it requires careful examination and testing of the results.
6 # First we find all #defines,
7 # then we search for each of them in turn,
8 # and if we find only one instance of a #define, we print it out.
11 # (1) find #defines, excluding the externals folder
12 # (2) extract just the constant name from the search results
13 # (3) trim blank lines
14 # (4) sort the results, mostly so I have an idea how far along the process is
15 # (5) for each result:
16 # (6) grep for the constant
17 # (7) use awk to check if only one match for a given constant was found
18 # (8) if so, generate a sed command to remove the #define
20 bin
/find-unused-typedefs.py \
22 |
xargs -Ixxx -n 1 -P 8 sh
-c \
23 '( git grep -w xxx | awk -f bin/find-unused-defines.awk -v p1=xxx ) && echo xxx 1>&2'