Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add PHAR generation task.

  • Loading branch information...
commit 8d4777e29d93a054d73539cc24783170717ebb0d 1 parent 1bc2643
@sebastianbergmann authored
Showing with 108 additions and 0 deletions.
  1. +83 −0 build.xml
  2. +25 −0 build/phar-autoload.php.in
View
83 build.xml
@@ -29,6 +29,17 @@
<delete dir="${basedir}/build/coverage"/>
<delete dir="${basedir}/build/logs"/>
<delete dir="${basedir}/build/pdepend"/>
+ <delete dir="${basedir}/build/phar"/>
+ <delete dir="${basedir}/build/phpdox"/>
+ <delete dir="${basedir}/build/SebastianBergmann"/>
+ <delete file="${basedir}/build/LICENSE"/>
+ <delete file="${basedir}/build/README.markdown"/>
+ <delete file="${basedir}/build/phploc.bat"/>
+ <delete file="${basedir}/build/phploc.php"/>
+ <delete>
+ <fileset dir="${basedir}/build" includes="**/*.phar"/>
+ <fileset dir="${basedir}/build" includes="**/*.tgz"/>
+ </delete>
</target>
<target name="prepare" depends="clean,phpab"
@@ -184,4 +195,76 @@
<delete file="${basedir}/build/phploc.bat"/>
<delete file="${basedir}/build/phploc.php"/>
</target>
+
+ <target name="phar"
+ description="Create PHAR archive of PHPLOC and all its dependencies"
+ depends="clean">
+ <mkdir dir="${basedir}/build/phar"/>
+
+ <exec executable="bash" outputproperty="version">
+ <arg value="-c" />
+ <arg value="pear remote-info pear.phpunit.de/phploc|grep Latest|sed 's/Latest //g'" />
+ </exec>
+
+ <exec executable="pear">
+ <arg value="config-set" />
+ <arg value="auto_discover" />
+ <arg value="1" />
+ </exec>
+
+ <exec executable="pear">
+ <arg value="install" />
+ <arg value="--force" />
+ <arg value="--alldeps" />
+ <arg value="--installroot" />
+ <arg path="${basedir}/build/phar" />
+ <arg value="pear.phpunit.de/phploc" />
+ </exec>
+
+ <delete dir="${basedir}/build/phar/tmp"/>
+
+ <move todir="${basedir}/build/phar/ezc">
+ <fileset dir="${basedir}/build/phar/usr/local/php-5.4/lib/php/ezc"/>
+ </move>
+
+ <move todir="${basedir}/build/phar/SebastianBergmann">
+ <fileset dir="${basedir}/build/phar/usr/local/php-5.4/lib/php/SebastianBergmann"/>
+ </move>
+
+ <move todir="${basedir}/build/phar/Symfony">
+ <fileset dir="${basedir}/build/phar/usr/local/php-5.4/lib/php/Symfony"/>
+ </move>
+
+ <delete dir="${basedir}/build/phar/usr"/>
+
+ <delete>
+ <fileset dir="${basedir}/build/phar">
+ <include name="**/*autoload.php" />
+ </fileset>
+ </delete>
+
+ <exec executable="phpab">
+ <arg value="--all" />
+ <arg value="--phar" />
+ <arg value="--output" />
+ <arg path="${basedir}/build/phploc-${version}.phar" />
+ <arg value="--template" />
+ <arg path="${basedir}/build/phar-autoload.php.in" />
+ <arg value="--indent" />
+ <arg value=" " />
+ <arg path="${basedir}/build/phar" />
+ </exec>
+
+ <chmod file="${basedir}/build/phploc-${version}.phar" perm="ugo+rx"/>
+ <copy file="${basedir}/build/phploc-${version}.phar" tofile="${basedir}/build/phploc-${version}-compressed.phar"/>
+ <chmod file="${basedir}/build/phploc-${version}-compressed.phar" perm="ugo+rx"/>
+
+ <exec executable="phar">
+ <arg value="compress" />
+ <arg value="-f" />
+ <arg path="${basedir}/build/phploc-${version}-compressed.phar" />
+ <arg value="-c" />
+ <arg value="bzip2" />
+ </exec>
+ </target>
</project>
View
25 build/phar-autoload.php.in
@@ -0,0 +1,25 @@
+#!/usr/bin/env php
+<?php
+spl_autoload_register(
+ function ($class)
+ {
+ static $classes = NULL;
+
+ if ($classes === NULL) {
+ $classes = array(
+ ___CLASSLIST___
+ );
+ }
+
+ $class = strtolower($class);
+
+ if (isset($classes[$class])) {
+ require 'phar://___PHAR___' . $classes[$class];
+ }
+ }
+);
+
+$textui = new SebastianBergmann\PHPLOC\TextUI\Command;
+$textui->main();
+
+__HALT_COMPILER();
Please sign in to comment.
Something went wrong with that request. Please try again.