phar build script
[shpub.git] / build.xml
1 <?xml version="1.0" encoding="utf-8"?>
2 <project name="shpub" default="phar" basedir=".">
3
4  <property name="version"  value="0.0.1" />
5  <property name="pharfile" value="${phing.dir}/dist/${phing.project.name}-${version}.phar" />
6  <property name="libdir" value="${phing.dir}/lib"/>
7
8  <fileset id="fs.phar" dir="${phing.dir}">
9   <include name="bin/**"/>
10   <include name="lib/**"/>
11   <include name="src/**"/>
12
13   <include name="README.rst"/>
14
15   <exclude name="bin/shpub.php"/>
16  </fileset>
17
18
19  <typedef name="pearPackageFileSet" classname="phing.types.PearPackageFileSet" />
20
21  <target name="phar" depends="collectdeps"
22          description="Create zip file for release"
23  >
24   <!-- strip the shebang  -->
25   <copy file="${phing.dir}/bin/shpub.php" tofile="${phing.dir}/bin/phar-shpub.php">
26    <filterchain>
27     <striplinecomments>
28      <comment value="#" />
29     </striplinecomments>
30    </filterchain>
31   </copy>
32
33   <mkdir dir="${phing.dir}/dist"/>
34   <delete file="${pharfile}"/>
35   <pharpackage basedir="${phing.dir}"
36    destfile="${pharfile}"
37    stub="${phing.dir}/src/phar-stub.php"
38    alias="shpub.phar"
39   >
40    <fileset refid="fs.phar"/>
41   </pharpackage>
42
43   <exec executable="chmod" checkreturn="1">
44    <arg value="+x"/>
45    <arg file="${pharfile}"/>
46   </exec>
47  </target>
48
49
50  <target name="collectdeps" description="Copy package dependencies to lib/">
51   <delete dir="${libdir}"/>
52   <mkdir dir="${libdir}"/>
53
54   <pearPackageFileset id="dep-Console_CommandLine" package="pear.php.net/Console_CommandLine"/>
55   <pearPackageFileset id="dep-HTTP_Request2" package="pear.php.net/HTTP_Request2"/>
56   <pearPackageFileset id="dep-Net_URL2" package="pear.php.net/Net_URL2"/>
57   <pearPackageFileset id="dep-PEAR" package="pear.php.net/PEAR">
58    <include name="PEAR/Exception.php"/>
59   </pearPackageFileset>
60
61   <copy todir="${libdir}">
62    <fileset refid="dep-Console_CommandLine"/>
63    <fileset refid="dep-HTTP_Request2"/>
64    <fileset refid="dep-Net_URL2"/>
65    <fileset refid="dep-PEAR"/>
66   </copy>
67  </target>
68
69
70  <target name="docs" description="render documentation">
71   <rst file="README.rst"/>
72  </target>
73
74 </project>