-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathautoexplicit.sh
More file actions
executable file
·86 lines (76 loc) · 2.4 KB
/
autoexplicit.sh
File metadata and controls
executable file
·86 lines (76 loc) · 2.4 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
#!/bin/bash
while getopts ":C:h" opt; do
case $opt in
C)
CDIR="$OPTARG"
if ! cd "$CDIR" 2>/dev/null
then
(>&2 echo "Failed to change directory to $OPTARG")
exit 1
fi
;;
h)
echo "
Usage:
autoexplicit.sh [-C dir] \"
Undefined symbols for architecture x86_64:
\\\"...\\\" \"
Or
make -C [your_project] 2>&1 | autoexplicit.sh -C \$LIBIGL"
exit 1
;;
\?)
echo "Invalid option: -$OPTARG" >&2
;;
esac
done
# Shift so that $# makes sense
shift $((OPTIND-1))
# process input line by line
while read line; do
if ! echo "$line" | grep -q "^\".*\", referenced from:$"
then
# undefined symbol line not found
continue
fi
symbol=`echo "$line" | sed -e "s/^\"\(.*\)\", referenced from:$/\1/"`
#echo "symbol = $symbol"
filename=`echo "$symbol" | perl -pe "s#.*?igl::([A-z0-9_:]*).*$'$'#\1#"`
filename=`echo "$filename" | sed -e "s/::/\//g"`
#echo "filename = $filename"
cpp="./include/igl/$filename.cpp"
# append .cpp and check that file exists
if [ ! -e "$cpp" ]
then
echo "Warning: $cpp does not exist, skipping ..."
continue
fi
if ! grep -q "^\/\/ Explicit template instantiation*$" "$cpp"
then
echo "Warning: skipping $cpp because it does not match ^\/\/ Explicit template instantiation*$ "
continue;
fi
before=`sed '/^\/\/ Explicit template instantiation$/q' "$cpp"`;
#echo "before = $before"
after=`sed '1,/^\/\/ Explicit template instantiation$/d' $cpp`;
#echo "after = $after"
explicit=`echo "template $symbol;" | \
sed -e "s/std::__1::/std::/g" | \
sed -e "s/__sFILE/FILE/g" | \
sed -e "s/std::mersenne_twister_engine<[^>]*long,[^>]*>/std::mt19937_64/g" | \
sed -e "s/std::mersenne_twister_engine<[^>]*int,[^>]*>/std::mt19937/g" | \
sed -e "s/std::linear_congruential_engine<[^>]*16807[^>]*>/std::minstd_rand0/g" | \
sed -e "s/std::linear_congruential_engine<[^>]*48271[^>]*>/std::minstd_rand/g" | \
sed -e "s/CGAL::Lazy_exact_nt<__gmp_expr<__mpq_struct \\[1\\], __mpq_struct \\[1\\]> >/CGAL::Epeck::FT/g"`
#echo "$explicit"
if grep -F "$explicit" "$cpp"
then
echo "Error: $cpp already contains $explicit"
echo " Recompile igl static lib, recompile your project, and try again."
continue
fi
echo "$before" > "$cpp"
echo "// generated by autoexplicit.sh" >> "$cpp"
echo "$explicit" >> "$cpp"
echo "$after" >> "$cpp"
done