mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-09 01:45:36 +08:00
Use legacy --enable-micro-win32 way to workaround
This commit is contained in:
@@ -35,11 +35,17 @@ trait windows
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[Stage]
|
#[Stage]
|
||||||
public function buildconfForWindows(TargetPackage $package): void
|
public function buildconfForWindows(TargetPackage $package, PackageInstaller $installer): void
|
||||||
{
|
{
|
||||||
InteractiveTerm::setMessage('Building php: ' . ConsoleColor::yellow('./buildconf.bat'));
|
InteractiveTerm::setMessage('Building php: ' . ConsoleColor::yellow('./buildconf.bat'));
|
||||||
V2CompatLayer::emitPatchPoint('before-php-buildconf');
|
V2CompatLayer::emitPatchPoint('before-php-buildconf');
|
||||||
cmd()->cd($package->getSourceDir())->exec('.\buildconf.bat');
|
cmd()->cd($package->getSourceDir())->exec('.\buildconf.bat');
|
||||||
|
|
||||||
|
if ($package->getBuildOption('enable-micro-win32') && $installer->isPackageResolved('php-micro')) {
|
||||||
|
SourcePatcher::patchMicroWin32();
|
||||||
|
} else {
|
||||||
|
SourcePatcher::unpatchMicroWin32();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Stage]
|
#[Stage]
|
||||||
|
|||||||
@@ -196,6 +196,22 @@ class SourcePatcher
|
|||||||
FileSystem::restoreBackupFile(SOURCE_PATH . '/php-src/ext/phar/phar.c');
|
FileSystem::restoreBackupFile(SOURCE_PATH . '/php-src/ext/phar/phar.c');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function patchMicroWin32(): void
|
||||||
|
{
|
||||||
|
// patch micro win32
|
||||||
|
if (!file_exists(SOURCE_PATH . '\php-src\sapi\micro\php_micro.c.win32bak')) {
|
||||||
|
copy(SOURCE_PATH . '\php-src\sapi\micro\php_micro.c', SOURCE_PATH . '\php-src\sapi\micro\php_micro.c.win32bak');
|
||||||
|
FileSystem::replaceFileStr(SOURCE_PATH . '\php-src\sapi\micro\php_micro.c', '#include "php_variables.h"', '#include "php_variables.h"' . "\n#define PHP_MICRO_WIN32_NO_CONSOLE 1");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function unpatchMicroWin32(): void
|
||||||
|
{
|
||||||
|
if (file_exists(SOURCE_PATH . '\php-src\sapi\micro\php_micro.c.win32bak')) {
|
||||||
|
rename(SOURCE_PATH . '\php-src\sapi\micro\php_micro.c.win32bak', SOURCE_PATH . '\php-src\sapi\micro\php_micro.c');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static function patchPhpSrc(?array $items = null): bool
|
public static function patchPhpSrc(?array $items = null): bool
|
||||||
{
|
{
|
||||||
$patch_dir = ROOT_DIR . '/src/globals/patch/php-src-patches';
|
$patch_dir = ROOT_DIR . '/src/globals/patch/php-src-patches';
|
||||||
|
|||||||
Reference in New Issue
Block a user