build.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. /*
  3. * This file is part of the Behat
  4. *
  5. * (c) Konstantin Kudryashov <ever.zet@gmail.com>
  6. *
  7. * This source file is subject to the MIT license that is bundled
  8. * with this source code in the file LICENSE.
  9. */
  10. $filename = 'mink_extension.phar';
  11. if (file_exists($filename)) {
  12. unlink($filename);
  13. }
  14. $phar = new \Phar($filename, 0, 'extension.phar');
  15. $phar->setSignatureAlgorithm(\Phar::SHA1);
  16. $phar->startBuffering();
  17. foreach (findFiles('src') as $path) {
  18. $phar->addFromString($path, file_get_contents(__DIR__.'/'.$path));
  19. }
  20. $phar->addFromString('init.php', file_get_contents(__DIR__.'/init.php'));
  21. $phar->setStub(<<<STUB
  22. <?php
  23. /*
  24. * This file is part of the Behat
  25. *
  26. * (c) Konstantin Kudryashov <ever.zet@gmail.com>
  27. *
  28. * This source file is subject to the MIT license that is bundled
  29. * with this source code in the file LICENSE.
  30. */
  31. Phar::mapPhar('extension.phar');
  32. return require 'phar://extension.phar/init.php';
  33. __HALT_COMPILER();
  34. STUB
  35. );
  36. $phar->stopBuffering();
  37. function findFiles($dir) {
  38. $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir),
  39. RecursiveIteratorIterator::CHILD_FIRST);
  40. $files = array();
  41. foreach ($iterator as $path) {
  42. if ($path->isFile()) {
  43. $files[] = $path->getPath().DIRECTORY_SEPARATOR.$path->getFilename();
  44. }
  45. }
  46. return $files;
  47. }