mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-10 10:25:36 +08:00
ttt
This commit is contained in:
@@ -1,26 +1,26 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Package\Extension;
|
namespace Package\Extension;
|
||||||
|
|
||||||
use Package\Target\php;
|
use Package\Target\php;
|
||||||
use StaticPHP\Attribute\Package\BeforeStage;
|
use StaticPHP\Attribute\Package\BeforeStage;
|
||||||
use StaticPHP\Attribute\Package\Extension;
|
use StaticPHP\Attribute\Package\Extension;
|
||||||
use StaticPHP\Attribute\PatchDescription;
|
use StaticPHP\Attribute\PatchDescription;
|
||||||
|
|
||||||
#[Extension('curl')]
|
#[Extension('curl')]
|
||||||
class curl
|
class curl
|
||||||
{
|
{
|
||||||
#[BeforeStage('php', [php::class, 'makeForWindows'], 'ext-curl')]
|
#[BeforeStage('php', [php::class, 'makeForWindows'], 'ext-curl')]
|
||||||
#[PatchDescription('Inject secur32.lib into SPC_EXTRA_LIBS for Schannel SSL support')]
|
#[PatchDescription('Inject secur32.lib into SPC_EXTRA_LIBS for Schannel SSL support')]
|
||||||
public function addSecur32LibForWindows(): void
|
public function addSecur32LibForWindows(): void
|
||||||
{
|
{
|
||||||
// curl on Windows uses Schannel (USE_WINDOWS_SSPI=ON, CURL_USE_SCHANNEL=ON),
|
// curl on Windows uses Schannel (USE_WINDOWS_SSPI=ON, CURL_USE_SCHANNEL=ON),
|
||||||
// which requires secur32.lib for SSL/TLS functions (SslEncryptPackage, etc.).
|
// which requires secur32.lib for SSL/TLS functions (SslEncryptPackage, etc.).
|
||||||
$extra_libs = getenv('SPC_EXTRA_LIBS') ?: '';
|
$extra_libs = getenv('SPC_EXTRA_LIBS') ?: '';
|
||||||
if (!str_contains($extra_libs, 'secur32.lib')) {
|
if (!str_contains($extra_libs, 'secur32.lib')) {
|
||||||
putenv('SPC_EXTRA_LIBS=' . trim($extra_libs . ' secur32.lib'));
|
putenv('SPC_EXTRA_LIBS=' . trim($extra_libs . ' secur32.lib'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ class nghttp2
|
|||||||
->build();
|
->build();
|
||||||
|
|
||||||
FileSystem::replaceFileStr($lib->getIncludeDir() . '\nghttp2\nghttp2.h', '#ifdef NGHTTP2_STATICLIB', '#if 1');
|
FileSystem::replaceFileStr($lib->getIncludeDir() . '\nghttp2\nghttp2.h', '#ifdef NGHTTP2_STATICLIB', '#if 1');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[BuildFor('Linux')]
|
#[BuildFor('Linux')]
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,64 +1,64 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace StaticPHP\Runtime\Shell;
|
namespace StaticPHP\Runtime\Shell;
|
||||||
|
|
||||||
use StaticPHP\Exception\SPCInternalException;
|
use StaticPHP\Exception\SPCInternalException;
|
||||||
use ZM\Logger\ConsoleColor;
|
use ZM\Logger\ConsoleColor;
|
||||||
|
|
||||||
class WindowsCmd extends Shell
|
class WindowsCmd extends Shell
|
||||||
{
|
{
|
||||||
public function __construct(?bool $debug = null)
|
public function __construct(?bool $debug = null)
|
||||||
{
|
{
|
||||||
if (PHP_OS_FAMILY !== 'Windows') {
|
if (PHP_OS_FAMILY !== 'Windows') {
|
||||||
throw new SPCInternalException('Only windows can use WindowsCmd');
|
throw new SPCInternalException('Only windows can use WindowsCmd');
|
||||||
}
|
}
|
||||||
parent::__construct($debug);
|
parent::__construct($debug);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function exec(string $cmd): static
|
public function exec(string $cmd): static
|
||||||
{
|
{
|
||||||
/* @phpstan-ignore-next-line */
|
/* @phpstan-ignore-next-line */
|
||||||
logger()->info(ConsoleColor::yellow('[EXEC] ') . ConsoleColor::green($cmd));
|
logger()->info(ConsoleColor::yellow('[EXEC] ') . ConsoleColor::green($cmd));
|
||||||
|
|
||||||
$original_command = $cmd;
|
$original_command = $cmd;
|
||||||
$this->logCommandInfo($original_command);
|
$this->logCommandInfo($original_command);
|
||||||
$this->last_cmd = $cmd = $this->getExecString($cmd);
|
$this->last_cmd = $cmd = $this->getExecString($cmd);
|
||||||
// echo $cmd . PHP_EOL;
|
// echo $cmd . PHP_EOL;
|
||||||
|
|
||||||
$this->passthru($cmd, $this->console_putput, $original_command, cwd: $this->cd);
|
$this->passthru($cmd, $this->console_putput, $original_command, cwd: $this->cd);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function execWithWrapper(string $wrapper, string $args): WindowsCmd
|
public function execWithWrapper(string $wrapper, string $args): WindowsCmd
|
||||||
{
|
{
|
||||||
return $this->exec($wrapper . ' "' . str_replace('"', '^"', $args) . '"');
|
return $this->exec($wrapper . ' "' . str_replace('"', '^"', $args) . '"');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function execWithResult(string $cmd, bool $with_log = true): array
|
public function execWithResult(string $cmd, bool $with_log = true): array
|
||||||
{
|
{
|
||||||
if ($with_log) {
|
if ($with_log) {
|
||||||
/* @phpstan-ignore-next-line */
|
/* @phpstan-ignore-next-line */
|
||||||
logger()->info(ConsoleColor::blue('[EXEC] ') . ConsoleColor::green($cmd));
|
logger()->info(ConsoleColor::blue('[EXEC] ') . ConsoleColor::green($cmd));
|
||||||
} else {
|
} else {
|
||||||
logger()->debug('Running command with result: ' . $cmd);
|
logger()->debug('Running command with result: ' . $cmd);
|
||||||
}
|
}
|
||||||
$original_command = $cmd;
|
$original_command = $cmd;
|
||||||
$this->logCommandInfo($original_command);
|
$this->logCommandInfo($original_command);
|
||||||
$cmd = $this->getExecString($cmd);
|
$cmd = $this->getExecString($cmd);
|
||||||
$result = $this->passthru($cmd, $this->console_putput, $original_command, capture_output: true, throw_on_error: false, cwd: $this->cd, env: $this->env);
|
$result = $this->passthru($cmd, $this->console_putput, $original_command, capture_output: true, throw_on_error: false, cwd: $this->cd, env: $this->env);
|
||||||
$out = explode("\n", $result['output']);
|
$out = explode("\n", $result['output']);
|
||||||
return [$result['code'], $out];
|
return [$result['code'], $out];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLastCommand(): string
|
public function getLastCommand(): string
|
||||||
{
|
{
|
||||||
return $this->last_cmd;
|
return $this->last_cmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getExecString(string $cmd): string
|
private function getExecString(string $cmd): string
|
||||||
{
|
{
|
||||||
return $cmd;
|
return $cmd;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user