aboutsummaryrefslogtreecommitdiffstats
path: root/build/build.xml
blob: 52646bb82e0606cc56fbd036f85b5a823f8dd78b (plain)
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
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
<?xml version="1.0" encoding="UTF-8"?>

<project name="phpBB" description="The phpBB forum software" default="all" basedir="../">
	<!-- a few settings for the build -->
	<property name="newversion" value="3.1.0-RC5" />
	<property name="prevversion" value="3.1.0-RC4" />
	<property name="olderversions" value="3.0.12, 3.1.0-a1, 3.1.0-a2, 3.1.0-a3, 3.1.0-b1, 3.1.0-b2, 3.1.0-b3, 3.1.0-b4, 3.1.0-RC1, 3.1.0-RC2, 3.1.0-RC3" />
	<!-- no configuration should be needed beyond this point -->

	<property name="oldversions" value="${olderversions}, ${prevversion}" />
	<property name="versions" value="${oldversions}, ${newversion}" />

	<!-- These are the main targets which you will probably want to use -->
	<target name="all" depends="clean,prepare,composer,test,docs,package" />
	<target name="build" depends="clean,prepare,composer,test,docs" />

	<target name="prepare">
		<mkdir dir="build/logs" />
		<mkdir dir="build/api" />
		<mkdir dir="build/codebrowser" />
		<mkdir dir="build/coverage" />
		<mkdir dir="build/cpd" />
		<mkdir dir="build/dependencies" />
		<mkdir dir="build/new_version" />
		<mkdir dir="build/new_version/files" />
		<mkdir dir="build/new_version/patches" />
		<mkdir dir="build/new_version/release_files" />
		<mkdir dir="build/new_version/update" />
		<mkdir dir="build/old_versions" />
		<mkdir dir="build/save" />
	</target>

	<target name="clean">
		<delete dir="build/logs" />
		<delete dir="build/api" />
		<delete dir="build/codebrowser" />
		<delete dir="build/coverage" />
		<delete dir="build/cpd" />
		<delete dir="build/dependencies" />
		<delete dir="build/new_version" />
		<delete dir="build/old_versions" />
		<delete dir="build/save" />
	</target>

	<!--
		This target basically just runs composer in the phpBB tree to ensure
		all dependencies are loaded. Additional development dependencies are
		loaded because testing framework may depend on them.
	-->
	<target name="composer">
		<exec dir="phpBB"
			command="php ../composer.phar install --dev"
			checkreturn="true"
			passthru="true" />
	</target>

	<target name="test" depends="clean,prepare,composer">
		<exec dir="."
			command="phpBB/vendor/bin/phpunit
			--log-junit build/logs/phpunit.xml
			--coverage-clover build/logs/clover.xml
			--coverage-html build/coverage"
			passthru="true" />
	</target>

	<target name="test-slow" depends="clean,prepare,composer">
		<exec dir="."
			command="phpBB/vendor/bin/phpunit
			--log-junit build/logs/phpunit.xml
			--group slow
			--coverage-clover build/logs/clover-slow.xml
			--coverage-html build/coverage-slow"
			passthru="true" />
	</target>

	<target name="sniff">
		<exec command="phpBB/vendor/bin/phpcs
				-s
				--extensions=php
				--standard=build/code_sniffer/ruleset-php-strict-core.xml
				--ignore=${project.basedir}/phpBB/phpbb/db/migration/data/v30x/*
				phpBB/phpbb"
			dir="." returnProperty="retval-php-strict" passthru="true" />
		<exec command="phpBB/vendor/bin/phpcs
				-s
				--extensions=php
				--standard=build/code_sniffer/ruleset-php-legacy-core.xml
				--ignore=${project.basedir}/phpBB/cache/*
				--ignore=${project.basedir}/phpBB/develop/*
				--ignore=${project.basedir}/phpBB/ext/*
				--ignore=${project.basedir}/phpBB/includes/diff/*.php
				--ignore=${project.basedir}/phpBB/includes/sphinxapi.php
				--ignore=${project.basedir}/phpBB/includes/utf/data/*
				--ignore=${project.basedir}/phpBB/install/data/*
				--ignore=${project.basedir}/phpBB/install/database_update.php
				--ignore=${project.basedir}/phpBB/phpbb/*
				--ignore=${project.basedir}/phpBB/vendor/*
				phpBB"
			dir="." returnProperty="retval-php-legacy" passthru="true" />
		<exec command="phpBB/vendor/bin/phpcs
				-s
				--extensions=php
				--standard=build/code_sniffer/ruleset-php-extensions.xml
				--ignore=${project.basedir}/phpBB/ext/*/tests/*
				--ignore=${project.basedir}/phpBB/ext/*/vendor/*
				phpBB/ext"
			dir="." returnProperty="retval-php-ext" passthru="true" />
		<if>
			<or>
				<not><equals arg1="${retval-php-strict}" arg2="0" /></not>
				<not><equals arg1="${retval-php-legacy}" arg2="0" /></not>
				<not><equals arg1="${retval-php-ext}" arg2="0" /></not>
			</or>
			<then>
				<fail message="PHP Code Sniffer failed." />
			</then>
		</if>
	</target>

	<target name="docs">
		<exec dir="."
			command="phpBB/vendor/bin/sami.php update build/sami.conf.php"
			passthru="true" />
	</target>

	<target name="old-version-diffs">
		<foreach list="${oldversions}" param="version" target="old-version-diff" />
	</target>

	<!-- This target retrieves an old version from the git tag release-${version}
	     and creates a diff between that release and the new one -->
	<target name="old-version-diff">
		<echo msg="Retrieving version ${version}" />
		<mkdir dir="build/old_versions/release-${version}" />

		<phingcall target="export">
			<property name="revision" value="release-${version}" />
			<property name="dir" value="build/old_versions/release-${version}" />
		</phingcall>

		<phingcall target="clean-diff-dir">
			<property name="dir" value="build/old_versions/release-${version}" />
		</phingcall>

		<exec dir="build/old_versions" command="LC_ALL=C diff -crNEBwd release-${version} release-${newversion} >
			../new_version/patches/phpBB-${version}_to_${newversion}.patch" escape="false" />
		<exec dir="build/old_versions" command="LC_ALL=C diff -qr release-${version} release-${newversion} | grep 'Only in release-${version}' > ../new_version/patches/phpBB-${version}_to_${newversion}.deleted" escape="false" />
	</target>

	<target name="prepare-new-version">
		<!-- select the currently checked out commit (HEAD) for packaging -->
		<mkdir dir="build/new_version/phpBB3" />
		<phingcall target="export">
			<property name="revision" value="HEAD" />
			<property name="dir" value="build/new_version/phpBB3" />
		</phingcall>

		<!-- copy into directory for diffs -->
		<exec dir="build" command="cp -rp new_version/phpBB3 old_versions/release-${newversion}" />
		<!-- and clean up -->
		<phingcall target="clean-diff-dir">
			<property name="dir" value="build/old_versions/release-${newversion}" />
		</phingcall>

		<!-- create an empty config.php file (not for diffs) -->
		<touch file="build/new_version/phpBB3/config.php" />

	</target>

	<target name="package" depends="clean,prepare,prepare-new-version,old-version-diffs">
		<exec dir="build" command="php -f package.php '${versions}' > logs/package.log" escape="false" />
		<exec dir="build" escape="false"
			command="diff -crNEBwd old_versions/release-${prevversion}/language new_version/phpBB3/language >
				save/phpbb-${prevversion}_to_${newversion}_language.patch" />
		<exec dir="build" escape="false"
			command="diff -crNEBwd old_versions/release-${prevversion}/styles/prosilver new_version/phpBB3/styles/prosilver >
				save/phpbb-${prevversion}_to_${newversion}_prosilver.patch" />
		<exec dir="build" escape="false"
			command="diff -crNEBwd old_versions/release-${prevversion}/styles/subsilver2 new_version/phpBB3/styles/subsilver2 >
				save/phpbb-${prevversion}_to_${newversion}_subsilver2.patch" />

		<exec dir="build" escape="false"
			command="git shortlog --summary --numbered release-${prevversion}...HEAD >
				save/phpbb-${prevversion}_to_${newversion}_git_shortlog.txt" />
		<exec dir="build" escape="false"
			command="git diff --stat release-${prevversion}...HEAD >
				save/phpbb-${prevversion}_to_${newversion}_git_diffstat.txt" />

		<phingcall target="checksum-dir">
			<property name="dir" value="build/new_version/release_files" />
		</phingcall>
	</target>

	<target name="checksum-dir">
		<foreach param="filename" absparam="absfilename" target="checksum-file">
			<fileset dir="${dir}">
				<type type="file" />
			</fileset>
		</foreach>
	</target>

	<target name="checksum-file">
		<echo msg="Creating checksum file for ${absfilename}" />
		<php function="dirname" returnProperty="dir"><param value="${absfilename}"/></php>
		<exec dir="${dir}" command="sha256sum ${filename} > ${filename}.sha256" />
	</target>

	<target name="announcement" depends="prepare">
		<echo msg="Writing download links and checksums for email announcement to save/announcement_email_${newversion}.txt" />
		<exec dir="build" escape="false"
			command="php -f build_announcement.php email '${newversion}' 'new_version/release_files' sha256 >
				save/announcement_email_${newversion}.txt"  />

		<echo msg="Writing download links and checksums for bbcode announcement to save/announcement_bbcode_${newversion}.txt" />
		<exec dir="build" escape="false"
			command="php -f build_announcement.php bbcode '${newversion}' 'new_version/release_files' sha256 >
				save/announcement_bbcode_${newversion}.txt"  />
	</target>

	<target name="changelog" depends="prepare">
		<exec dir="build" escape="false"
			command="php -f build_changelog.php '${newversion}' >
				save/changelog_${newversion}.html"  />
	</target>

	<!--
		This target can be called using phingcall to retrieve a clean
		checkout of a commit from git. It will only export the phpBB directory.
		The properties revision and dir are required.
		This target will remove directories that are not needed in distribution
		and set correct permissions.
	-->
	<target name="export">
		<exec dir="phpBB"
			command="git archive ${revision} | tar -xf - -C ../${dir}"
			checkreturn="true" />

		<!-- Install composer dependencies, if there are any. -->
		<exec dir="${dir}"
			command='php -r "\$j = json_decode(file_get_contents(\"composer.json\")); echo isset(\$j->require);"'
			checkreturn="true"
			outputProperty='composer-has-dependencies' />
		<if>
			<equals arg1="${composer-has-dependencies}" arg2="1" trim="true" />
			<then>
				<!-- We have non-dev composer dependencies -->
				<exec dir="."
					command="git ls-tree ${revision} composer.phar"
					checkreturn="true"
					outputProperty='composer-ls-tree-output' />
				<if>
					<equals arg1="${composer-ls-tree-output}" arg2="" trim="true" />
					<then>
						<fail message="There are composer dependencies, but composer.phar is missing." />
					</then>
					<else>
						<!-- Export the phar, install dependencies, delete phar. -->
						<exec dir="."
							command="git archive ${revision} composer.phar | tar -xf - -C ${dir}"
							checkreturn="true" />
						<exec dir="${dir}"
							command="php composer.phar install --no-dev --optimize-autoloader"
							checkreturn="true"
							passthru="true" />
						<delete file="${dir}/composer.phar" />
					</else>
				</if>
			</then>
			<else>
				<!-- We do not have composer dependencies, do not ship composer files -->
				<delete file="${dir}/composer.json" />
				<delete file="${dir}/composer.lock" />
			</else>
		</if>

		<!-- Create schema.json -->
		<exec dir="${dir}" command="php develop/create_schema_files.php" />

		<delete file="${dir}/config.php" />
		<delete dir="${dir}/develop" />
		<delete dir="${dir}/install/data" />

		<phingcall target="clean-vendor-dir">
			<property name="dir" value="${dir}" />
		</phingcall>

		<echo msg="Setting permissions for checkout of ${revision} in ${dir}" />
		<!-- set permissions of all files to 644, directories to 755 -->
		<exec dir="${dir}" command="find . -type f|xargs chmod 644" escape="false" />
		<exec dir="${dir}" command="find . -type d|xargs chmod 755" escape="false" />
		<!-- set permissions of some directories to 777 -->
		<chmod mode="0777" file="${dir}/cache" />
		<chmod mode="0777" file="${dir}/store" />
		<chmod mode="0777" file="${dir}/files" />
		<chmod mode="0777" file="${dir}/images/avatars/upload" />
	</target>

	<target name="clean-vendor-dir">
		<!-- Delete unrelated files from vendor/, see PHPBB3-12390 -->
		<delete dir="${dir}/vendor/lusitanian/oauth/examples" />
		<delete dir="${dir}/vendor/lusitanian/oauth/tests" />
		<delete file="${dir}/vendor/lusitanian/oauth/.gitignore" />
		<delete file="${dir}/vendor/lusitanian/oauth/.travis.yml" />
		<delete file="${dir}/vendor/lusitanian/oauth/phpunit.xml.dist" />
		<delete file="${dir}/vendor/lusitanian/oauth/README.md" />

		<delete dir="${dir}/vendor/psr/log/Psr/Log/Test" />
		<delete file="${dir}/vendor/psr/log/.gitignore" />
		<delete file="${dir}/vendor/psr/log/README.md" />

		<delete dir="${dir}/vendor/symfony/config/Symfony/Component/Config/Tests" />
		<delete file="${dir}/vendor/symfony/config/Symfony/Component/Config/.gitignore" />
		<delete file="${dir}/vendor/symfony/config/Symfony/Component/Config/CHANGELOG.md" />
		<delete file="${dir}/vendor/symfony/config/Symfony/Component/Config/README.md" />
		<delete file="${dir}/vendor/symfony/config/Symfony/Component/Config/phpunit.xml.dist" />

		<delete dir="${dir}/vendor/symfony/console/Symfony/Component/Console/Tests" />
		<delete file="${dir}/vendor/symfony/console/Symfony/Component/Console/.gitignore" />
		<delete file="${dir}/vendor/symfony/console/Symfony/Component/Console/CHANGELOG.md" />
		<delete file="${dir}/vendor/symfony/console/Symfony/Component/Console/README.md" />
		<delete file="${dir}/vendor/symfony/console/Symfony/Component/Console/phpunit.xml.dist" />

		<delete dir="${dir}/vendor/symfony/debug/Symfony/Component/Debug/Tests" />
		<delete file="${dir}/vendor/symfony/debug/Symfony/Component/Debug/.gitignore" />
		<delete file="${dir}/vendor/symfony/debug/Symfony/Component/Debug/CHANGELOG.md" />
		<delete file="${dir}/vendor/symfony/debug/Symfony/Component/Debug/README.md" />
		<delete file="${dir}/vendor/symfony/debug/Symfony/Component/Debug/phpunit.xml.dist" />

		<delete dir="${dir}/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests" />
		<delete file="${dir}/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/.gitignore" />
		<delete file="${dir}/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/CHANGELOG.md" />
		<delete file="${dir}/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/README.md" />
		<delete file="${dir}/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/phpunit.xml.dist" />

		<delete dir="${dir}/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests" />
		<delete file="${dir}/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/.gitignore" />
		<delete file="${dir}/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/CHANGELOG.md" />
		<delete file="${dir}/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/README.md" />
		<delete file="${dir}/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/phpunit.xml.dist" />

		<delete dir="${dir}/vendor/symfony/filesystem/Symfony/Component/Filesystem/Tests" />
		<delete file="${dir}/vendor/symfony/filesystem/Symfony/Component/Filesystem/.gitignore" />
		<delete file="${dir}/vendor/symfony/filesystem/Symfony/Component/Filesystem/CHANGELOG.md" />
		<delete file="${dir}/vendor/symfony/filesystem/Symfony/Component/Filesystem/README.md" />
		<delete file="${dir}/vendor/symfony/filesystem/Symfony/Component/Filesystem/phpunit.xml.dist" />

		<delete dir="${dir}/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests" />
		<delete file="${dir}/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/.gitignore" />
		<delete file="${dir}/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/CHANGELOG.md" />
		<delete file="${dir}/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/README.md" />
		<delete file="${dir}/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/phpunit.xml.dist" />

		<delete dir="${dir}/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests" />
		<delete file="${dir}/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/.gitignore" />
		<delete file="${dir}/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/CHANGELOG.md" />
		<delete file="${dir}/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/README.md" />
		<delete file="${dir}/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/phpunit.xml.dist" />

		<delete dir="${dir}/vendor/symfony/routing/Symfony/Component/Routing/Tests" />
		<delete file="${dir}/vendor/symfony/routing/Symfony/Component/Routing/.gitignore" />
		<delete file="${dir}/vendor/symfony/routing/Symfony/Component/Routing/CHANGELOG.md" />
		<delete file="${dir}/vendor/symfony/routing/Symfony/Component/Routing/README.md" />
		<delete file="${dir}/vendor/symfony/routing/Symfony/Component/Routing/phpunit.xml.dist" />

		<delete dir="${dir}/vendor/symfony/yaml/Symfony/Component/Yaml/Tests" />
		<delete file="${dir}/vendor/symfony/yaml/Symfony/Component/Yaml/.gitignore" />
		<delete file="${dir}/vendor/symfony/yaml/Symfony/Component/Yaml/CHANGELOG.md" />
		<delete file="${dir}/vendor/symfony/yaml/Symfony/Component/Yaml/README.md" />
		<delete file="${dir}/vendor/symfony/yaml/Symfony/Component/Yaml/phpunit.xml.dist" />

		<delete dir="${dir}/vendor/twig/twig/doc" />
		<delete dir="${dir}/vendor/twig/twig/ext" />
		<delete dir="${dir}/vendor/twig/twig/test" />
		<delete file="${dir}/vendor/twig/twig/.editorconfig" />
		<delete file="${dir}/vendor/twig/twig/.gitignore" />
		<delete file="${dir}/vendor/twig/twig/.travis.yml" />
		<delete file="${dir}/vendor/twig/twig/AUTHORS" />
		<delete file="${dir}/vendor/twig/twig/CHANGELOG" />
		<delete file="${dir}/vendor/twig/twig/phpunit.xml.dist" />
		<delete file="${dir}/vendor/twig/twig/README.markdown" />
	</target>

	<target name="clean-diff-dir">
		<delete dir="${dir}/cache" />
		<delete dir="${dir}/docs" />
		<delete dir="${dir}/files" />
		<delete dir="${dir}/install" />
		<delete dir="${dir}/store" />
		<delete dir="${dir}/vendor" />
	</target>

</project>