forked from BraveSirRobin/amqphp
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.xml
198 lines (150 loc) · 6.31 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
<?xml version="1.0"?>
<!--
Amqphp build system, can build to either "class per file" (CPF) or
"namespace per file" (NSPF) granularity.
-->
<project name="amqphp" default="build">
<taskdef name="useclean" classname="phing.PhpUseFilterTask" />
<taskdef name="codegen" classname="phing.AmqpCodeGenTask" />
<property file="build.properties"/>
<fileset dir="${srcdir}" id="SOURCES">
<include name="**/*.php"/>
</fileset>
<fileset dir="${build.tempdir}" id="BUILD_ALL">
<include name="**"/>
</fileset>
<fileset dir="${build.tempdir}" id="BUILD_PHP_FILES">
<include name="**/*.php"/>
</fileset>
<target name="clean">
<delete dir="${builddir}" includeemptydirs="true" verbose="true" failonerror="true" />
<delete dir="${build.tempdir}" includeemptydirs="true" verbose="true" failonerror="true" />
</target>
<!--
Runs the Amqp code generation routine. This is Xslt based, and
generates a set of Amqp binding classes in the specified dir.
-->
<target name="generateAmqpBindings" depends="clean">
<mkdir dir="${gencode.tempdir}"/>
<codegen stylesheet="${gencode.stylesheet}"
specfile="${gencode.specfile}"
outputDir="${gencode.tempdir}"/>
</target>
<!--
This target is called in a foreach which visits every file / folder in
the ${srcdir} source tree. Files are ignored, and directories are
converted in to NSPF packages.
-->
<target name="doNspfPackage">
<php function="is_dir" returnProperty="isDir">
<param value="${fullPath}"/>
</php>
<if>
<and>
<istrue value="${isDir}"/>
<istrue value="${fileName}"/>
</and>
<then>
<!-- Calculate a package file name -->
<php expression="implode('.', array_slice(explode('/', '${fullPath}'), count(explode('/', '${build.tempdir}')))) . '.php'"
returnProperty="nspfName"/>
<php expression="implode('\\', array_slice(explode('/', '${fullPath}'), count(explode('/', '${build.tempdir}'))))"
returnProperty="namespace"/>
<echo msg="Generate an nspf file, src=${fullPath} dst=${builddir.nsPerFile}/${nspfName} nspfName=${nspfName}"/>
<echo file="${builddir.nsPerFile}/${nspfName}"><?php</echo>
<echo file="${builddir.nsPerFile}/${nspfName}" append="true">
namespace ${namespace};</echo>
<append destFile="${builddir.nsPerFile}/${nspfName}">
<filterchain>
<replaceregexp>
<regexp pattern="^[\s]*namespace.*$" replace="" modifiers="m"/>
</replaceregexp>
<replaceregexp>
<regexp pattern="<\?php" replace=""/>
</replaceregexp>
</filterchain>
<fileset dir="${fullPath}">
<include name="*.php"/>
</fileset>
</append>
<useclean file="${builddir.nsPerFile}/${nspfName}" fromDir="${fullPath}"/>
</then>
</if>
</target>
<!--
Prepare the NSPF and CPF source trees.
-->
<target name="build" depends="generateAmqpBindings">
<mkdir dir="${builddir}"/>
<mkdir dir="${builddir.nsPerFile}"/>
<mkdir dir="${builddir.classPerFile}"/>
<mkdir dir="${build.tempdir}"/>
<!-- Copy all sources to the temp dir -->
<copy todir="${build.tempdir}" haltonerror="true">
<fileset refid="SOURCES"/>
</copy>
<!-- Write out nspf packages -->
<foreach param="fileName" absparam="fullPath" target="doNspfPackage">
<fileset refid="BUILD_ALL"/>
</foreach>
<!-- Copy over cpf package files -->
<copy todir="${builddir.classPerFile}" haltonerror="true">
<filterchain>
</filterchain>
<fileset refid="BUILD_PHP_FILES"/>
</copy>
<!-- Copy over the readme -->
<copy file="${builddir.readme}" tofile="${builddir}/README.txt"/>
</target>
<!--
Prepare the directory for development work by symlinking the
distribution cpf files to their equivalents in the ${srcdir}
-->
<target name="build-devtime" depends="build">
<!-- Set up individual symlinks from ${builddir} to ${srcdir} for all files in ${srcdir} -->
<foreach param="fileName" absparam="fullPath" target="doBuildDevSymlink">
<fileset dir="${srcdir}">
<include name="**/*.php"/>
</fileset>
</foreach>
</target>
<!-- TODO: Cut'n'paste mess! -->
<target name="build-devtime-only">
<!-- Set up individual symlinks from ${builddir} to ${srcdir} for all files in ${srcdir} -->
<foreach param="fileName" absparam="fullPath" target="doBuildDevSymlink">
<fileset dir="${srcdir}">
<include name="**/*.php"/>
</fileset>
</foreach>
</target>
<!--
Replace given ${builddir} file with a link to the ${srcdir} file
-->
<target name="doBuildDevSymlink">
<delete file="${builddir.classPerFile}/${fileName}"/>
<symlink target="${fullPath}" link="${builddir.classPerFile}/${fileName}"/>
</target>
<target name="deploy-web-demo">
<!-- Create folders. -->
<exec command="ssh phpvm mkdir -p ${webdepl.basedir}/${webdepl.viewdir} ${webdepl.basedir}/${webdepl.libdir} ${webdepl.basedir}/${webdepl.confdir}" />
<!-- controllers -->
<exec command="scp demos/pconnections/web-single-process-test.php demos/pconnections/web-multi-process-test.php phpvm:${webdepl.basedir}"
dir="${project.basedir}"/>
<!-- views -->
<exec command="scp demos/pconnections/web-controls-multi.phtml demos/pconnections/web-controls-single.phtml phpvm:${webdepl.basedir}/${webdepl.viewdir}"
dir="${project.basedir}"/>
<!-- libs -->
<exec command="scp demos/Setup.php demos/pconnections/web-common.php demos/class-loader.php phpvm:${webdepl.basedir}/${webdepl.libdir}"
dir="${project.basedir}"/>
<!-- configs -->
<exec command="scp demos/configs/web-multi.xml demos/configs/broker-common-setup.xml phpvm:${webdepl.basedir}/${webdepl.confdir}"
dir="${project.basedir}"/>
</target>
<target name="deploy-web-libs-only">
<exec command="ssh phpvm rm -rf ${webdepl.basedir}/${webdepl.libdir}/amqphp ${webdepl.basedir}/${webdepl.libdir}/nspf" />
<exec command="scp -r build/cpf build/nspf phpvm:${webdepl.basedir}/${webdepl.libdir}" dir="${project.basedir}"/>
</target>
<target name="deploy-web-libs" depends="deploy-web-demo,deploy-web-libs-only">
<echo>Note: target deploy-web-libs depends on deploy-web-demo - use deploy-web-libs to deploy libs only.</echo>
</target>
</project>