static-php-cli/src/SPC/builder/BuilderProvider.php

40 lines
1.2 KiB
PHP
Raw Normal View History

2023-03-18 17:34:37 +08:00
<?php
declare(strict_types=1);
namespace SPC\builder;
2023-10-15 13:07:13 +08:00
use SPC\builder\freebsd\BSDBuilder;
2023-03-18 17:34:37 +08:00
use SPC\builder\linux\LinuxBuilder;
use SPC\builder\macos\MacOSBuilder;
use SPC\exception\FileSystemException;
2023-03-18 17:34:37 +08:00
use SPC\exception\RuntimeException;
2023-03-29 21:39:36 +08:00
use SPC\exception\WrongUsageException;
2023-03-18 17:34:37 +08:00
use Symfony\Component\Console\Input\InputInterface;
/**
* 用于生成对应系统环境的 Builder 对象的类
*/
class BuilderProvider
{
/**
* @throws FileSystemException
2023-03-18 17:34:37 +08:00
* @throws RuntimeException
* @throws WrongUsageException
2023-03-18 17:34:37 +08:00
*/
public static function makeBuilderByInput(InputInterface $input): BuilderBase
{
return match (PHP_OS_FAMILY) {
// 'Windows' => new WindowsBuilder(
// binary_sdk_dir: $input->getOption('with-sdk-binary-dir'),
// vs_ver: $input->getOption('vs-ver'),
// arch: $input->getOption('arch'),
// ),
'Darwin' => new MacOSBuilder($input->getOptions()),
'Linux' => new LinuxBuilder($input->getOptions()),
2023-10-15 13:07:13 +08:00
'BSD' => new BSDBuilder($input->getOptions()),
2023-03-29 21:39:36 +08:00
default => throw new WrongUsageException('Current OS "' . PHP_OS_FAMILY . '" is not supported yet'),
2023-03-18 17:34:37 +08:00
};
}
}