-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.sh
More file actions
107 lines (95 loc) · 2.01 KB
/
Copy pathutils.sh
File metadata and controls
107 lines (95 loc) · 2.01 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
fnd () {
grep -Irwn $1 src
}
fnd_all () {
grep -Irwn $1 src generated tests
}
run_gdb () {
gdb -q ./bin/fn core
}
cores_on () {
sudo bash -c "echo 'core.%e' > /proc/sys/kernel/core_pattern"
ulimit -c unlimited
}
cores_off () {
ulimit -c 0
}
echo_gpl () {
__YEAR=`date +%Y`
echo '/*'
cat docs/gpl.txt | sed -e 's/^/ * /' -e s/__YEAR__/$__YEAR/
echo ' */'
}
watch_make () {
inotifywait -q -e close_write -m ./src |
while read -r directory events filename; do
if [ -e ./src/$filename ] ; then
make
fi
done
}
error () {
echo 1>&2 "$*"
}
new_h () {
if [ -z "$1" ] ; then
error usage: new_h filename_without_extension
return 1
fi
file="src/$1.h"
if [ -e $file ] ; then
error $file already exists
return 1
else
define=`echo "cekf_${1}_h" | sed -e 's#/#_#g'`
echo "#ifndef $define" > $file
echo "# define $define" >> $file
echo_gpl >> $file
echo "" >> $file
echo "#endif" >> $file
fi
}
new_c () {
if [ -z "$1" ] ; then
error usage: new_c filename_without_extension
return 1
fi
file="src/$1.c"
if [ -e $file ] ; then
error $file already exists
return 1
else
echo_gpl > $file
echo "" >> $file
fi
}
new_ch () {
if [ -z "$1" ] ; then
error usage: new_ch filename_without_extension
return 1
fi
cfile="src/$1.c"
if [ -e $cfile ] ; then
error $cfile already exists
return 1
else
new_c $1
new_h $1
echo "#include \"$1.h\"" >> $cfile
echo "" >> $cfile
fi
}
new_visitor () {
if [ -z "$1" ] || [ -z "$2" ] ; then
error usage: new_visitor name suffix
return 1
fi
cfile="src/$1_$2.c"
if [ -e $cfile ] ; then
error $cfile already exists
return 1
fi
new_h "$1_$2" &&
python3 tools/generate.py --target "$2" src/$1.yaml visitor > $cfile
}
export PATH=./bin:$PATH