-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
224 lines (199 loc) · 8.9 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
<?xml version="1.0" encoding="UTF-8"?>
<project name = "module-php" basedir = ".">
<!-- Import sigcheck.xml -->
<import file = "sigcheck.xml" />
<!-- Define project properties -->
<property name = "project.basedir" location = "." />
<property name = "root.dir" location = "${project.basedir}/.." />
<property name = "build.properties" value = "${project.basedir}/build.properties" />
<property file = "${build.properties}" />
<!-- Bearsampp dev -->
<property name = "dev.path" location = "${root.dir}/dev" />
<fail unless = "dev.path" message = "Project 'dev' not found in ${dev.path}" />
<echo message = "Bearsampp dev found in ${dev.path}" level = "debug" />
<!-- Import build-commons.xml -->
<import file = "${dev.path}/build/build-commons.xml" />
<!-- Import build-bundle.xml -->
<import file = "${dev.path}/build/build-bundle.xml" />
<!-- Define directories -->
<property name = "php-ext.path" location = "${project.basedir}/ext" />
<property name = "pear-install.path" location = "${project.basedir}/pear" />
<property name = "bundle.tmp.prep.path" location = "${project.basedir}/tmp/prep" />
<property name = "build.tmp.path" location = "${project.basedir}/tmp" />
<!-- Define the executeSigcheck target -->
<target name = "executeSigcheck">
<!-- Invoke the executeSigcheck target from sigcheck.xml -->
<ant antfile = "sigcheck.xml" target = "executeSigcheck" />
</target>
<!-- Main target for release build -->
<target name = "release.build">
<!-- Define the bundle folder -->
<basename property = "bundle.folder" file = "${bundle.path}" />
<replaceproperty src = "bundle.folder" dest = "bundle.version" replace = "${bundle.name}" with = "" />
<!-- Get the PHP module -->
<getmoduleuntouched name = "${bundle.name}" version = "${bundle.version}" propSrcDest = "bundle.srcdest" propSrcFilename = "bundle.srcfilename" />
<assertfile file = "${bundle.srcdest}/php.exe" />
<!-- Prepare PHP -->
<property name = "php.prep.path" location = "${bundle.tmp.prep.path}/${bundle.name}${bundle.version}" />
<delete dir = "${php.prep.path}" />
<mkdir dir = "${php.prep.path}" />
<copy todir = "${php.prep.path}" overwrite = "true">
<fileset dir = "${bundle.srcdest}" excludes = "
dev/**,
extras/**,
PEAR/**,
*.reg,
install.txt,
go-pear.bat,
news.txt,
php.gif,
php.ini*,
snapshot.txt"
/>
</copy>
<copy todir = "${php.prep.path}" overwrite = "true">
<fileset dir = "${bundle.path}" defaultexcludes = "yes" />
</copy>
<!-- Install PEAR -->
<if>
<available file = "${php.prep.path}/pear.properties" type = "file" />
<then>
<property prefix = "phppear" file = "${php.prep.path}/pear.properties" />
<!-- Copy pear-install scripts -->
<echo message = "Copying pear-install scripts..." />
<delete dir = "${php.prep.path}/pear-install" />
<copy todir = "${php.prep.path}/pear-install">
<fileset dir = "${pear-install.path}" defaultexcludes = "yes" />
</copy>
<assertfile file = "${php.prep.path}/pear-install/pear-install.bat" />
<!-- Download phar -->
<download url = "${phppear.pear}" returnProperty = "phppear.dest" />
<copy file = "${phppear.dest}"
tofile = "${php.prep.path}/pear-install/install-pear-nozlib.phar" overwrite = "true" />
<!-- Launch phar -->
<echo message = "Processing phar..." />
<exec executable = "${php.prep.path}/pear-install/pear-install.bat"
dir = "${php.prep.path}/pear-install"
failonerror = "true"
/>
<delete dir = "${php.prep.path}/pear-install" />
<delete file = "${php.prep.path}/pear.properties" />
</then>
</if>
<!-- Extensions -->
<if>
<available file = "${php.prep.path}/exts.properties" type = "file" />
<then>
<echo message = "Processing extensions..." />
<delete file = "${build.tmp.path}/php_extensions.tmp" />
<touch file = "${build.tmp.path}/php_extensions.tmp" />
<property prefix = "phpexts" file = "${php.prep.path}/exts.properties" />
<propertyselector property = "phpexts" match = "phpexts\.(.*)" select = "\1" />
<for list = "${phpexts}" param = "phpext">
<sequential>
<var name = "phpext.version" unset = "true" />
<var name = "phpext.dest" unset = "true" />
<var name = "phpext.dll" unset = "true" />
<propertyregex property = "phpext.version" input = "${phpexts.@{phpext}}" regexp = "php_.*-(.*?(-dev))" select = "\1" />
<propertyregex property = "phpext.version" input = "${phpexts.@{phpext}}" regexp = "php_.*-(.*)-(5\.|7\.)" select = "\1" />
<!-- Download ext -->
<download url = "${phpexts.@{phpext}}" returnProperty = "phpext.dest" />
<echo message = "Extension path: ${phpext.dest}" />
<condition property = "phpext.dll" value = "${phpext.dest}/php_@{phpext}.dll">
<available file = "${phpext.dest}/php_@{phpext}.dll" type = "file" />
</condition>
<condition property = "phpext.dll" value = "${phpext.dest}">
<matches string = "${phpext.dest}" pattern = "\.dll$" />
</condition>
<fail unless = "phpext.dll" message = "Main dll not found" />
<!-- Call the Sigcheck routine -->
<antcall target = "executeSigcheck" />
<!-- Copy ext -->
<echo message = "Copy @{phpext} ${phpext.version} extension..." />
<copy file = "${phpext.dll}" tofile = "${php.prep.path}/ext/php_@{phpext}.dll" overwrite = "true" />
<if>
<equals arg1 = "@{phpext}" arg2 = "imagick" />
<then>
<copy todir = "${php.prep.path}/imagick">
<fileset dir = "${phpext.dest}" includes = "CORE_*.dll" />
</copy>
</then>
</if>
<!-- Echo extension string to temp file -->
<if>
<not>
<equals arg1 = "@{phpext}" arg2 = "xdebug" />
</not>
<then>
<echo message = "extension=@{phpext}${line.separator}" file = "${build.tmp.path}/php_extensions.tmp" append = "true" />
</then>
</if>
</sequential>
</for>
<!-- Inject in php.ini -->
<if>
<length file = "${build.tmp.path}/php_extensions.tmp" when = "equal" length = "0" />
<then>
<property name = "php.extensions" value = "" />
</then>
<else>
<loadfile property = "php.extensions" srcFile = "${build.tmp.path}/php_extensions.tmp" />
</else>
</if>
<echo message = "${line.separator}PHP extensions to inject in php.ini :${line.separator}${php.extensions}" />
<copy todir = "${php.prep.path}" overwrite = "true">
<filterset>
<filter token = "PHP_EXTENSIONS" value = "${php.extensions}" />
</filterset>
<resources>
<file file = "${bundle.path}/php.ini" />
<file file = "${bundle.path}/php.ini.ber" />
</resources>
</copy>
<delete file = "${php.prep.path}/exts.properties" />
</then>
<else>
<copy todir = "${php.prep.path}" overwrite = "true">
<filterset>
<filter token = "PHP_EXTENSIONS" value = "" />
</filterset>
<resources>
<file file = "${bundle.path}/php.ini" />
<file file = "${bundle.path}/php.ini.ber" />
</resources>
</copy>
</else>
</if>
<!-- Dependencies -->
<if>
<available file = "${php.prep.path}/deps.properties" type = "file" />
<then>
<echo message = "Processing dependencies..." />
<property prefix = "phpdeps" file = "${php.prep.path}/deps.properties" />
<propertyselector property = "phpdeps" match = "phpdeps\.(.*)" select = "\1" />
<for list = "${phpdeps}" param = "phpdep">
<sequential>
<var name = "phpdep.dest" unset = "true" />
<!-- Download dep -->
<download url = "${phpdeps.@{phpdep}}" returnProperty = "phpdep.dest" />
<echo message = "Dependency path: ${phpdep.dest}" />
<!-- Copy dep -->
<echo message = "Copy @{phpdep} dependency..." />
<if>
<equals arg1 = "@{phpdep}" arg2 = "imagemagick" />
<then>
<copy todir = "${php.prep.path}/imagick" overwrite = "true">
<fileset dir = "${phpdep.dest}" includes = "
*.exe,
*.dll"
/>
</copy>
</then>
</if>
</sequential>
</for>
<delete file = "${php.prep.path}/deps.properties" />
</then>
</if>
</target>
</project>