build_precommand.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!/usr/bin/php
  2. <?php echo '<'.'?php';?>
  3. /** @file phar.php
  4. * @ingroup Phar
  5. * @brief class Phar Pre Command
  6. * @author Marcus Boerger
  7. * @date 2007 - 2008
  8. *
  9. * Phar Command
  10. */
  11. foreach(array("SPL", "Reflection", "Phar") as $ext) {
  12. if (!extension_loaded($ext)) {
  13. echo "$argv[0] requires PHP extension $ext.\n";
  14. exit(1);
  15. }
  16. }
  17. <?php
  18. $classes = array(
  19. 'DirectoryTreeIterator',
  20. 'DirectoryGraphIterator',
  21. 'InvertedRegexIterator',
  22. 'CLICommand',
  23. 'PharCommand',
  24. );
  25. foreach($classes as $name) {
  26. echo "if (!class_exists('$name', 0))\n{\n";
  27. $f = file(dirname(__FILE__) . '/phar/' . strtolower($name) . '.inc');
  28. unset($f[0]);
  29. $c = count($f);
  30. while ($c && (strlen($f[$c]) == 0 || $f[$c] == "\n" || $f[$c] == "\r\n")) {
  31. unset($f[$c--]);
  32. }
  33. if (substr($f[$c], -2) == "\r\n") {
  34. $f[$c] = substr($f[$c], 0, -2);
  35. }
  36. if (substr($f[$c], -1) == "\n") {
  37. $f[$c] = substr($f[$c], 0, -1);
  38. }
  39. if (substr($f[$c], -2) == '?>') {
  40. $f[$c] = substr($f[$c], 0,-2);
  41. }
  42. while ($c && (strlen($f[$c]) == 0 || $f[$c] == "\n" || $f[$c] == "\r\n")) {
  43. unset($f[$c--]);
  44. }
  45. echo join('', $f);
  46. echo "\n}\n\n";
  47. }
  48. echo 'new PharCommand($argc, $argv);'."\n";
  49. ?>