mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-20 23:35:37 +08:00
Add before and after build hooks for phar extension to replace file strings
This commit is contained in:
@@ -9,6 +9,8 @@ use StaticPHP\Attribute\Package\AfterStage;
|
|||||||
use StaticPHP\Attribute\Package\BeforeStage;
|
use StaticPHP\Attribute\Package\BeforeStage;
|
||||||
use StaticPHP\Attribute\Package\Extension;
|
use StaticPHP\Attribute\Package\Extension;
|
||||||
use StaticPHP\Attribute\PatchDescription;
|
use StaticPHP\Attribute\PatchDescription;
|
||||||
|
use StaticPHP\Package\PhpExtensionPackage;
|
||||||
|
use StaticPHP\Util\FileSystem;
|
||||||
use StaticPHP\Util\SourcePatcher;
|
use StaticPHP\Util\SourcePatcher;
|
||||||
|
|
||||||
#[Extension('phar')]
|
#[Extension('phar')]
|
||||||
@@ -26,4 +28,24 @@ class phar
|
|||||||
{
|
{
|
||||||
SourcePatcher::unpatchMicroPhar();
|
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']
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user