From 9713b7693558079543f1dd7ebe4ebcd29f5515b2 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Thu, 12 Mar 2026 17:09:59 +0800 Subject: [PATCH] Add patch to modify info.c for release builds to hide configure command --- src/Package/Target/php/unix.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/Package/Target/php/unix.php b/src/Package/Target/php/unix.php index de439acb..e636883e 100644 --- a/src/Package/Target/php/unix.php +++ b/src/Package/Target/php/unix.php @@ -161,6 +161,25 @@ trait unix shell()->cd(SOURCE_PATH . '/php-src')->exec('sed -i "s|//lib|/lib|g" Makefile'); } + #[BeforeStage('php', [self::class, 'makeForUnix'], 'php')] + #[PatchDescription('Patch info.c to hide configure command in release builds')] + public function patchInfoCForRelease(): void + { + if (str_contains((string) getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS'), '-release')) { + FileSystem::replaceFileLineContainsString( + SOURCE_PATH . '/php-src/ext/standard/info.c', + '#ifdef CONFIGURE_COMMAND', + '#ifdef NO_CONFIGURE_COMMAND', + ); + } else { + FileSystem::replaceFileLineContainsString( + SOURCE_PATH . '/php-src/ext/standard/info.c', + '#ifdef NO_CONFIGURE_COMMAND', + '#ifdef CONFIGURE_COMMAND', + ); + } + } + #[Stage] public function makeForUnix(TargetPackage $package, PackageInstaller $installer): void {