Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

205 lines (154 sloc) 6.553 kb
<?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" />
<delete dir="${build.tempdir}" includeemptydirs="true" verbose="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}">&lt;?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>
<stripphpcomments />
<stripwhitespace />
<replaceregexp>
<regexp pattern="&lt;\?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>
<stripphpcomments />
<stripwhitespace />
</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>
Jump to Line
Something went wrong with that request. Please try again.