-
Notifications
You must be signed in to change notification settings - Fork 0
/
sipdiff
executable file
·67 lines (59 loc) · 1.31 KB
/
sipdiff
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env bash
DIR=$(git rev-parse --show-toplevel)
# ARGUMENTS
SIPIFY=NO
while getopts ":s" opt; do
case $opt in
s)
# sipify header
SIPIFY=YES
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
esac
done
shift $(expr $OPTIND - 1)
for file in $*; do
d=${file#*/}
d=${d%/*}
f=${file##*/}
f=${f%.*}
header="src/$d/$f.h"
if ! grep -Fxq "$d/$f.sip" python/auto_sip.blacklist; then
echo -e "\033[0;31m$d/$f.sip is an automatically generated SIP file\033[0m"
echo -e " g) \x1B[4mg\x1B[0menerate the SIP file \033[0;32m./scripts/sipify.pl $header > python/$d/$f.sip\033[0m"
echo -e " s) \x1B[4ms\x1B[0mhow the diff"
SHOW=NO
while read -n 1 n; do
echo ""
case $n in
g)
echo "Generating the SIP file ..."
pushd ${DIR}
./scripts/sipify.pl $header > python/$d/$f.sip
popd
break
;;
s)
SHOW=YES
break
;;
*)
invalid option
;;
esac
done
if [[ $SHOW =~ NO ]]; then
continue
fi
fi
if [[ $SIPIFY =~ YES ]]; then
tempfile=$(mktemp ${DIR}/${f}XXXX --suffix=.h)
${DIR}/scripts/sipify.pl ${DIR}/$header > $tempfile
else
tempfile=$header
fi
vimdiff $tempfile python/$d/$f.sip
done