mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-06 16:25:39 +08:00
52 lines
1.5 KiB
PHP
52 lines
1.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Package\Extension;
|
|
|
|
use Package\Target\php;
|
|
use StaticPHP\Attribute\Package\AfterStage;
|
|
use StaticPHP\Attribute\Package\BeforeStage;
|
|
use StaticPHP\Attribute\Package\Extension;
|
|
use StaticPHP\Attribute\PatchDescription;
|
|
use StaticPHP\Package\PhpExtensionPackage;
|
|
use StaticPHP\Util\FileSystem;
|
|
use StaticPHP\Util\SourcePatcher;
|
|
|
|
#[Extension('phar')]
|
|
class phar
|
|
{
|
|
#[BeforeStage('php', [php::class, 'makeMicroForUnix'], 'ext-phar')]
|
|
#[PatchDescription('Patch phar extension for micro SAPI to support compressed phar')]
|
|
public function beforeMicroUnixBuild(): void
|
|
{
|
|
SourcePatcher::patchMicroPhar(php::getPHPVersionID());
|
|
}
|
|
|
|
#[AfterStage('php', [php::class, 'makeMicroForUnix'], 'ext-phar')]
|
|
public function afterMicroUnixBuild(): void
|
|
{
|
|
SourcePatcher::unpatchMicroPhar();
|
|
}
|
|
|
|
#[BeforeStage('ext-phar', 'build')]
|
|
public function beforeBuildShared(PhpExtensionPackage $pkg): void
|
|
{
|
|
FileSystem::replaceFileStr(
|
|
"{$pkg->getSourceDir()}/config.m4",
|
|
['$ext_dir/phar.1', '$ext_dir/phar.phar.1'],
|
|
['${ext_dir}phar.1', '${ext_dir}phar.phar.1']
|
|
);
|
|
}
|
|
|
|
#[AfterStage('ext-phar', 'build')]
|
|
public function afterBuildShared(PhpExtensionPackage $pkg): void
|
|
{
|
|
FileSystem::replaceFileStr(
|
|
"{$pkg->getSourceDir()}/config.m4",
|
|
['${ext_dir}phar.1', '${ext_dir}phar.phar.1'],
|
|
['$ext_dir/phar.1', '$ext_dir/phar.phar.1']
|
|
);
|
|
}
|
|
}
|