Allow all types of package can be built

This commit is contained in:
crazywhalecc 2025-12-08 16:59:38 +08:00
parent 11e7a590c8
commit 321f2e13e8
No known key found for this signature in database
GPG Key ID: 1F4BDD59391F2680
2 changed files with 17 additions and 17 deletions

View File

@ -13,23 +13,6 @@ use StaticPHP\Util\FileSystem;
*/
class LibraryPackage extends Package
{
/** @var array<string, callable> $build_functions Build functions for different OS binding */
protected array $build_functions = [];
/**
* Add a build function for a specific platform.
*
* @param string $platform PHP_OS_FAMILY
* @param callable $func Function to build for the platform
*/
public function addBuildFunction(string $platform, callable $func): void
{
$this->build_functions[$platform] = $func;
if ($platform === PHP_OS_FAMILY) {
$this->addStage('build', $func);
}
}
public function isInstalled(): bool
{
foreach (PackageConfig::get($this->getName(), 'static-libs', []) as $lib) {

View File

@ -19,6 +19,9 @@ abstract class Package
*/
protected array $stages = [];
/** @var array<string, callable> $build_functions Build functions for different OS binding */
protected array $build_functions = [];
/**
* @param string $name Name of the package
* @param string $type Type of the package
@ -55,6 +58,20 @@ abstract class Package
return $ret;
}
/**
* Add a build function for a specific platform.
*
* @param string $os_family PHP_OS_FAMILY
* @param callable $func Function to build for the platform
*/
public function addBuildFunction(string $os_family, callable $func): void
{
$this->build_functions[$os_family] = $func;
if ($os_family === PHP_OS_FAMILY) {
$this->addStage('build', $func);
}
}
public function isInstalled(): bool
{
// By default, assume package is not installed.