chiark / gitweb /
Forbid undo of new-game if it would change the params.
[sgt-puzzles.git] / Buildscr
1 # -*- sh -*-
2 # Build script to build Puzzles.
3
4 module puzzles
5
6 set Version $(!builddate).$(vcsid)
7
8 # Start by substituting the right version number in configure.ac.
9 in puzzles do perl -i~ -pe 's/6.66/$(Version)/' configure.ac
10 in puzzles do rm configure.ac~
11
12 # And put it into the documentation as a versionid.
13 # use perl to avoid inconsistent behaviour of echo '\v'
14 in puzzles do perl -e 'print "\n\\versionid Simon Tatham'\''s Portable Puzzle Collection, version $$ARGV[0]\n"' $(Version) >> puzzles.but
15 in puzzles do perl -e 'print "\n\\versionid Simon Tatham'\''s Portable Puzzle Collection, version $$ARGV[0]\n"' $(Version) >> devel.but
16
17 # Write out a version.h that contains the real version number.
18 in puzzles do echo '/* Generated by automated build script */' > version.h
19 in puzzles do echo '$#define VER "Version $(Version)"' >> version.h
20
21 # And do the same substitution in the OS X metadata. (This is a bit
22 # icky in principle because it presumes that my version numbers don't
23 # need XML escaping, but frankly, if they ever do then I should fix
24 # them!)
25 in puzzles do perl -i -pe 's/Unidentified build/$(Version)/' osx-info.plist
26
27 # First build some local binaries, to run the icon build.
28 in puzzles do perl mkfiles.pl -U
29 in puzzles do make
30
31 # Now build the screenshots and icons.
32 in puzzles/icons do xvfb-run -s "-screen 0 1024x768x24" make web winicons gtkicons
33
34 # Destroy the local binaries and autoconf detritus, mostly to avoid
35 # wasting network bandwidth by transferring them to the delegate
36 # servers.
37 in puzzles do make distclean
38
39 # Re-run mkfiles.pl now that it knows the icons are there.
40 in puzzles do perl mkfiles.pl
41
42 # Rebuild the configure script.
43 in puzzles do ./mkauto.sh
44
45 # Build the OS X .dmg archive.
46 delegate osx
47   in puzzles do make -f Makefile.osx clean
48   in puzzles do make -f Makefile.osx release VER=-DVER=$(Version)
49   return puzzles/Puzzles.dmg
50 enddelegate
51
52 # Build the Windows binaries and installer, and the CHM file.
53 in puzzles do make -f Makefile.doc clean
54 in puzzles do make -f Makefile.doc # build help files for installer
55 in puzzles do mason.pl --args '{"version":"$(Version)","descfile":"gamedesc.txt"}' winwix.mc > puzzles.wxs
56 in puzzles do perl winiss.pl $(Version) gamedesc.txt > puzzles.iss
57 ifneq "$(VISUAL_STUDIO)" "yes" then
58   in puzzles with clangcl64 do Platform=x64 make -f Makefile.clangcl clean
59   in puzzles with clangcl64 do Platform=x64 make -f Makefile.clangcl VER=-DVER=$(Version)
60   # Code-sign the binaries, if the local bob config provides a script
61   # to do so. We assume here that the script accepts an -i option to
62   # provide a 'more info' URL, and an optional -n option to provide a
63   # program name, and that it can take multiple .exe filename
64   # arguments and sign them all in place.
65   ifneq "$(cross_winsigncode)" "" in puzzles do $(cross_winsigncode) -i https://www.chiark.greenend.org.uk/~sgtatham/puzzles/ *.exe
66   # Build installers.
67   in puzzles with wixonlinux do candle -arch x64 puzzles.wxs && light -ext WixUIExtension -sval puzzles.wixobj
68   ifneq "$(cross_winsigncode)" "" in puzzles do $(cross_winsigncode) -i https://www.chiark.greenend.org.uk/~sgtatham/puzzles/ -n "Simon Tatham's Portable Puzzle Collection Installer" puzzles.msi
69 else
70   delegate windows
71     in puzzles with visualstudio do/win nmake -f Makefile.vc clean
72     in puzzles with visualstudio do/win nmake -f Makefile.vc VER=-DVER=$(Version)
73     ifneq "$(winsigncode)" "" in puzzles do $(winsigncode) -i https://www.chiark.greenend.org.uk/~sgtatham/puzzles/ *.exe
74     # Build installers.
75     in puzzles with wix do/win candle puzzles.wxs && light -ext WixUIExtension -sval puzzles.wixobj
76     in puzzles with innosetup do/win iscc puzzles.iss
77     return puzzles/*.exe
78     return puzzles/puzzles.msi
79   enddelegate
80 endif
81 in puzzles do chmod +x *.exe
82
83 # Build the Pocket PC binaries and CAB.
84 #
85 # NOTE: This part of the build script requires the Windows delegate
86 # server to have the cabwiz program on its PATH. This will
87 # typically be at
88 #
89 #   C:\Program Files\Windows CE Tools\WCE420\POCKET PC 2003\Tools
90 #
91 # but it might not be if you've installed it somewhere else, or
92 # have a different version.
93 #
94 # NOTE ALSO: This part of the build is commented out, for the
95 # moment, because cabwiz does unhelpful things when run from within
96 # a bob delegate process (or, more generally, when run from any
97 # terminal-based remote login to a Windows machine, including
98 # Cygwin opensshd and Windows Telnet). The symptom is that cabwiz
99 # just beeps and sits there. Until I figure out how to build the
100 # .cab from an automated process (and I'm willing to consider silly
101 # approaches such as a third-party CAB generator), I don't think I
102 # can sensibly enable this build.
103
104 #in puzzles do perl wceinf.pl gamedesc.txt > puzzles.inf
105 #delegate windows
106 #  in puzzles do cmd /c 'wcearmv4 & nmake -f Makefile.wce clean'
107 #  in puzzles do cmd /c 'wcearmv4 & nmake -f Makefile.wce VER=-DVER=$(Version)'
108 #  # Nasty piece of sh here which saves the return code from cabwiz,
109 #  # outputs its errors and/or warnings, and then propagates the
110 #  # return code back to bob. If only cabwiz could output to
111 #  # standard error LIKE EVERY OTHER COMMAND-LINE UTILITY IN THE
112 #  # WORLD, I wouldn't have to do this.
113 #  in puzzles do cat puzzles.inf
114 #  in puzzles do cmd /c 'wcearmv4 & bash -c cabwiz puzzles.inf /err cabwiz.err /cpu ARMV4'; a=$$?; cat cabwiz.err; exit $$a
115 #  return puzzles/puzzles.armv4.cab
116 #enddelegate
117
118 # Build the HTML docs.
119 in puzzles do mkdir doc
120 in puzzles do mkdir devel
121 in puzzles/doc do halibut --html -Chtml-contents-filename:index.html -Chtml-index-filename:indexpage.html -Chtml-template-filename:%k.html -Chtml-template-fragment:%k ../puzzles.but
122 in puzzles/devel do halibut --html -Chtml-contents-filename:index.html -Chtml-index-filename:indexpage.html -Chtml-template-filename:%k.html -Chtml-template-fragment:%k ../devel.but
123
124 # Move the deliver-worthy Windows binaries (those specified in
125 # gamedesc.txt, which is generated by mkfiles.pl and helpfully
126 # excludes the command-line auxiliary utilities such as solosolver,
127 # and nullgame.exe) into a subdirectory for easy access.
128 in puzzles do mkdir winbin
129 in puzzles do mv `cut -f2 -d: gamedesc.txt` winbin
130
131 # Make a zip file of the Windows binaries and help files.
132 in puzzles do zip -j puzzles.zip winbin/*.exe puzzles.chm puzzles.hlp puzzles.cnt
133
134 # Create the source archive. (That writes the archive into the
135 # _parent_ directory, so be careful when we deliver it.)
136 in puzzles do ./makedist.sh $(Version)
137
138 # Build the autogenerated pieces of the main web page.
139 in puzzles do perl webpage.pl
140
141 ifneq "$(JAVA_UNFINISHED)" "" in puzzles do perl -i~ -pe 'print "!srcdir unfinished/\n" if /!srcdir icons/' Recipe
142 ifneq "$(JAVA_UNFINISHED)" "" in puzzles do ln -s unfinished/group.R .
143 ifneq "$(JAVA_UNFINISHED)" "" in puzzles do perl mkfiles.pl
144
145 # Build the Java applets.
146 delegate nestedvm
147   in puzzles do make -f Makefile.nestedvm NESTEDVM="$$NESTEDVM" VER=-DVER=$(Version)
148   return puzzles/*.jar
149 enddelegate
150
151 # Build the Javascript applets. Since my master build machine doesn't
152 # have the right dependencies installed for Emscripten, I do this by a
153 # delegation.
154 in puzzles do mkdir js # so we can tell output .js files from emcc*.js
155 delegate emscripten
156   in puzzles do make -f Makefile.emcc OUTPREFIX=js/ clean
157   in puzzles do make -f Makefile.emcc OUTPREFIX=js/
158   return puzzles/js/*.js
159 enddelegate
160
161 # Build a set of wrapping HTML pages for easy testing of the
162 # Javascript puzzles. These aren't quite the same as the versions that
163 # will go on my live website, because those ones will substitute in a
164 # different footer, and not have to link to the .js files with the
165 # ../js/ prefix. But these ones should be good enough to just open
166 # using a file:// URL in a browser after running a build, and make
167 # sure the main functionality works.
168 in puzzles do mkdir jstest
169 in puzzles/jstest do ../html/jspage.pl --jspath=../js/ /dev/null ../html/*.html
170
171 # Set up .htaccess containing a redirect for the archive filename.
172 in puzzles do echo "AddType application/octet-stream .chm" > .htaccess
173 in puzzles do echo "AddType application/octet-stream .hlp" >> .htaccess
174 in puzzles do echo "AddType application/octet-stream .cnt" >> .htaccess
175 in . do set -- puzzles*.tar.gz; echo RedirectMatch temp '(.*/)'puzzles.tar.gz '$$1'"$$1" >> puzzles/.htaccess
176 in puzzles do echo RedirectMatch temp '(.*/)'puzzles-installer.msi '$$1'puzzles-$(Version)-installer.msi >> .htaccess
177
178 # Phew, we're done. Deliver everything!
179 deliver puzzles/icons/*-web.png $@
180 deliver puzzles/winbin/*.exe $@
181 deliver puzzles/.htaccess $@
182 deliver puzzles/doc/*.html doc/$@
183 deliver puzzles/devel/*.html devel/$@
184 deliver puzzles/Puzzles.dmg $@
185 deliver puzzles/puzzles.chm $@
186 deliver puzzles/puzzles.hlp $@
187 deliver puzzles/puzzles.cnt $@
188 deliver puzzles/puzzles.zip $@
189 deliver puzzles/puzzles.msi puzzles-$(Version)-installer.msi
190 deliver puzzles/*.jar java/$@
191 deliver puzzles/js/*.js js/$@
192 deliver puzzles/jstest/*.html jstest/$@
193 deliver puzzles/html/*.html html/$@
194 deliver puzzles/html/*.pl html/$@
195 deliver puzzles/wwwspans.html $@
196 deliver puzzles/wwwlinks.html $@
197
198 # deliver puzzles/puzzles.armv4.cab $@ # (not built at the moment)
199
200 # This one isn't in the puzzles subdir, because makedist.sh left it
201 # one level up.
202 deliver puzzles*.tar.gz $@