forked from vancegroup/util-headers
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathutil_header_search_tool.sh
executable file
·28 lines (23 loc) · 1.01 KB
/
util_header_search_tool.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/sh
# Run with --update to parse headers and generate the guid.list.txt and guid.transforms.txt data files.
# Running with any other arguments will lead to those arguments being treated as input files passed to
# a pipeline starting with grep, that will output the name of any util-headers file found (and its original
# name in this repo)
set -e
DATADIR=$(cd $(dirname $0) && pwd)
HEADERDIR=$(cd $(dirname $0) && cd util && pwd)
defineLineToGUID() {
sed -n 's/[#]ifndef INCLUDED_.*_GUID_\(.*\)$/\1/p' $@
}
if [ "x$1" = "x--update" ]; then
echo "Updating GUID databases."
(
cd ${HEADERDIR}
# Generate file to use with sed
(find * -name "*.h" | xargs grep "#ifndef INCLUDED_" )| defineLineToGUID | sed 's/\([^:]*\):\(.*\)/s:\2:\1:/' > ${DATADIR}/guid.transforms.txt
# Generate input for grep
cut --delimiter=: --fields=2 ${DATADIR}/guid.transforms.txt > ${DATADIR}/guid.list.txt
)
exit 0
fi
grep -F -f ${DATADIR}/guid.list.txt $@ | defineLineToGUID | sed -f ${DATADIR}/guid.transforms.txt | sed 's/:/\t/'