mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-04 15:25:41 +08:00
Add build function check for current OS and update validation logic
This commit is contained in:
@@ -15,6 +15,7 @@ use StaticPHP\Attribute\Package\Validate;
|
||||
use StaticPHP\Attribute\PatchDescription;
|
||||
use StaticPHP\Config\PackageConfig;
|
||||
use StaticPHP\DI\ApplicationContext;
|
||||
use StaticPHP\Exception\EnvironmentException;
|
||||
use StaticPHP\Exception\SPCException;
|
||||
use StaticPHP\Exception\WrongUsageException;
|
||||
use StaticPHP\Package\Package;
|
||||
@@ -529,6 +530,12 @@ class php extends TargetPackage
|
||||
$package->runStage([$this, 'unixBuildSharedExt']);
|
||||
}
|
||||
|
||||
#[BuildFor('Windows')]
|
||||
public function buildWin(TargetPackage $package): void
|
||||
{
|
||||
throw new EnvironmentException('Not implemented');
|
||||
}
|
||||
|
||||
/**
|
||||
* Patch phpize and php-config if needed
|
||||
*/
|
||||
|
||||
@@ -127,6 +127,14 @@ abstract class Package
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the package has a build function for the current OS.
|
||||
*/
|
||||
public function hasBuildFunctionForCurrentOS(): bool
|
||||
{
|
||||
return isset($this->build_functions[PHP_OS_FAMILY]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the package.
|
||||
*/
|
||||
|
||||
@@ -306,7 +306,9 @@ class PackageLoader
|
||||
}
|
||||
}
|
||||
// check stage exists
|
||||
if (!$pkg->hasStage($stage_name)) {
|
||||
// Skip validation if the package has no build function for current OS
|
||||
// (e.g., libedit has BeforeStage for 'build' but only BuildFor('Darwin'/'Linux'))
|
||||
if (!$pkg->hasStage($stage_name) && $pkg->hasBuildFunctionForCurrentOS()) {
|
||||
throw new RegistryException("Package stage [{$stage_name}] is not registered in package [{$package_name}].");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user