31 lines
901 B
PHP
31 lines
901 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
$root = dirname(__DIR__);
|
|
$target = $root . '/dist/wm.phar';
|
|
if (ini_get('phar.readonly')) {
|
|
fwrite(STDERR, "PHAR creation is disabled; run php -d phar.readonly=0 build/phar.php\n");
|
|
exit(1);
|
|
}
|
|
if (file_exists($target)) {
|
|
unlink($target);
|
|
}
|
|
$phar = new Phar($target, 0, 'wm.phar');
|
|
$phar->startBuffering();
|
|
foreach (['bin/wm', 'src/autoload.php', 'src/App.php', 'src/Runtime.php', 'src/Registry.php', 'src/Project.php', 'src/Systemd.php', 'src/Process.php', 'src/UI.php'] as $path) {
|
|
$phar->addFile($root . '/' . $path, $path);
|
|
}
|
|
$stub = <<<'STUB'
|
|
#!/usr/bin/env php
|
|
<?php
|
|
Phar::mapPhar('wm.phar');
|
|
require 'phar://wm.phar/bin/wm';
|
|
__HALT_COMPILER();
|
|
STUB;
|
|
$phar->setStub($stub . "\n");
|
|
$phar->setSignatureAlgorithm(Phar::SHA256);
|
|
$phar->stopBuffering();
|
|
chmod($target, 0755);
|
|
echo "Built {$target} (" . number_format(filesize($target)) . " bytes)\n";
|