Merge branch 'v3' into fable-v3-windows

This commit is contained in:
Marc
2026-07-08 11:45:02 +07:00
committed by GitHub
136 changed files with 4051 additions and 1453 deletions

View File

@@ -5,12 +5,13 @@ declare(strict_types=1);
namespace StaticPHP\Runtime\Executor;
use StaticPHP\Package\LibraryPackage;
use StaticPHP\Package\ToolPackage;
abstract class Executor
{
public function __construct(protected LibraryPackage $package) {}
public function __construct(protected LibraryPackage|ToolPackage $package) {}
public static function create(LibraryPackage $package): static
public static function create(LibraryPackage|ToolPackage $package): static
{
return new static($package);
}

View File

@@ -10,6 +10,7 @@ use StaticPHP\Exception\SPCInternalException;
use StaticPHP\Package\LibraryPackage;
use StaticPHP\Package\PackageBuilder;
use StaticPHP\Package\PackageInstaller;
use StaticPHP\Package\ToolPackage;
use StaticPHP\Runtime\Shell\UnixShell;
use StaticPHP\Util\InteractiveTerm;
use ZM\Logger\ConsoleColor;
@@ -22,7 +23,7 @@ class UnixAutoconfExecutor extends Executor
protected PackageInstaller $installer;
public function __construct(protected LibraryPackage $package, ?PackageInstaller $installer = null)
public function __construct(protected LibraryPackage|ToolPackage $package, ?PackageInstaller $installer = null)
{
parent::__construct($package);
if ($installer !== null) {
@@ -117,7 +118,7 @@ class UnixAutoconfExecutor extends Executor
/**
* Add configure args.
*/
public function addConfigureArgs(...$args): static
public function addConfigureArgs(string ...$args): static
{
$this->configure_args = [...$this->configure_args, ...$args];
return $this;
@@ -126,7 +127,7 @@ class UnixAutoconfExecutor extends Executor
/**
* Remove some configure args, to bypass the configure option checking for some libs.
*/
public function removeConfigureArgs(...$args): static
public function removeConfigureArgs(string ...$args): static
{
$this->configure_args = array_diff($this->configure_args, $args);
return $this;

View File

@@ -11,6 +11,7 @@ use StaticPHP\Package\LibraryPackage;
use StaticPHP\Package\PackageBuilder;
use StaticPHP\Package\PackageInstaller;
use StaticPHP\Package\TargetPackage;
use StaticPHP\Package\ToolPackage;
use StaticPHP\Runtime\Shell\UnixShell;
use StaticPHP\Runtime\SystemTarget;
use StaticPHP\Util\FileSystem;
@@ -40,7 +41,7 @@ class UnixCMakeExecutor extends Executor
protected PackageInstaller $installer;
public function __construct(protected LibraryPackage $package, ?PackageInstaller $installer = null)
public function __construct(protected LibraryPackage|ToolPackage $package, ?PackageInstaller $installer = null)
{
parent::__construct($package);
if ($installer !== null) {
@@ -135,7 +136,7 @@ class UnixCMakeExecutor extends Executor
/**
* Add configure args.
*/
public function addConfigureArgs(...$args): static
public function addConfigureArgs(string ...$args): static
{
$this->configure_args = [...$this->configure_args, ...$args];
return $this;
@@ -144,7 +145,7 @@ class UnixCMakeExecutor extends Executor
/**
* Remove some configure args, to bypass the configure option checking for some libs.
*/
public function removeConfigureArgs(...$args): static
public function removeConfigureArgs(string ...$args): static
{
$this->ignore_args = [...$this->ignore_args, ...$args];
return $this;

View File

@@ -9,6 +9,7 @@ use StaticPHP\Exception\SPCInternalException;
use StaticPHP\Package\LibraryPackage;
use StaticPHP\Package\PackageBuilder;
use StaticPHP\Package\PackageInstaller;
use StaticPHP\Package\ToolPackage;
use StaticPHP\Runtime\Shell\WindowsCmd;
use StaticPHP\Util\FileSystem;
use StaticPHP\Util\InteractiveTerm;
@@ -35,7 +36,7 @@ class WindowsCMakeExecutor extends Executor
protected PackageInstaller $installer;
public function __construct(protected LibraryPackage $package)
public function __construct(protected LibraryPackage|ToolPackage $package)
{
parent::__construct($this->package);
$this->builder = ApplicationContext::get(PackageBuilder::class);
@@ -99,7 +100,7 @@ class WindowsCMakeExecutor extends Executor
/**
* Add configure args.
*/
public function addConfigureArgs(...$args): static
public function addConfigureArgs(string ...$args): static
{
$this->configure_args = [...$this->configure_args, ...$args];
return $this;
@@ -108,7 +109,7 @@ class WindowsCMakeExecutor extends Executor
/**
* Remove some configure args, to bypass the configure option checking for some libs.
*/
public function removeConfigureArgs(...$args): static
public function removeConfigureArgs(string ...$args): static
{
$this->ignore_args = [...$this->ignore_args, ...$args];
return $this;

View File

@@ -185,12 +185,14 @@ class DefaultShell extends Shell
*/
public function execute7zExtract(string $archive_path, string $target_path): bool
{
$sdk_path = getenv('PHP_SDK_PATH');
if ($sdk_path === false) {
throw new SPCInternalException('PHP_SDK_PATH environment variable is not set');
// 7za.exe is installed by the 7za-win target package into PKG_ROOT_PATH\bin,
// which is added to PATH by MSVCToolchain::initEnv().
$_7z_path = FileSystem::convertPath(PKG_ROOT_PATH . '\bin\7za.exe');
if (!file_exists($_7z_path)) {
throw new SPCInternalException('7za.exe not found. Please install the 7za-win target package.');
}
$_7z = escapeshellarg(FileSystem::convertPath($sdk_path . '/bin/7za.exe'));
$_7z = escapeshellarg(FileSystem::convertPath($_7z_path));
$archive_arg = escapeshellarg(FileSystem::convertPath($archive_path));
$target_arg = escapeshellarg(FileSystem::convertPath($target_path));

View File

@@ -6,6 +6,7 @@ namespace StaticPHP\Runtime\Shell;
use StaticPHP\Exception\SPCInternalException;
use StaticPHP\Package\LibraryPackage;
use StaticPHP\Package\ToolPackage;
use StaticPHP\Runtime\SystemTarget;
use ZM\Logger\ConsoleColor;
@@ -40,9 +41,9 @@ class UnixShell extends Shell
/**
* Init the environment variable that common build will be used.
*
* @param LibraryPackage $library Library package
* @param LibraryPackage|ToolPackage $library Library or tool package
*/
public function initializeEnv(LibraryPackage $library): UnixShell
public function initializeEnv(LibraryPackage|ToolPackage $library): UnixShell
{
$this->setEnv([
'CFLAGS' => $library->getLibExtraCFlags(),