diff --git a/src/Package/Target/php/unix.php b/src/Package/Target/php/unix.php index 2b81402d..4b2b99be 100644 --- a/src/Package/Target/php/unix.php +++ b/src/Package/Target/php/unix.php @@ -26,7 +26,6 @@ use StaticPHP\Util\InteractiveTerm; use StaticPHP\Util\SourcePatcher; use StaticPHP\Util\SPCConfigUtil; use StaticPHP\Util\System\UnixUtil; -use StaticPHP\Util\V2CompatLayer; use ZM\Logger\ConsoleColor; trait unix @@ -62,7 +61,6 @@ trait unix public function buildconfForUnix(TargetPackage $package): void { InteractiveTerm::setMessage('Building php: ' . ConsoleColor::yellow('./buildconf')); - V2CompatLayer::emitPatchPoint('before-php-buildconf'); shell()->cd($package->getSourceDir())->exec(getenv('SPC_CMD_PREFIX_PHP_BUILDCONF')); } @@ -70,7 +68,6 @@ trait unix public function configureForUnix(TargetPackage $package, PackageInstaller $installer): void { InteractiveTerm::setMessage('Building php: ' . ConsoleColor::yellow('./configure')); - V2CompatLayer::emitPatchPoint('before-php-configure'); $cmd = getenv('SPC_CMD_PREFIX_PHP_CONFIGURE'); $args = []; @@ -183,8 +180,6 @@ trait unix #[Stage] public function makeForUnix(TargetPackage $package, PackageInstaller $installer): void { - V2CompatLayer::emitPatchPoint('before-php-make'); - logger()->info('cleaning up php-src build files'); shell()->cd($package->getSourceDir())->exec('make clean'); diff --git a/src/Package/Target/php/windows.php b/src/Package/Target/php/windows.php index 8ab7b019..311db033 100644 --- a/src/Package/Target/php/windows.php +++ b/src/Package/Target/php/windows.php @@ -22,7 +22,6 @@ use StaticPHP\Util\FileSystem; use StaticPHP\Util\InteractiveTerm; use StaticPHP\Util\SourcePatcher; use StaticPHP\Util\System\WindowsUtil; -use StaticPHP\Util\V2CompatLayer; use ZM\Logger\ConsoleColor; trait windows @@ -38,7 +37,6 @@ trait windows public function buildconfForWindows(TargetPackage $package, PackageInstaller $installer): void { InteractiveTerm::setMessage('Building php: ' . ConsoleColor::yellow('./buildconf.bat')); - V2CompatLayer::emitPatchPoint('before-php-buildconf'); cmd()->cd($package->getSourceDir())->exec('.\buildconf.bat'); if ($package->getBuildOption('enable-micro-win32') && $installer->isPackageResolved('php-micro')) { @@ -52,7 +50,6 @@ trait windows public function configureForWindows(TargetPackage $package, PackageInstaller $installer): void { InteractiveTerm::setMessage('Building php: ' . ConsoleColor::yellow('./configure.bat')); - V2CompatLayer::emitPatchPoint('before-php-configure'); $args = [ '--disable-all', "--with-php-build={$package->getBuildRootPath()}", @@ -232,7 +229,6 @@ trait windows #[Stage] public function makeForWindows(TargetPackage $package, PackageInstaller $installer): void { - V2CompatLayer::emitPatchPoint('before-php-make'); InteractiveTerm::setMessage('Building php: ' . ConsoleColor::yellow('nmake clean')); cmd()->cd($package->getSourceDir())->exec('nmake clean'); diff --git a/src/StaticPHP/Package/PackageInstaller.php b/src/StaticPHP/Package/PackageInstaller.php index fa049bbd..750ddbaf 100644 --- a/src/StaticPHP/Package/PackageInstaller.php +++ b/src/StaticPHP/Package/PackageInstaller.php @@ -52,7 +52,6 @@ class PackageInstaller ApplicationContext::set(PackageInstaller::class, $this); $builder = new PackageBuilder($options); ApplicationContext::set(PackageBuilder::class, $builder); - ApplicationContext::set('patch_point', ''); // Check for no-download option if (!empty($options['no-download'])) { diff --git a/src/StaticPHP/Util/V2CompatLayer.php b/src/StaticPHP/Util/V2CompatLayer.php index 93fa36e3..ff992e44 100644 --- a/src/StaticPHP/Util/V2CompatLayer.php +++ b/src/StaticPHP/Util/V2CompatLayer.php @@ -5,11 +5,6 @@ declare(strict_types=1); namespace StaticPHP\Util; use StaticPHP\Artifact\Artifact; -use StaticPHP\DI\ApplicationContext; -use StaticPHP\Exception\InterruptException; -use StaticPHP\Exception\WrongUsageException; -use StaticPHP\Package\PackageBuilder; -use StaticPHP\Package\PackageInstaller; use StaticPHP\Package\TargetPackage; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; @@ -70,71 +65,15 @@ class V2CompatLayer } } - public static function beforeExtractHook(Artifact $artifact): void - { - self::emitPatchPoint(match ($artifact->getName()) { - 'php-src' => 'before-php-extract', - 'micro' => 'before-micro-extract', - default => '', - }); - } + public static function beforeExtractHook(Artifact $artifact): void {} - public static function afterExtractHook(Artifact $artifact): void - { - self::emitPatchPoint(match ($artifact->getName()) { - 'php-src' => 'after-php-extract', - 'micro' => 'after-micro-extract', - default => '', - }); - } + public static function afterExtractHook(Artifact $artifact): void {} - public static function beforeExtsExtractHook(): void - { - self::emitPatchPoint('before-exts-extract'); - } + public static function beforeExtsExtractHook(): void {} - public static function afterExtsExtractHook(): void - { - self::emitPatchPoint('after-exts-extract'); - } + public static function afterExtsExtractHook(): void {} - public static function beforeLibExtractHook(string $pkg): void - { - self::emitPatchPoint("before-library[{$pkg}]-extract"); - } + public static function beforeLibExtractHook(string $pkg): void {} - public static function afterLibExtractHook(string $pkg): void - { - self::emitPatchPoint("after-library[{$pkg}]-extract"); - } - - public static function emitPatchPoint(string $point_name): void - { - if ($point_name === '') { - return; - } - if (!ApplicationContext::has(PackageInstaller::class)) { - return; - } - $builder = ApplicationContext::get(PackageBuilder::class); - $patch_points = $builder->getOption('with-added-patch', []); - ApplicationContext::set('patch_point', $point_name); - foreach ($patch_points as $patch_point) { - if (!file_exists($patch_point)) { - throw new WrongUsageException("Additional patch script {$patch_point} does not exist!"); - } - logger()->debug("Applying additional patch script {$patch_point}"); - - try { - require $patch_point; - } catch (InterruptException $e) { - if ($e->getCode() === 0) { - logger()->notice('Patch script ' . $patch_point . ' interrupted' . ($e->getMessage() ? (': ' . $e->getMessage()) : '.')); - } else { - logger()->error('Patch script ' . $patch_point . ' interrupted with error code [' . $e->getCode() . ']' . ($e->getMessage() ? (': ' . $e->getMessage()) : '.')); - } - } - } - ApplicationContext::set('patch_point', ''); - } + public static function afterLibExtractHook(string $pkg): void {} } diff --git a/src/globals/functions.php b/src/globals/functions.php index ee279328..549ef498 100644 --- a/src/globals/functions.php +++ b/src/globals/functions.php @@ -3,7 +3,6 @@ declare(strict_types=1); use StaticPHP\Exception\ExecutionException; -use StaticPHP\Exception\InterruptException; use StaticPHP\Exception\WrongUsageException; use StaticPHP\Runtime\Shell\DefaultShell; use StaticPHP\Runtime\Shell\UnixShell; @@ -120,18 +119,6 @@ function cmd(?bool $debug = null): WindowsCmd return new WindowsCmd($debug); } -/** - * Get current patch point. - */ -function patch_point(): string -{ - if (StaticPHP\DI\ApplicationContext::has('patch_point')) { - /* @phpstan-ignore-next-line */ - return StaticPHP\DI\ApplicationContext::get('patch_point'); - } - return ''; -} - // Add log filter value(s) to prevent secret leak function spc_add_log_filter(array|string $filter): void { @@ -158,11 +145,6 @@ function spc_write_log(mixed $stream, string $data): false|int return fwrite($stream, $data); } -function patch_point_interrupt(int $retcode, string $msg = ''): InterruptException -{ - return new InterruptException(message: $msg, code: $retcode); -} - // ------- function f_* part ------- // f_ means standard function wrapper