-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathgen_html_std.sh
executable file
·112 lines (85 loc) · 2.44 KB
/
gen_html_std.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
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
108
109
110
111
#! /bin/sh -e
# check if we need to rebuild
cd cxxdraft-htmlgen
echo "htmlgen $(git rev-parse HEAD)" > ../thisbuild.tmp
cd ../draft
echo "draft $(git rev-parse origin/main)" >> ../thisbuild.tmp
cd ..
if [ -f all.patch ]
then
sha1sum all.patch >> thisbuild.tmp
fi
if [ -f htmlgen.patch ]
then
sha1sum htmlgen.patch >> thisbuild.tmp
fi
if [ -f htmlgen_code.patch ]
then
sha1sum htmlgen_code.patch >> thisbuild.tmp
fi
if [ -f lastbuild.sig ]
then
cmp --silent lastbuild.sig thisbuild.tmp && rm thisbuild.tmp && exit 0
fi
# Build the standard
cd draft/source
git reset --hard origin/main
if [ -f ../../all.patch ]
then
git apply ../../all.patch
fi
latexmk -pdf std
cp std.pdf std_orig.pdf
# create the "annex-f" file that maps stable names to section numbers
# Memoir 3.8 changed the content of the .aux files so as to require a different incantation
if grep -q TitleReference *.aux
then
# Memoir < 3.8
grep -h '^\\newlabel{' *.aux \
| sed 's/\\newlabel{\([^}]*\)}.*TitleReference {\([^}]*\)}.*/\1 \2/' \
| sed 's/\\newlabel{\([^}]*\)}{{\(Clause\|Annex\) \([^}]*\)}.*/\1 \3/' \
| sed 's/\\newlabel{\(eq:[^}]*\)}{{\([^}]*\)}.*/\1 \2/' \
| grep -v '^\\' \
| sort > annex-f
else
grep -h '^\\newlabel{' *.aux \
| sed 's/^\\newlabel{\([^}]*\)}{{\([^}]*\)}.*/\1 \2/' \
| grep -v '^\\' \
| sed 's/\(Clause\|Annex\) //' \
| sort > annex-f
fi
if [ -f ../../htmlgen.patch ]
then
git apply -3 ../../htmlgen.patch
fi
# Build the HTML
cd ../../cxxdraft-htmlgen
git reset --hard origin/master
if [ -f ../htmlgen_code.patch ]
then
git apply ../htmlgen_code.patch
fi
# For WSL, need to bump the limit of open files
mylimit=9000
sudo prlimit --nofile=$mylimit --pid $$; ulimit -n $mylimit
rm -rf 14882
cabal v2-update
cabal v2-build
cabal v2-run cxxdraft-htmlgen ../draft Bare
rm -f ../gh-pages/*.html ../gh-pages/draft.pdf ../gh-pages/annex-f
find 14882/ -maxdepth 1 -type f -execdir cp '{}' ../../gh-pages/'{}'.html \;
rm -r 14882
# Fixup gh-pages
cd ../gh-pages
rm -f *.css *.png
rename 's/.html//' *.css.html *.png.html
mv index.html.html index.html
cp ../draft/source/std_orig.pdf ./draft.pdf
cp ../draft/source/annex-f ./
cd ..
if [ -f gh-pages/full.html ]
then
mv thisbuild.tmp lastbuild.sig
else
rm thisbuild.tmp
fi