forked from coplate/KUAL_Booklet
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.xml
251 lines (219 loc) · 9.58 KB
/
build.xml
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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
<?xml version="1.0" encoding="UTF-8"?>
<project name="KUAL" default="dist">
<property file="build.properties"/>
<!-- local properties which are not committed to git. See build.properties for the keys which are expected to be found in there. -->
<property file="build-local.properties"/>
<path id="classpath.jdk14">
<fileset dir="${build.classpath.jdk14}" includes="**/*.jar"/>
</path>
<path id="classpath.lib">
<fileset dir="lib" includes="**/*.jar"/>
<fileset dir="${build.classpath.592}" includes="**/*.jar"/>
</path>
<target name="clean">
<delete dir="${build.dir}"/>
</target>
<target name="prepare">
<delete dir="${build.dir}"/>
<mkdir dir="${build.dir}"/>
<mkdir dir="dist"/>
</target>
<target name="compile" depends="prepare, strip-parser">
<javac source="1.4" target="1.4" includeantruntime="false" bootclasspathref="classpath.jdk14" classpathref="classpath.lib" srcdir="src" destdir="${build.dir}" debug="true" debuglevel="lines,vars,source">
<include name="com/mobileread/ixtab/**/*.java"/>
<exclude name="com/mobileread/ixtab/**/KualKindlet*.java"/>
<exclude name="com/mobileread/ixtab/**/LauncherKindletJailbreak.java"/>
<exclude name="com/mobileread/ixtab/**/ui/v1/Kual*.java"/>
</javac>
</target>
<target name="build" depends="compile">
<echo level="info">Launching build targets</echo>
<antcall target="restore-parser"/>
<!--
<antcall target="build-kdk">
<param name="kdk-version" value="1.0"/>
</antcall>
<antcall target="build-kdk">
<param name="kdk-version" value="2.0"/>
</antcall>
-->
<antcall target="build-booklet"/>
</target>
<target name="build-kdk" depends="compile, git.changelog">
<property name="file" value="${product.filename}-KDK-${kdk-version}.${product.extension}"/>
<delete file="${file}"/>
<jar destfile="${file}">
<manifest>
<attribute name="Implementation-Title" value="${product.name}"/>
<attribute name="Implementation-Version" value="${product.version}"/>
<attribute name="Implementation-Vendor" value="${product.vendor}"/>
<attribute name="Main-Class" value="${product.mainclass}"/>
<attribute name="Amazon-Cover-Image" value="${product.image}"/>
<attribute name="Extension-List" value="SDK"/>
<attribute name="SDK-Extension-Name" value="com.amazon.kindle.kindlet"/>
<attribute name="SDK-Specification-Version" value="${kdk-version}"/>
<attribute name="Toolbar-Mode" value="persistent"/>
<attribute name="Font-Size-Mode" value="point"/>
</manifest>
<!-- actual program logic files -->
<fileset dir="${build.dir}">
<include name="**/*.class"/>
<exclude name="**/KualBooklet*.class"/>
</fileset>
<!-- jailbreak frontend, required -->
<zipfileset src="lib/jailbreak.jar">
<include name="**/*.class"/>
</zipfileset>
<!-- resources -->
<fileset dir="src/">
<include name="**/resources/*"/>
<exclude name="**/resources/*.java"/>
<exclude name="**/resources/old"/>
<exclude name="**/resources/aloop"/>
<exclude name="**/resources/booklet"/>
<exclude name="**/resources/tool"/>
<exclude name="**/resources/dist"/>
<exclude name="**/resources/parse-commented.awk"/>
<exclude name="**/resources/parse-commented.awk.tpl"/>
</fileset>
<!-- "cover" icon -->
<fileset dir=".">
<include name="${product.image}"/>
</fileset>
</jar>
<signjar jar="${file}" keystore="${sign.keystore.file}" storepass="${sign.keystore.password}" alias="dk${sign.aliases}" sigalg="SHA1withDSA" digestalg="SHA1"/>
<signjar jar="${file}" keystore="${sign.keystore.file}" storepass="${sign.keystore.password}" alias="di${sign.aliases}" sigalg="SHA1withDSA" digestalg="SHA1"/>
<signjar jar="${file}" keystore="${sign.keystore.file}" storepass="${sign.keystore.password}" alias="dn${sign.aliases}" sigalg="SHA1withDSA" digestalg="SHA1"/>
<antcall target="restore-parser"/>
</target>
<target name="build-booklet" depends="compile, git.changelog">
<property name="file" value="${product.filename}Booklet.jar"/>
<delete file="${file}"/>
<jar destfile="${file}">
<manifest>
<attribute name="Main-Class" value="${product.bookletmainclass}"/>
</manifest>
<!-- actual program logic files -->
<fileset dir="${build.dir}">
<include name="**/*.class"/>
<exclude name="**/KualKindlet*.class"/>
<exclude name="**/LauncherKindletJailbreak.class"/>
<exclude name="**/ui/v1/Kual*.class"/>
</fileset>
<!-- resources -->
<fileset dir="src/">
<include name="**/resources/*"/>
<exclude name="**/resources/*.java"/>
<exclude name="**/resources/old"/>
<exclude name="**/resources/aloop"/>
<exclude name="**/resources/booklet"/>
<exclude name="**/resources/tool"/>
<exclude name="**/resources/dist"/>
<exclude name="**/resources/parse-commented.awk"/>
<exclude name="**/resources/parse-commented.awk.tpl"/>
</fileset>
</jar>
<antcall target="restore-parser"/>
</target>
<!-- Strip the parser -->
<target name="strip-parser" depends="inject-git.revision" description="Strip the parser">
<exec executable="src/com/mobileread/ixtab/kindlelauncher/resources/tool/stripit.sh" failifexecutionfails="true" failonerror="true" errorproperty=""/>
<echo level="info">Built stripped parser awk script</echo>
</target>
<target name="cleanup" description="Remove the files generated by the build system">
<delete file="src/com/mobileread/ixtab/kindlelauncher/resources/parse.awk"/>
<delete file="src/com/mobileread/ixtab/kindlelauncher/resources/dist/ChangeLog.txt"/>
</target>
<!-- Get a pretty git version :). Cf. http://stackoverflow.com/questions/2974106 -->
<available file=".git" type="dir" property="git.present"/>
<target name="git.revision" description="Store git revision in ${repository.version}" if="git.present">
<exec executable="git" outputproperty="git.revision" failifexecutionfails="false">
<arg value="describe"/>
<arg value="--tags"/>
<arg value="--always"/>
<arg value="HEAD"/>
<!-- Replace the first dash by a dot -->
<redirector>
<outputfilterchain>
<tokenfilter>
<replaceregex pattern="-" replace="."/>
</tokenfilter>
</outputfilterchain>
</redirector>
</exec>
<condition property="repository.version" value="${git.revision}" else="unknown">
<and>
<isset property="git.revision"/>
<length string="${git.revision}" trim="yes" length="0" when="greater"/>
</and>
</condition>
<echo level="info">Got git revision</echo>
</target>
<!-- And the date of the last commit in our usual format... -->
<target name="git.date" description="Store date of last commit ${repository.rawdate}" if="git.present">
<exec executable="git" outputproperty="git.date" failifexecutionfails="false">
<arg value="show"/>
<arg value="-s"/>
<arg value="--format=%ct"/>
</exec>
<condition property="repository.rawdate" value="${git.date}" else="unknown">
<and>
<isset property="git.date"/>
<length string="${git.date}" trim="yes" length="0" when="greater"/>
</and>
</condition>
<echo level="info">Got last commit date</echo>
</target>
<target name="date.date" depends="git.date" description="Format date of last commit in ${repository.date}">
<exec executable="date" outputproperty="date.date" failifexecutionfails="false">
<arg value="-d"/>
<arg value="@${repository.rawdate}"/>
<arg value="+%Y%m%d"/>
</exec>
<condition property="repository.date" value="${date.date}" else="unknown">
<and>
<isset property="date.date"/>
<length string="${date.date}" trim="yes" length="0" when="greater"/>
</and>
</condition>
<echo level="info">Formatted last commit date</echo>
</target>
<!-- Finally, inject all this in the parser -->
<target name="backup-parser" description="Backup parse-commented.awk">
<copy file="src/com/mobileread/ixtab/kindlelauncher/resources/parse-commented.awk" tofile="src/com/mobileread/ixtab/kindlelauncher/resources/parse-commented.awk.tpl" overwrite="yes"/>
</target>
<target name="inject-git.revision" depends="git.revision, date.date, backup-parser" description="Inject git revision in parse-commented.awk">
<copy file="src/com/mobileread/ixtab/kindlelauncher/resources/parse-commented.awk.tpl" tofile="src/com/mobileread/ixtab/kindlelauncher/resources/parse-commented.awk" overwrite="yes">
<filterchain>
<replacetokens>
<token key="repository.version" value="${repository.version}"/>
<token key="repository.date" value="${repository.date}"/>
</replacetokens>
</filterchain>
</copy>
</target>
<target name="restore-parser" description="Restore parse-commented.awk">
<copy file="src/com/mobileread/ixtab/kindlelauncher/resources/parse-commented.awk.tpl" tofile="src/com/mobileread/ixtab/kindlelauncher/resources/parse-commented.awk" overwrite="yes"/>
<delete file="src/com/mobileread/ixtab/kindlelauncher/resources/parse-commented.awk.tpl"/>
</target>
<!-- Build a ChangeLog from git -->
<target name="git.changelog" description="Build a ChangeLog from git" if="git.present">
<exec executable="git" output="src/com/mobileread/ixtab/kindlelauncher/resources/dist/ChangeLog.txt" failifexecutionfails="false">
<arg value="log"/>
<arg value="--stat"/>
<arg value="--graph"/>
</exec>
<echo level="info">Built ChangeLog</echo>
</target>
<!-- Ship it! -->
<target name="dist" depends="build, clean">
<exec executable="src/com/mobileread/ixtab/kindlelauncher/resources/tool/shipit.sh" failifexecutionfails="false" errorproperty="">
<arg value="${repository.version}"/>
<arg value="${repository.date}"/>
</exec>
<antcall target="cleanup"/>
<echo level="info">
Finished building version ${repository.version} (${repository.date}) :)
</echo>
</target>
</project>