-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild.xml
225 lines (198 loc) · 9.51 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
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE project>
<project name="buildApps"
default="buildAll"
basedir=".">
<property file="build.properties"/>
<description>
This file list is used by ant to build project
</description>
<!--=======================================================================-->
<!-- some variables -->
<!--=======================================================================-->
<property name="app.name" value="buildApps"/>
<property name="sign.jar" value="${basedir}/tools/signapk.jar"/>
<property name="sign.pem" value="${basedir}/tools/testkey.x509.pem"/>
<property name="sign.pk8" value="${basedir}/tools/testkey.pk8"/>
<tstamp>
<format property="build.today" pattern="yyyyMMdd"/>
</tstamp>
<!--=======================================================================-->
<!-- complete build -->
<!--=======================================================================-->
<target name="buildAll"
depends="cleanupBefore,initit,generateCleanUpList,buildARMPackage,buildX86Package,cleanupAfter"
description="execute complete build"/>
<!--=======================================================================-->
<!-- project -->
<!--=======================================================================-->
<target name="buildARMPackage">
<!-- preparations -->
<property environment="env"/>
<property name="file.version.arm" value="${PRODUCT_VERSION_NAME}-${PRODUCT_VERSION_MAJOR}-${PRODUCT_VERSION_DNSCRYPT}-ARM"/>
<property name="file.name.arm" value="${build.dir}/${file.version.arm}-${build.today}.zip"/>
<delete dir="${work.dir}"/>
<propertyfile file="${build.dir}/props.filenames">
<entry key="armfilename" value="${file.name.arm}"/>
</propertyfile>
<!-- copy files -->
<copy todir="${work.dir}">
<fileset dir="${source.dir}" >
<exclude name="vendor/**"/>
</fileset>
<fileset dir="${source.dir}" >
<include name="vendor/armeabi-v7a/**/*"/>
<include name="vendor/arm64-v8a/**/*"/>
</fileset>
</copy>
<copy todir="${work.dir}/system/etc/dnscrypt-proxy">
<fileset dir="${git.resolvers.dir}/v2" >
<include name="public-resolvers*"/>
</fileset>
</copy>
<copy file="${extra.dir}/updater-script" todir="${work.dir}/META-INF/com/google/android" />
<!-- generate backup script -->
<fileset id="item.file" dir="${work.dir}/system" includes="**/*"/>
<pathconvert refid="item.file" property="file.list" pathsep=" " dirsep="/">
<map from="${work.dir}/system/" to=''/>
</pathconvert>
<copy file="${extra.dir}/99-dnscrypt.sh" todir="${work.dir}/system/addon.d">
<filterchain>
<replaceregex pattern="@file.version@" replace="${file.version.arm}" flags="i"/>
<replaceregex pattern="@file.list@" replace="${file.list}" flags="i"/>
</filterchain>
</copy>
<!-- zip and sign it -->
<antcall target="ZipAndSigning">
<param name="hfile.name" value="${file.name.arm}"/>
</antcall>
</target>
<target name="buildX86Package">
<!-- preparations -->
<property environment="env"/>
<property name="file.version.x86" value="${PRODUCT_VERSION_NAME}-${PRODUCT_VERSION_MAJOR}-${PRODUCT_VERSION_DNSCRYPT}-X86"/>
<property name="file.name.x86" value="${build.dir}/${file.version.x86}-${build.today}.zip"/>
<delete dir="${work.dir}"/>
<propertyfile file="${build.dir}/props.filenames">
<entry key="x86filename" value="${file.name.x86}"/>
</propertyfile>
<!-- copy files -->
<copy todir="${work.dir}">
<fileset dir="${source.dir}" >
<exclude name="vendor/**"/>
</fileset>
<fileset dir="${source.dir}" >
<include name="vendor/X86/**/*"/>
<include name="vendor/X86_64/**/*"/>
</fileset>
</copy>
<copy todir="${work.dir}/system/etc/dnscrypt-proxy">
<fileset dir="${git.resolvers.dir}/v2" >
<include name="public-resolvers*"/>
</fileset>
</copy>
<copy file="${extra.dir}/updater-script" todir="${work.dir}/META-INF/com/google/android" />
<!-- generate backup script -->
<fileset id="item.file" dir="${work.dir}/system" includes="**/*"/>
<pathconvert refid="item.file" property="file.list" pathsep=" " dirsep="/">
<map from="${work.dir}/system/" to=''/>
</pathconvert>
<copy file="${extra.dir}/99-dnscrypt.sh" todir="${work.dir}/system/addon.d">
<filterchain>
<replaceregex pattern="@file.version@" replace="${file.version.x86}" flags="i"/>
<replaceregex pattern="@file.list@" replace="${file.list}" flags="i"/>
</filterchain>
</copy>
<!-- zip and sign it -->
<antcall target="ZipAndSigning">
<param name="hfile.name" value="${file.name.x86}"/>
</antcall>
</target>
<!--=======================================================================-->
<!-- generate clean up list -->
<!--=======================================================================-->
<target name="generateCleanUpList">
<path id="cleanup.file">
<fileset dir="${extra.dir}">
<include name="*.sh"/>
</fileset>
<fileset dir="${source.dir}/system"/>
</path>
</target>
<!--=======================================================================-->
<!-- zip and sign it -->
<!--=======================================================================-->
<target name="ZipAndSigning">
<zip destfile="${build.dir}/unsigned.zip" basedir="${work.dir}"/>
<echo message="Signing..."/>
<java dir="${build.dir}" fork="true" failonerror="true" maxmemory="1536m" jar="${sign.jar}">
<arg value="-w"/>
<arg value="${sign.pem}"/>
<arg value="${sign.pk8}"/>
<arg value="${build.dir}/unsigned.zip"/>
<arg value="${hfile.name}"/>
</java>
</target>
<!--=======================================================================-->
<!-- cleanupBefore new build -->
<!--=======================================================================-->
<target name="cleanupBefore"
description="delete old directories">
<delete dir="${build.dir}"/>
<delete dir="${work.dir}"/>
</target>
<!--=======================================================================-->
<!-- cleanupAfter build is done -->
<!--=======================================================================-->
<target name="cleanupAfter"
description="delete unnecessary build files">
<echo message="Cleaning up"/>
<delete file="${build.dir}/unsigned.zip"/>
</target>
<!--=======================================================================-->
<!-- initiating build -->
<!--=======================================================================-->
<target name ="initit"
description="initiating-steps">
<mkdir dir="${build.dir}"/>
<mkdir dir="${work.dir}"/>
<git-clone-pull repository="${git.resolvers.source}" dest="${git.resolvers.dir}" />
</target>
<!--=======================================================================-->
<!-- test build -->
<!--=======================================================================-->
<target name ="testit"
description="testtest">
<echo message="${x.dir}"/>
<property name="x.dir" value="test9899"/>
<echo message="${x.dir}"/>
</target>
<!--=======================================================================-->
<!-- git command -->
<!--=======================================================================-->
<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>
</project>