mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-19 13:24:51 +08:00
add static-php-cli.version ini for php-src
This commit is contained in:
parent
2591b48abe
commit
839931d65f
@ -23,7 +23,7 @@ use Symfony\Component\Console\Command\ListCommand;
|
||||
*/
|
||||
final class ConsoleApplication extends Application
|
||||
{
|
||||
public const VERSION = '2.1.0-beta.1';
|
||||
public const VERSION = '2.1.0-beta.2';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
@ -104,6 +104,9 @@ class BuildCliCommand extends BuildCommand
|
||||
SourcePatcher::patchHardcodedINI($custom_ini);
|
||||
}
|
||||
|
||||
// add static-php-cli.version to main.c, in order to debug php failure more easily
|
||||
SourcePatcher::patchSPCVersionToPHP($this->getApplication()->getVersion());
|
||||
|
||||
// start to build
|
||||
$builder->buildPHP($rule);
|
||||
|
||||
|
||||
@ -296,4 +296,20 @@ class SourcePatcher
|
||||
$lines[$line_num + 1] = "\t" . '"$(LINK)" /nologo $(PHP_GLOBAL_OBJS_RESP) $(CLI_GLOBAL_OBJS_RESP) $(STATIC_EXT_OBJS_RESP) $(STATIC_EXT_LIBS) $(ASM_OBJS) $(LIBS) $(LIBS_CLI) $(BUILD_DIR)\php.exe.res /out:$(BUILD_DIR)\php.exe $(LDFLAGS) $(LDFLAGS_CLI) /ltcg /nodefaultlib:msvcrt /nodefaultlib:msvcrtd /ignore:4286';
|
||||
FileSystem::writeFile(SOURCE_PATH . '/php-src/Makefile', implode("\r\n", $lines));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add additional `static-php-cli.version` ini value for PHP source.
|
||||
*
|
||||
* @throws FileSystemException
|
||||
*/
|
||||
public static function patchSPCVersionToPHP(string $version = 'unknown'): void
|
||||
{
|
||||
// detect patch
|
||||
$file = FileSystem::readFile(SOURCE_PATH . '/php-src/main/main.c');
|
||||
if (!str_contains($file, 'static-php-cli.version')) {
|
||||
logger()->debug('Inserting static-php-cli.version to php-src');
|
||||
$file = str_replace('PHP_INI_BEGIN()', "PHP_INI_BEGIN()\n\tPHP_INI_ENTRY(\"static-php-cli.version\",\t\"{$version}\",\tPHP_INI_ALL,\tNULL)", $file);
|
||||
FileSystem::writeFile(SOURCE_PATH . '/php-src/main/main.c', $file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user