2026-02-10 22:35:25 +08:00
|
|
|
<?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;
|
2026-03-08 14:02:15 +08:00
|
|
|
use StaticPHP\Package\PhpExtensionPackage;
|
|
|
|
|
use StaticPHP\Util\FileSystem;
|
2026-02-10 22:35:25 +08:00
|
|
|
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();
|
|
|
|
|
}
|
2026-03-08 14:02:15 +08:00
|
|
|
|
|
|
|
|
#[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']
|
|
|
|
|
);
|
|
|
|
|
}
|
2026-02-10 22:35:25 +08:00
|
|
|
}
|