Add lib skeleton command and sort config, spc_mode suuport, etc...

This commit is contained in:
crazywhalecc
2025-12-18 15:43:58 +08:00
parent 1707c679e8
commit dd5762fbd3
19 changed files with 866 additions and 109 deletions

View File

@@ -1,9 +1,14 @@
<?php
declare(strict_types=1);
namespace StaticPHP\Skeleton;
use StaticPHP\Exception\ValidationException;
use StaticPHP\Runtime\Executor\Executor;
use StaticPHP\Runtime\Executor\UnixAutoconfExecutor;
use StaticPHP\Runtime\Executor\UnixCMakeExecutor;
use StaticPHP\Runtime\Executor\WindowsCMakeExecutor;
class ExecutorGenerator
{
@@ -13,4 +18,19 @@ class ExecutorGenerator
throw new ValidationException('Executor class must extend ' . Executor::class);
}
}
/**
* Generate the code to create an instance of the executor.
*
* @return array{0: string, 1: string} an array containing the class name and the code string
*/
public function generateCode(): array
{
return match ($this->class) {
UnixCMakeExecutor::class => [UnixCMakeExecutor::class, 'UnixCMakeExecutor::create($package)->build();'],
UnixAutoconfExecutor::class => [UnixAutoconfExecutor::class, 'UnixAutoconfExecutor::create($package)->build();'],
WindowsCMakeExecutor::class => [WindowsCMakeExecutor::class, 'WindowsCMakeExecutor::create($package)->build();'],
default => throw new ValidationException("Unsupported executor class: {$this->class}"),
};
}
}