-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcompile
executable file
·71 lines (57 loc) · 1.74 KB
/
compile
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
63
64
65
66
67
68
69
70
71
#!/usr/bin/env php
<?php
require_once __DIR__.'/vendor/Symfony/Component/ClassLoader/UniversalClassLoader.php';
$loader = new Symfony\Component\ClassLoader\UniversalClassLoader();
$loader->registerNamespaces(array(
'Symfony' => __DIR__.'/vendor',
'MySQLndUhTool' => __DIR__.'/src',
));
$loader->register();
$pharFile = 'mysqlnduhtool.phar';
if (file_exists($pharFile))
{
unlink($pharFile);
}
$phar = new \Phar($pharFile, 0, 'MySQLndUhTool');
$phar->setSignatureAlgorithm(\Phar::SHA1);
$phar->startBuffering();
if (!file_exists('composer.phar')) {
shell_exec('wget http://getcomposer.org/composer.phar');
}
shell_exec('php composer.phar install');
// CLI Component files
$files = array(
'LICENSE',
'vendor/.composer/autoload.php',
'vendor/.composer/autoload_namespaces.php'
);
$dirs = array(
'src/MySQLndUhTool',
'vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher',
);
$finder = new \Symfony\Component\Finder\Finder();
$iterator = $finder->files()->name('*.php')->in($dirs);
$files = array_merge($files, iterator_to_array($iterator));
foreach ($files as $file)
{
$path = str_replace(__DIR__.'/', '', $file);
$content = php_strip_whitespace($file);
$phar->addFromString($path, $content);
}
// Stubs
$license = <<<LICENSE
/*
* This file is part of the MySQLndUhTool utility.
*
* (c) Gordon Franke <[email protected]>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
LICENSE;
$stub = sprintf('<?php %s require_once %s; __HALT_COMPILER();', $license, "__DIR__.'/vendor/.composer/autoload.php'");
$phar['_cli_stub.php'] = $stub;
$phar['_web_stub.php'] = $stub;
$phar->setDefaultStub('_cli_stub.php', '_web_stub.php');
$phar->stopBuffering();
unset($phar);