-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathbuild.xml
More file actions
194 lines (168 loc) · 9.47 KB
/
build.xml
File metadata and controls
194 lines (168 loc) · 9.47 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
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
<project default="help">
<property file="build.properties"/>
<property name="tstamp.pattern" value="yyyyMMddHHmmss"/>
<tstamp>
<format property="tstamp" pattern="${tstamp.pattern}"/>
</tstamp>
<property name="game.id" value="${game.name}"/>
<property name="game.package" value="${game.package}"/>
<property name="game.version" value="${tstamp}"/>
<property name="game.dir" value="${game.name}"/>
<property name="game.src" value="src"/>
<property name="game.app" value="${game.name}.app"/>
<property name="game.love" value="${game.name}.love"/>
<property name="game.exe" value="${game.name}.exe"/>
<property name="game.title" value="${game.name}-${game.version}"/>
<property name="dist.dir" value="dist"/>
<property name="dist.files" value=""/>
<property name="dist.love" value="${game.title}.love"/>
<property name="dist.zip" value="${game.title}.zip"/>
<property name="game.apk" value="${game.title}.apk"/>
<property name="love.url" value="https://bitbucket.org/rude/love/downloads"/>
<property name="love.name" value="love"/>
<property name="love.version" value="0.9.2"/>
<property name="love.app" value="${love.name}.app"/>
<property name="love.exe" value="${love.name}.exe"/>
<property name="love-android.git" value="https://github.com/Sorroko/love-android-sdl2.git"/>
<property name="love-android.name" value="love-android-sdl2"/>
<property name="love-android.package-path" value="${game.package-path}"/>
<property name="love-android.activity" value="${game.activity}"/>
<property name="love-android.gen-apk" value="love_android_sdl2-debug.apk"/>
<macrodef name = "git">
<attribute name = "command" />
<attribute name = "dir" default = "" />
<element name = "args" optional = "true" />
<sequential>
<echo message = "git @{command}" />
<exec executable = "git" dir = "@{dir}">
<arg value = "@{command}" />
<args/>
</exec>
</sequential>
</macrodef>
<macrodef name = "git-clone-pull">
<attribute name = "repository" />
<attribute name = "dest" />
<sequential>
<git command = "clone">
<args>
<arg value = "@{repository}" />
<arg value = "@{dest}" />
</args>
</git>
<git command = "pull" dir = "@{dest}" />
</sequential>
</macrodef>
<target name="help" description="Prints all targets and their description.">
<java classname="org.apache.tools.ant.Main">
<arg value="-projecthelp"/>
<arg value="-buildfile" />
<arg value="${ant.file}" />
</java>
</target>
<target name="all" depends="love, dist, dist-win-32, dist-win-64, dist-osx, dist-android" description="Creates everything."/>
<target name="init" description="Initializes build.">
<!-- <antcall target="clean"/> -->
<mkdir dir="${dist.dir}"/>
<mkdir dir="${dist.dir}/cache"/>
</target>
<target name="love" depends="init" description="Creates LOVE file.">
<zip destfile="${dist.dir}/${dist.love}">
<zipfileset dir="${game.src}" includes="**/*" />
</zip>
</target>
<target name="dist" depends="init, love" description="Creates generic distribution zip.">
<zip destfile="${dist.dir}/${dist.zip}">
<zipfileset dir="${dist.dir}" includes="${dist.love}"/>
<!-- <zipfileset dir="." includes="${dist.files}" prefix="${game.dir}"/> -->
</zip>
</target>
<target name="dist-win-32" description="Creates distribution zip for Windows (32-bit).">
<antcall target="dist-win">
<param name="suffix" value="win32"/>
</antcall>
</target>
<target name="dist-win-64" description="Creates distribution zip for Windows (64-bit).">
<antcall target="dist-win">
<param name="suffix" value="win64"/>
</antcall>
</target>
<target name="dist-win" depends="init, love" if="suffix">
<property name="love.title" value="${love.name}-${love.version}-${suffix}"/>
<property name="love.dir" value="${love.title}"/>
<property name="love.zip" value="${love.title}.zip"/>
<property name="dist.win.zip" value="${game.title}-${suffix}.zip"/>
<get src="${love.url}/${love.zip}" dest="${dist.dir}/cache/${love.zip}" skipexisting="true"/>
<unzip src="${dist.dir}/cache/${love.zip}" dest="${dist.dir}/cache/"/>
<concat destfile="${dist.dir}/${game.exe}" binary="true">
<fileset file="${dist.dir}/cache/${love.dir}/${love.exe}"/>
<fileset file="${dist.dir}/${dist.love}"/>
</concat>
<zip destfile="${dist.dir}/${dist.win.zip}">
<zipfileset dir="${dist.dir}" includes="${game.exe}" prefix="${game.dir}"/>
<zipfileset dir="${dist.dir}/cache/${love.dir}" includes="*.dll" prefix="${game.dir}"/>
<!-- <zipfileset dir="." includes="${dist.files}" prefix="${game.dir}"/> -->
</zip>
<delete dir="${dist.dir}/cache/${love.dir}"/>
<delete file="${dist.dir}/${game.exe}"/>
</target>
<target name="dist-osx" depends="init, love" description="Creates distribution zip for OS X.">
<property name="love.zip" value="${love.name}-${love.version}-macosx-x64.zip"/>
<property name="dist.osx.zip" value="${game.title}-osx.zip"/>
<get src="${love.url}/${love.zip}" dest="${dist.dir}/cache/${love.zip}" skipexisting="true"/>
<unzip src="${dist.dir}/cache/${love.zip}" dest="${dist.dir}/cache/"/>
<move todir="${dist.dir}/${game.app}">
<fileset dir="${dist.dir}/cache/${love.app}"/>
</move>
<copy file="${dist.dir}/${dist.love}" tofile="${dist.dir}/${game.app}/Contents/Resources/${game.love}"/>
<replace file="${dist.dir}/${game.app}/Contents/Info.plist" token="<string>org.love2d.love</string>" value="<string>${game.package}</string>"/>
<replace file="${dist.dir}/${game.app}/Contents/Info.plist" token="<string>LÖVE</string>" value="<string>${game.name}</string>"/>
<replaceregexp file="${dist.dir}/${game.app}/Contents/Info.plist" match="<key>UTExportedTypeDeclarations</key>.*</array>.*</array>.*</array>" replace="" flags="s"/>
<zip destfile="${dist.dir}/${dist.osx.zip}">
<zipfileset dir="${dist.dir}/${game.app}" prefix="${game.name}/${game.app}"/>
<!-- <zipfileset dir="." includes="${dist.files}" prefix="${game.name}"/> -->
</zip>
<delete dir="${dist.dir}/${game.app}"/>
</target>
<target name="dist-android" depends="init, love" description="Creates distribution apk for Android.">
<!-- <mkdir dir="${dist.dir}/cache/${love-android.name}"/> -->
<git-clone-pull repository="${love-android.git}" dest="${dist.dir}/cache/${love-android.name}" />
<exec executable="ndk-build" dir="${dist.dir}/cache/${love-android.name}"/>
<mkdir dir="${dist.dir}/cache/${love-android.name}/assets"/>
<copy file="${dist.dir}/${dist.love}" tofile="${dist.dir}/cache/${love-android.name}/assets/game.love"/>
<copy file="assets/ic_launcher-hdpi.png" tofile="${dist.dir}/cache/${love-android.name}/res/drawable-hdpi/ic_launcher.png" overwrite="true" />
<copy file="assets/ic_launcher-mdpi.png" tofile="${dist.dir}/cache/${love-android.name}/res/drawable-mdpi/ic_launcher.png" overwrite="true" />
<copy file="assets/ic_launcher-xhdpi.png" tofile="${dist.dir}/cache/${love-android.name}/res/drawable-xhdpi/ic_launcher.png" overwrite="true" />
<copy file="assets/ic_launcher-xxhdpi.png" tofile="${dist.dir}/cache/${love-android.name}/res/drawable-xxhdpi/ic_launcher.png" overwrite="true" />
<copy file="assets/AndroidManifest.xml" tofile="${dist.dir}/cache/${love-android.name}/AndroidManifest.xml" overwrite="true" />
<!-- <replace file="${dist.dir}/cache/${love-android.name}/AndroidManifest.xml" token="package="org.love2d.android"" value="package="${game.package}""/>
<replace file="${dist.dir}/cache/${love-android.name}/AndroidManifest.xml" token="android:name="GameActivity"" value="android:name="${love-android.activity}""/>
<replaceregexp file="${dist.dir}/cache/${love-android.name}/AndroidManifest.xml" match="android:versionName="(.*?)"" replace="android:versionName="${game.version}"" flags="s"/>
<replaceregexp file="${dist.dir}/cache/${love-android.name}/AndroidManifest.xml" match="android:label="(.*?)"" replace="android:label="${game.name}"" flags="sg"/> -->
<mkdir dir="${dist.dir}/cache/${love-android.name}/src/${love-android.package-path}"/>
<echo file="${dist.dir}/cache/${love-android.name}/src/${love-android.package-path}/${love-android.activity}.java">
package ${game.package};
import org.love2d.android.GameActivity;
public class ${love-android.activity} extends GameActivity {}
</echo>
<ant dir="${dist.dir}/cache/${love-android.name}" target="debug" />
<move tofile="${dist.dir}/${game.apk}" file="${dist.dir}/cache/${love-android.name}/bin/${love-android.gen-apk}" />
</target>
<target name="run" description="Runs game.">
<property name="args" value=""/>
<exec executable="love" osfamily="windows">
<arg line="${game.src} ${args}"/>
</exec>
<exec executable="love" osfamily="unix">
<arg line="${game.src} ${args}"/>
</exec>
</target>
<target name="debug" description="Runs game with additional parameters.">
<antcall target="run">
<param name="args" value="${debug.args}"/>
</antcall>
</target>
<target name="clean" description="Deletes all generated files.">
<delete dir="${dist.dir}"/>
</target>
</project>