-
Notifications
You must be signed in to change notification settings - Fork 10
/
build.php
62 lines (49 loc) · 1.54 KB
/
build.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
chdir(__DIR__);
if (!file_exists('vendor/autoload.php')) {
echo '[ERROR] It\'s required to run "composer install" before building MutaTesting!' . PHP_EOL;
exit(1);
}
$filename = 'build/mutatesting.phar';
if (file_exists($filename)) {
unlink($filename);
}
$phar = new \Phar($filename, 0, 'mutatesting.phar');
$phar->setSignatureAlgorithm(\Phar::SHA1);
$phar->startBuffering();
$files = array_merge(rglob('*.php'), rglob('*.twig'), rglob('*.json'));
$exclude = '!(.git)|(.svn)!';
foreach($files as $file) {
if(preg_match($exclude, $file)) continue;
$path = str_replace(__DIR__.'/', '', $file);
$phar->addFromString($path, file_get_contents($file));
}
$phar->setStub(<<<STUB
#!/usr/bin/env php
<?php
/*
* This file is part of the PhpMetrics
*
* (c) Jean-François Lépine
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
Phar::mapPhar('mutatesting.phar');
require_once 'phar://mutatesting.phar/vendor/autoload.php';
\$dispatcher = new Symfony\Component\EventDispatcher\EventDispatcher();
\$app = new Hal\MutaTesting\Console\MutaTestingApplication('MutaTesting', '0.2');
\$app->setDispatcher(\$dispatcher);
\$app->run();
__HALT_COMPILER();
STUB
);
$phar->stopBuffering();
chmod($filename, 0755);
function rglob($pattern='*', $flags = 0, $path='')
{
$paths=glob($path.'*', GLOB_MARK|GLOB_ONLYDIR|GLOB_NOSORT);
$files=glob($path.$pattern, $flags);
foreach ($paths as $path) { $files=array_merge($files,rglob($pattern, $flags, $path)); }
return $files;
}