mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-18 04:44:53 +08:00
Allow all types of package can be built
This commit is contained in:
parent
11e7a590c8
commit
321f2e13e8
@ -13,23 +13,6 @@ use StaticPHP\Util\FileSystem;
|
|||||||
*/
|
*/
|
||||||
class LibraryPackage extends Package
|
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
|
public function isInstalled(): bool
|
||||||
{
|
{
|
||||||
foreach (PackageConfig::get($this->getName(), 'static-libs', []) as $lib) {
|
foreach (PackageConfig::get($this->getName(), 'static-libs', []) as $lib) {
|
||||||
|
|||||||
@ -19,6 +19,9 @@ abstract class Package
|
|||||||
*/
|
*/
|
||||||
protected array $stages = [];
|
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 $name Name of the package
|
||||||
* @param string $type Type of the package
|
* @param string $type Type of the package
|
||||||
@ -55,6 +58,20 @@ abstract class Package
|
|||||||
return $ret;
|
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
|
public function isInstalled(): bool
|
||||||
{
|
{
|
||||||
// By default, assume package is not installed.
|
// By default, assume package is not installed.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user