-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgame-launcher.build
212 lines (159 loc) · 7.97 KB
/
game-launcher.build
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
<?xml version="1.0"?>
<project name="Game-Launcher" default="build" basedir=".">
<description>
This is the build script for the Game Launcher project.
Game Launcher depends on node-webkit as its runtime framework and
Reveal.js as its UI framework. The build target will download these
two frameworks and extract and set them up in the bin directory along
with the source code for game launcher (from the src directory).
</description>
<!-- ******** Properties ************************************************************* -->
<!-- The platform to build for; currently only win32 is supported. -->
<property name="platform" value="win32" overwrite="false" />
<!-- The operating system that the build script is executing on. -->
<property name="operatingSystem" value="${operating-system::to-string(environment::get-operating-system())}" overwrite="true" />
<property name="buildingOnWindows" value="${string::contains(operatingSystem, 'Windows')}"/>
<!-- The version number of this source package. -->
<property name="version" value="1.0.0" overwrite="true" />
<!-- ******** Properties - Application Dependencies ********************************** -->
<!-- URL to the node-webit runtime binary package. -->
<property name="node-webkit-url-win32" overwrite="true"
value="https://s3.amazonaws.com/node-webkit/v0.7.3/node-webkit-v0.7.3-win-ia32.zip" />
<!-- URL to the reveal.js framework. -->
<property name="reveal-js-url" overwrite="true"
value="https://github.com/hakimel/reveal.js/archive/2.5.0.zip" />
<!-- URL to the jQuery framework. -->
<property name="jquery-url" overwrite="true"
value="http://code.jquery.com/jquery-2.0.3.min.js" />
<!-- ******** Properties - Bulid Process Dependencies ******************************** -->
<!-- URL to Inno Setup Extractor tool. -->
<property name="inno-extract-url" overwrite="true"
value="http://constexpr.org/innoextract/files/innoextract-1.4-windows-r1.zip" />
<!-- URL to the Resource Hacker tool. -->
<property name="resource-hacker-url" overwrite="true"
value="http://www.angusj.com/resourcehacker/reshack_setup.exe" />
<!-- ******** Target: clean ********************************************************** -->
<target name="clean" description="Removes the generated bin and tmp directories."
depends="cleanTemp,cleanBin,cleanDist">
</target>
<!-- ******** Target: cleanDist ****************************************************** -->
<target name="cleanDist" description="Removes the generated dist directory.">
<delete dir="dist" if="${directory::exists('dist')}"/>
</target>
<!-- ******** Target: cleanBin ******************************************************* -->
<target name="cleanBin" description="Removes the generated bin directory.">
<delete dir="bin" if="${directory::exists('bin')}"/>
</target>
<!-- ******** Target: cleanTemp ****************************************************** -->
<target name="cleanTemp" description="Removes the generated tmp directory.">
<delete dir="tmp" if="${directory::exists('tmp')}"/>
</target>
<!-- ******** Target: build ********************************************************** -->
<target name="build" description="Downloads and sets up project depenencies and copies source code to the bin directory.">
<!-- Create the temp directory for holding external dependency source/packages etc. -->
<mkdir dir="tmp"/>
<!-- If we don't have node-webkit yet, go fetch it. -->
<if test="${not file::exists('tmp/node-webkit-src.zip')}">
<get src="${node-webkit-url-win32}" dest="tmp/node-webkit-src.zip"/>
</if>
<!-- If we don't have reveal.js yet, go fetch it. -->
<if test="${not file::exists('tmp/reveal-js-src.zip')}">
<get src="${reveal-js-url}" dest="tmp/reveal-js-src.zip"/>
</if>
<!-- If we don't have jquery yet, go fetch it. -->
<if test="${not file::exists('tmp/jquery.min.js')}">
<get src="${jquery-url}" dest="tmp/jquery.min.js"/>
</if>
<!-- We only need these tools if we are building for the Windows platform. -->
<if test="${platform=='win32'}">
<!-- If we don't have Inno Setup Extract yet, go fetch it. -->
<if test="${not file::exists('tmp/inno-extract.zip')}">
<get src="${inno-extract-url}" dest="tmp/inno-extract.zip"/>
</if>
<!-- If we don't have Resource Hacker yet, go fetch it. -->
<if test="${not file::exists('tmp/resource-hacker.exe')}">
<get src="${resource-hacker-url}" dest="tmp/resource-hacker.exe"/>
</if>
</if>
<!-- If the bin directory doesn't exist yet, then create it and setup the external dependencies. -->
<if test="${not directory::exists('bin')}">
<!-- Create the directory structure. -->
<mkdir dir="bin"/>
<mkdir dir="bin/game-images"/>
<mkdir dir="bin/resources"/>
<mkdir dir="bin/resources/js"/>
<mkdir dir="bin/resources/css"/>
<mkdir dir="bin/resources/img"/>
<mkdir dir="bin/resources/font"/>
<!-- Setup node-webkit. -->
<unzip zipfile="tmp/node-webkit-src.zip" todir="bin"/>
<delete file="bin/credits.html" failonerror="false"/>
<delete file="bin/nwsnapshot.exe" failonerror="false"/>
<delete file="bin/ffmpegsumo.dll" failonerror="false"/>
<move file="bin/nw.exe" tofile="bin/game-launcher.exe"/>
<!-- Setup reveal.js. -->
<unzip zipfile="tmp/reveal-js-src.zip" todir="tmp/reveal-js-src"/>
<copy todir="bin/resources">
<fileset basedir="tmp/reveal-js-src/reveal.js-2.5.0">
<include name="js/**/*"/>
<include name="css/*.css"/>
<include name="css/theme/*.css"/>
</fileset>
</copy>
<!-- Setup jQuery. -->
<copy file="tmp/jquery.min.js" todir="bin/resources/js"/>
<!-- Copy the sample game images. -->
<copy todir="bin/game-images">
<fileset basedir="samples/game-images">
<include name="*"/>
</fileset>
</copy>
<!--
Modify the executable's icon; currently only supported when building for the Windows
platform AND we are building ON a Windows OS (since the tools are Windows-only).
-->
<if test="${platform=='win32'}">
<if test="${buildingOnWindows}">
<!-- Ensure that the resource hacker tool is extracted. -->
<if test="${not file::exists('tmp/resource-hacker/reshacker.exe')}">
<mkdir dir="tmp/resource-hacker"/>
<!-- First, unzip the Inno Extract tool. -->
<unzip zipfile="tmp/inno-extract.zip" todir="tmp/inno-extract" failonerror="false"
unless="${file::exists('tmp/inno-extract/innoextract-1.4-windows-r1/innoextract.exe')}"/>
<!-- Next, use the Inno Extract tool to extract the contents of the Resource Hacker installer bundle. -->
<exec program="tmp/inno-extract/innoextract-1.4-windows-r1/innoextract.exe" workingdir="tmp/" failonerror="false">
<arg line="--silent --extract --output-dir resource-hacker resource-hacker.exe"/>
</exec>
</if>
<!-- Use the resource hacker tool to inject the custom icon into the executable. -->
<exec program="tmp/resource-hacker/app/ResHacker.exe" workingdir="." failonerror="false">
<arg line="-modify "bin/game-launcher.exe", "bin/game-launcher.exe", "src/img/icon.ico", ICONGROUP, IDR_MAINFRAME, 0"/>
</exec>
</if>
</if>
</if>
<!-- Copy in the Game Launcher source files. -->
<copy todir="bin/resources">
<fileset basedir="src/">
<include name="**/*"/>
</fileset>
</copy>
<!-- Copy the package definition for node-webkit. -->
<copy file="cfg/package.json" todir="bin" />
<!-- Copy the configuration file only if it doesn't exist yet. -->
<copy file="cfg/configuration.js" todir="bin"
unless="${file::exists('bin/configuration.js')}"/>
</target>
<!-- ******** Target: package ******************************************************** -->
<target name="package" depends="build" description="Builds the application and then packges it up into ZIP files in dist/">
<if test="${directory::exists('dist')}">
<delete dir="dist"/>
</if>
<mkdir dir="dist"/>
<zip zipfile="dist/Game-Launcher-${version}-win32.zip">
<fileset basedir="bin/">
<include name="**/*"/>
</fileset>
</zip>
</target>
</project>