Permalink
Browse files

Add PHAR generation task.

  • Loading branch information...
1 parent adebbc6 commit 74a2b28a96f9cb6043782f2905f99d02a27f77c2 @sebastianbergmann committed Oct 9, 2012
Showing with 106 additions and 0 deletions.
  1. +2 −0 .gitignore
  2. +79 −0 build.xml
  3. +25 −0 build/phar-autoload.php.in
View
@@ -3,10 +3,12 @@ build/code-browser
build/coverage
build/logs
build/pdepend
+build/phar
build/phpdox
build/SebastianBergmann
build/phpcpd.bat
build/phpcpd.php
+build/*.phar
build/*.tgz
cache.properties
phpunit.xml
View
@@ -29,6 +29,7 @@
<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/ChangeLog.markdown"/>
@@ -37,6 +38,7 @@
<delete file="${basedir}/build/phpcpd.bat"/>
<delete file="${basedir}/build/phpcpd.php"/>
<delete>
+ <fileset dir="${basedir}/build" includes="**/*.phar"/>
<fileset dir="${basedir}/build" includes="**/*.tgz"/>
</delete>
</target>
@@ -200,4 +202,81 @@
<delete file="${basedir}/build/phpcpd.bat"/>
<delete file="${basedir}/build/phpcpd.php"/>
</target>
+
+ <target name="phar"
+ description="Create PHAR archive of PHPCPD 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/phpcpd|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/phpcpd" />
+ </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/PHP">
+ <fileset dir="${basedir}/build/phar/usr/local/php-5.4/lib/php/PHP"/>
+ </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" />
+ <include name="**/*autoload.php" />
+ </fileset>
+ </delete>
+
+ <exec executable="phpab">
+ <arg value="--all" />
+ <arg value="--phar" />
+ <arg value="--output" />
+ <arg path="${basedir}/build/phpcpd-${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/phpcpd-${version}.phar" perm="ugo+rx"/>
+ <copy file="${basedir}/build/phpcpd-${version}.phar" tofile="${basedir}/build/phpcpd-${version}-compressed.phar"/>
+ <chmod file="${basedir}/build/phpcpd-${version}-compressed.phar" perm="ugo+rx"/>
+
+ <exec executable="phar">
+ <arg value="compress" />
+ <arg value="-f" />
+ <arg path="${basedir}/build/phpcpd-${version}-compressed.phar" />
+ <arg value="-c" />
+ <arg value="bzip2" />
+ </exec>
+ </target>
</project>
@@ -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\PHPCPD\TextUI\Command;
+$textui->main();
+
+__HALT_COMPILER();

0 comments on commit 74a2b28

Please sign in to comment.