mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-18 12:54:52 +08:00
add hardcoded-ini option for embed SAPI
This commit is contained in:
parent
824748c2a7
commit
4e99211bc3
@ -23,7 +23,7 @@ use Symfony\Component\Console\Command\ListCommand;
|
|||||||
*/
|
*/
|
||||||
final class ConsoleApplication extends Application
|
final class ConsoleApplication extends Application
|
||||||
{
|
{
|
||||||
public const VERSION = '2.0-rc6';
|
public const VERSION = '2.0.0';
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -158,6 +158,8 @@ class SourcePatcher
|
|||||||
$cli_c_bak = SOURCE_PATH . '/php-src/sapi/cli/php_cli.c.bak';
|
$cli_c_bak = SOURCE_PATH . '/php-src/sapi/cli/php_cli.c.bak';
|
||||||
$micro_c = SOURCE_PATH . '/php-src/sapi/micro/php_micro.c';
|
$micro_c = SOURCE_PATH . '/php-src/sapi/micro/php_micro.c';
|
||||||
$micro_c_bak = SOURCE_PATH . '/php-src/sapi/micro/php_micro.c.bak';
|
$micro_c_bak = SOURCE_PATH . '/php-src/sapi/micro/php_micro.c.bak';
|
||||||
|
$embed_c = SOURCE_PATH . '/php-src/sapi/embed/php_embed.c';
|
||||||
|
$embed_c_bak = SOURCE_PATH . '/php-src/sapi/embed/php_embed.c.bak';
|
||||||
|
|
||||||
// Try to reverse backup file
|
// Try to reverse backup file
|
||||||
$find_str = 'const char HARDCODED_INI[] =';
|
$find_str = 'const char HARDCODED_INI[] =';
|
||||||
@ -168,13 +170,14 @@ class SourcePatcher
|
|||||||
$patch_str = "const char HARDCODED_INI[] =\n{$patch_str}";
|
$patch_str = "const char HARDCODED_INI[] =\n{$patch_str}";
|
||||||
|
|
||||||
// Detect backup, if we have backup, it means we need to reverse first
|
// Detect backup, if we have backup, it means we need to reverse first
|
||||||
if (file_exists($cli_c_bak) || file_exists($micro_c_bak)) {
|
if (file_exists($cli_c_bak) || file_exists($micro_c_bak) || file_exists($embed_c_bak)) {
|
||||||
self::unpatchHardcodedINI();
|
self::unpatchHardcodedINI();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Backup it
|
// Backup it
|
||||||
$result = file_put_contents($cli_c_bak, file_get_contents($cli_c));
|
$result = file_put_contents($cli_c_bak, file_get_contents($cli_c));
|
||||||
$result = $result && file_put_contents($micro_c_bak, file_get_contents($micro_c));
|
$result = $result && file_put_contents($micro_c_bak, file_get_contents($micro_c));
|
||||||
|
$result = $result && file_put_contents($embed_c_bak, file_get_contents($embed_c));
|
||||||
if ($result === false) {
|
if ($result === false) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -182,6 +185,7 @@ class SourcePatcher
|
|||||||
// Patch it
|
// Patch it
|
||||||
FileSystem::replaceFileStr($cli_c, $find_str, $patch_str);
|
FileSystem::replaceFileStr($cli_c, $find_str, $patch_str);
|
||||||
FileSystem::replaceFileStr($micro_c, $find_str, $patch_str);
|
FileSystem::replaceFileStr($micro_c, $find_str, $patch_str);
|
||||||
|
FileSystem::replaceFileStr($embed_c, $find_str, $patch_str);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,13 +195,17 @@ class SourcePatcher
|
|||||||
$cli_c_bak = SOURCE_PATH . '/php-src/sapi/cli/php_cli.c.bak';
|
$cli_c_bak = SOURCE_PATH . '/php-src/sapi/cli/php_cli.c.bak';
|
||||||
$micro_c = SOURCE_PATH . '/php-src/sapi/micro/php_micro.c';
|
$micro_c = SOURCE_PATH . '/php-src/sapi/micro/php_micro.c';
|
||||||
$micro_c_bak = SOURCE_PATH . '/php-src/sapi/micro/php_micro.c.bak';
|
$micro_c_bak = SOURCE_PATH . '/php-src/sapi/micro/php_micro.c.bak';
|
||||||
if (!file_exists($cli_c_bak) && !file_exists($micro_c_bak)) {
|
$embed_c = SOURCE_PATH . '/php-src/sapi/embed/php_embed.c';
|
||||||
|
$embed_c_bak = SOURCE_PATH . '/php-src/sapi/embed/php_embed.c.bak';
|
||||||
|
if (!file_exists($cli_c_bak) && !file_exists($micro_c_bak) && !file_exists($embed_c_bak)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$result = file_put_contents($cli_c, file_get_contents($cli_c_bak));
|
$result = file_put_contents($cli_c, file_get_contents($cli_c_bak));
|
||||||
$result = $result && file_put_contents($micro_c, file_get_contents($micro_c_bak));
|
$result = $result && file_put_contents($micro_c, file_get_contents($micro_c_bak));
|
||||||
|
$result = $result && file_put_contents($embed_c, file_get_contents($embed_c_bak));
|
||||||
@unlink($cli_c_bak);
|
@unlink($cli_c_bak);
|
||||||
@unlink($micro_c_bak);
|
@unlink($micro_c_bak);
|
||||||
|
@unlink($embed_c_bak);
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user