2023-03-18 17:32:21 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
namespace SPC\builder;
|
|
|
|
|
|
2024-01-03 15:57:05 +08:00
|
|
|
use SPC\exception\ExceptionHandler;
|
2023-03-18 17:32:21 +08:00
|
|
|
use SPC\exception\FileSystemException;
|
|
|
|
|
use SPC\exception\RuntimeException;
|
2023-04-30 12:42:19 +08:00
|
|
|
use SPC\exception\WrongUsageException;
|
2023-03-18 17:32:21 +08:00
|
|
|
use SPC\store\Config;
|
|
|
|
|
use SPC\store\FileSystem;
|
2023-07-28 00:02:49 +08:00
|
|
|
use SPC\store\SourceExtractor;
|
2023-04-15 18:46:21 +08:00
|
|
|
use SPC\util\CustomExt;
|
2023-03-18 17:32:21 +08:00
|
|
|
use SPC\util\DependencyUtil;
|
|
|
|
|
|
|
|
|
|
abstract class BuilderBase
|
|
|
|
|
{
|
2023-08-20 19:51:45 +08:00
|
|
|
/** @var int Concurrency */
|
2023-03-18 17:32:21 +08:00
|
|
|
public int $concurrency = 1;
|
|
|
|
|
|
2023-08-20 19:51:45 +08:00
|
|
|
/** @var array<string, LibraryBase> libraries */
|
2023-03-18 17:32:21 +08:00
|
|
|
protected array $libs = [];
|
|
|
|
|
|
2023-08-20 19:51:45 +08:00
|
|
|
/** @var array<string, Extension> extensions */
|
2023-03-18 17:32:21 +08:00
|
|
|
protected array $exts = [];
|
|
|
|
|
|
2023-08-20 19:51:45 +08:00
|
|
|
/** @var bool compile libs only (just mark it) */
|
2023-03-18 17:32:21 +08:00
|
|
|
protected bool $libs_only = false;
|
|
|
|
|
|
2023-08-20 19:51:45 +08:00
|
|
|
/** @var array<string, mixed> compile options */
|
|
|
|
|
protected array $options = [];
|
2023-05-10 21:59:33 +08:00
|
|
|
|
2024-01-03 15:57:05 +08:00
|
|
|
/** @var string patch point name */
|
|
|
|
|
protected string $patch_point = '';
|
|
|
|
|
|
2023-03-18 17:32:21 +08:00
|
|
|
/**
|
2023-08-20 19:51:45 +08:00
|
|
|
* Build libraries
|
2023-03-18 17:32:21 +08:00
|
|
|
*
|
2024-01-07 00:39:36 +08:00
|
|
|
* @param array<string> $sorted_libraries Libraries to build (if not empty, must sort first)
|
2023-03-18 17:32:21 +08:00
|
|
|
* @throws FileSystemException
|
2023-04-30 12:42:19 +08:00
|
|
|
* @throws RuntimeException
|
|
|
|
|
* @throws WrongUsageException
|
2023-03-18 17:32:21 +08:00
|
|
|
*/
|
2024-01-07 00:39:36 +08:00
|
|
|
public function buildLibs(array $sorted_libraries): void
|
2023-03-18 17:32:21 +08:00
|
|
|
{
|
2023-08-20 19:51:45 +08:00
|
|
|
// search all supported libs
|
2023-03-18 17:32:21 +08:00
|
|
|
$support_lib_list = [];
|
|
|
|
|
$classes = FileSystem::getClassesPsr4(
|
|
|
|
|
ROOT_DIR . '/src/SPC/builder/' . osfamily2dir() . '/library',
|
|
|
|
|
'SPC\\builder\\' . osfamily2dir() . '\\library'
|
|
|
|
|
);
|
|
|
|
|
foreach ($classes as $class) {
|
|
|
|
|
if (defined($class . '::NAME') && $class::NAME !== 'unknown' && Config::getLib($class::NAME) !== null) {
|
|
|
|
|
$support_lib_list[$class::NAME] = $class;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-20 19:51:45 +08:00
|
|
|
// if no libs specified, compile all supported libs
|
2024-01-07 00:39:36 +08:00
|
|
|
if ($sorted_libraries === [] && $this->isLibsOnly()) {
|
2023-03-18 17:32:21 +08:00
|
|
|
$libraries = array_keys($support_lib_list);
|
2024-01-07 00:39:36 +08:00
|
|
|
$sorted_libraries = DependencyUtil::getLibsByDeps($libraries);
|
2023-03-18 17:32:21 +08:00
|
|
|
}
|
2023-08-20 19:51:45 +08:00
|
|
|
|
|
|
|
|
// pkg-config must be compiled first, whether it is specified or not
|
2024-01-07 00:39:36 +08:00
|
|
|
if (!in_array('pkg-config', $sorted_libraries)) {
|
|
|
|
|
array_unshift($sorted_libraries, 'pkg-config');
|
2023-05-10 02:04:08 +08:00
|
|
|
}
|
2023-03-18 17:32:21 +08:00
|
|
|
|
2023-08-20 19:51:45 +08:00
|
|
|
// add lib object for builder
|
2024-01-07 00:39:36 +08:00
|
|
|
foreach ($sorted_libraries as $library) {
|
2023-08-20 19:51:45 +08:00
|
|
|
// if some libs are not supported (but in config "lib.json", throw exception)
|
2023-03-18 17:32:21 +08:00
|
|
|
if (!isset($support_lib_list[$library])) {
|
2023-11-12 17:00:27 +08:00
|
|
|
throw new WrongUsageException('library [' . $library . '] is in the lib.json list but not supported to compile, but in the future I will support it!');
|
2023-03-18 17:32:21 +08:00
|
|
|
}
|
|
|
|
|
$lib = new ($support_lib_list[$library])($this);
|
|
|
|
|
$this->addLib($lib);
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-20 19:51:45 +08:00
|
|
|
// calculate and check dependencies
|
2023-03-18 17:32:21 +08:00
|
|
|
foreach ($this->libs as $lib) {
|
|
|
|
|
$lib->calcDependency();
|
|
|
|
|
}
|
2023-04-30 12:42:19 +08:00
|
|
|
|
2024-01-03 15:57:05 +08:00
|
|
|
// patch point
|
|
|
|
|
$this->emitPatchPoint('before-libs-extract');
|
|
|
|
|
|
2023-08-20 19:51:45 +08:00
|
|
|
// extract sources
|
2024-01-07 00:39:36 +08:00
|
|
|
SourceExtractor::initSource(libs: $sorted_libraries);
|
2023-04-30 12:42:19 +08:00
|
|
|
|
2024-01-03 15:57:05 +08:00
|
|
|
$this->emitPatchPoint('after-libs-extract');
|
|
|
|
|
|
2023-08-20 19:51:45 +08:00
|
|
|
// build all libs
|
2023-03-18 17:32:21 +08:00
|
|
|
foreach ($this->libs as $lib) {
|
2023-09-11 23:44:30 +08:00
|
|
|
match ($lib->tryBuild($this->getOption('rebuild', false))) {
|
2023-03-18 17:32:21 +08:00
|
|
|
BUILD_STATUS_OK => logger()->info('lib [' . $lib::NAME . '] build success'),
|
|
|
|
|
BUILD_STATUS_ALREADY => logger()->notice('lib [' . $lib::NAME . '] already built'),
|
|
|
|
|
BUILD_STATUS_FAILED => logger()->error('lib [' . $lib::NAME . '] build failed'),
|
|
|
|
|
default => logger()->warning('lib [' . $lib::NAME . '] build status unknown'),
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2023-08-20 19:51:45 +08:00
|
|
|
* Add library to build.
|
2023-03-18 17:32:21 +08:00
|
|
|
*
|
2023-08-20 19:51:45 +08:00
|
|
|
* @param LibraryBase $library Library object
|
2023-03-18 17:32:21 +08:00
|
|
|
*/
|
|
|
|
|
public function addLib(LibraryBase $library): void
|
|
|
|
|
{
|
|
|
|
|
$this->libs[$library::NAME] = $library;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2023-08-20 19:51:45 +08:00
|
|
|
* Get library object by name.
|
2023-03-18 17:32:21 +08:00
|
|
|
*/
|
|
|
|
|
public function getLib(string $name): ?LibraryBase
|
|
|
|
|
{
|
|
|
|
|
return $this->libs[$name] ?? null;
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-23 00:37:28 +08:00
|
|
|
/**
|
|
|
|
|
* Get all library objects.
|
|
|
|
|
*
|
|
|
|
|
* @return LibraryBase[]
|
|
|
|
|
*/
|
|
|
|
|
public function getLibs(): array
|
|
|
|
|
{
|
|
|
|
|
return $this->libs;
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-18 17:32:21 +08:00
|
|
|
/**
|
2023-08-20 19:51:45 +08:00
|
|
|
* Add extension to build.
|
2023-03-18 17:32:21 +08:00
|
|
|
*/
|
|
|
|
|
public function addExt(Extension $extension): void
|
|
|
|
|
{
|
|
|
|
|
$this->exts[$extension->getName()] = $extension;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2023-08-20 19:51:45 +08:00
|
|
|
* Get extension object by name.
|
2023-03-18 17:32:21 +08:00
|
|
|
*/
|
|
|
|
|
public function getExt(string $name): ?Extension
|
|
|
|
|
{
|
|
|
|
|
return $this->exts[$name] ?? null;
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-24 23:49:52 +08:00
|
|
|
/**
|
2023-08-20 19:51:45 +08:00
|
|
|
* Get all extension objects.
|
2023-07-24 23:49:52 +08:00
|
|
|
*
|
|
|
|
|
* @return Extension[]
|
|
|
|
|
*/
|
|
|
|
|
public function getExts(): array
|
|
|
|
|
{
|
|
|
|
|
return $this->exts;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2023-10-23 00:37:28 +08:00
|
|
|
* Check if there is a cpp extensions or libraries.
|
2023-07-24 23:49:52 +08:00
|
|
|
*
|
|
|
|
|
* @throws FileSystemException
|
|
|
|
|
* @throws WrongUsageException
|
|
|
|
|
*/
|
2023-10-23 00:37:28 +08:00
|
|
|
public function hasCpp(): bool
|
2023-07-24 23:49:52 +08:00
|
|
|
{
|
|
|
|
|
// judge cpp-extension
|
|
|
|
|
$exts = array_keys($this->getExts());
|
|
|
|
|
foreach ($exts as $ext) {
|
|
|
|
|
if (Config::getExt($ext, 'cpp-extension', false) === true) {
|
2023-10-14 14:06:09 +08:00
|
|
|
return true;
|
2023-07-24 23:49:52 +08:00
|
|
|
}
|
|
|
|
|
}
|
2023-10-23 00:37:28 +08:00
|
|
|
$libs = array_keys($this->getLibs());
|
|
|
|
|
foreach ($libs as $lib) {
|
|
|
|
|
if (Config::getLib($lib, 'cpp-library', false) === true) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-10-14 14:06:09 +08:00
|
|
|
return false;
|
2023-07-24 23:49:52 +08:00
|
|
|
}
|
|
|
|
|
|
2023-03-18 17:32:21 +08:00
|
|
|
/**
|
2023-08-20 19:51:45 +08:00
|
|
|
* Set libs only mode.
|
2023-03-18 17:32:21 +08:00
|
|
|
*/
|
|
|
|
|
public function setLibsOnly(bool $status = true): void
|
|
|
|
|
{
|
|
|
|
|
$this->libs_only = $status;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2023-08-20 19:51:45 +08:00
|
|
|
* Verify the list of "ext" extensions for validity and declare an Extension object to check the dependencies of the extensions.
|
2023-03-18 17:32:21 +08:00
|
|
|
*
|
|
|
|
|
* @throws FileSystemException
|
|
|
|
|
* @throws RuntimeException
|
2023-07-28 23:44:14 +08:00
|
|
|
* @throws \ReflectionException
|
|
|
|
|
* @throws WrongUsageException
|
2023-03-18 17:32:21 +08:00
|
|
|
*/
|
|
|
|
|
public function proveExts(array $extensions): void
|
|
|
|
|
{
|
2023-04-15 18:46:21 +08:00
|
|
|
CustomExt::loadCustomExt();
|
2024-01-03 15:57:05 +08:00
|
|
|
$this->emitPatchPoint('before-php-extract');
|
2023-07-28 00:02:49 +08:00
|
|
|
SourceExtractor::initSource(sources: ['php-src']);
|
2024-01-03 15:57:05 +08:00
|
|
|
$this->emitPatchPoint('after-php-extract');
|
2023-04-30 12:42:19 +08:00
|
|
|
if ($this->getPHPVersionID() >= 80000) {
|
2024-01-03 15:57:05 +08:00
|
|
|
$this->emitPatchPoint('before-micro-extract');
|
2023-07-28 00:02:49 +08:00
|
|
|
SourceExtractor::initSource(sources: ['micro']);
|
2024-01-03 15:57:05 +08:00
|
|
|
$this->emitPatchPoint('after-micro-extract');
|
2023-04-30 12:42:19 +08:00
|
|
|
}
|
2024-01-03 15:57:05 +08:00
|
|
|
$this->emitPatchPoint('before-exts-extract');
|
2023-07-28 00:02:49 +08:00
|
|
|
SourceExtractor::initSource(exts: $extensions);
|
2024-01-03 15:57:05 +08:00
|
|
|
$this->emitPatchPoint('after-exts-extract');
|
2023-03-18 17:32:21 +08:00
|
|
|
foreach ($extensions as $extension) {
|
2023-04-15 18:46:21 +08:00
|
|
|
$class = CustomExt::getExtClass($extension);
|
|
|
|
|
$ext = new $class($extension, $this);
|
2023-03-18 17:32:21 +08:00
|
|
|
$this->addExt($ext);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach ($this->exts as $ext) {
|
|
|
|
|
$ext->checkDependency();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2023-08-20 19:51:45 +08:00
|
|
|
* Start to build PHP
|
2023-03-18 17:32:21 +08:00
|
|
|
*
|
2023-08-20 19:51:45 +08:00
|
|
|
* @param int $build_target Build target, see BUILD_TARGET_*
|
2023-03-18 17:32:21 +08:00
|
|
|
*/
|
2023-08-20 19:51:45 +08:00
|
|
|
abstract public function buildPHP(int $build_target = BUILD_TARGET_NONE);
|
2023-03-18 17:32:21 +08:00
|
|
|
|
|
|
|
|
/**
|
2023-08-20 19:51:45 +08:00
|
|
|
* Generate extension enable arguments for configure.
|
|
|
|
|
* e.g. --enable-mbstring
|
2023-03-18 17:32:21 +08:00
|
|
|
*
|
|
|
|
|
* @throws FileSystemException
|
2023-07-28 00:02:49 +08:00
|
|
|
* @throws WrongUsageException
|
2023-03-18 17:32:21 +08:00
|
|
|
*/
|
|
|
|
|
public function makeExtensionArgs(): string
|
|
|
|
|
{
|
|
|
|
|
$ret = [];
|
|
|
|
|
foreach ($this->exts as $ext) {
|
2023-04-15 18:46:21 +08:00
|
|
|
$ret[] = trim($ext->getConfigureArg());
|
2023-03-18 17:32:21 +08:00
|
|
|
}
|
2024-01-03 10:31:21 +08:00
|
|
|
logger()->debug('Using configure: ' . implode(' ', $ret));
|
2023-03-18 17:32:21 +08:00
|
|
|
return implode(' ', $ret);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2023-08-20 19:51:45 +08:00
|
|
|
* Get libs only mode.
|
2023-03-18 17:32:21 +08:00
|
|
|
*/
|
|
|
|
|
public function isLibsOnly(): bool
|
|
|
|
|
{
|
|
|
|
|
return $this->libs_only;
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-03 20:47:24 +08:00
|
|
|
/**
|
2023-08-20 19:51:45 +08:00
|
|
|
* Get PHP Version ID from php-src/main/php_version.h
|
2023-09-30 08:56:37 +02:00
|
|
|
*
|
|
|
|
|
* @throws RuntimeException
|
|
|
|
|
* @throws WrongUsageException
|
2023-04-03 20:47:24 +08:00
|
|
|
*/
|
|
|
|
|
public function getPHPVersionID(): int
|
|
|
|
|
{
|
2023-09-30 08:56:37 +02:00
|
|
|
if (!file_exists(SOURCE_PATH . '/php-src/main/php_version.h')) {
|
|
|
|
|
throw new WrongUsageException('PHP source files are not available, you need to download them first');
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-03 20:47:24 +08:00
|
|
|
$file = file_get_contents(SOURCE_PATH . '/php-src/main/php_version.h');
|
2023-09-30 08:56:37 +02:00
|
|
|
if (preg_match('/PHP_VERSION_ID (\d+)/', $file, $match) !== 0) {
|
|
|
|
|
return intval($match[1]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
throw new RuntimeException('PHP version file format is malformed, please remove it and download again');
|
2023-04-03 20:47:24 +08:00
|
|
|
}
|
|
|
|
|
|
2023-12-15 01:31:01 +08:00
|
|
|
public function getPHPVersion(): string
|
|
|
|
|
{
|
|
|
|
|
if (!file_exists(SOURCE_PATH . '/php-src/main/php_version.h')) {
|
|
|
|
|
throw new WrongUsageException('PHP source files are not available, you need to download them first');
|
|
|
|
|
}
|
|
|
|
|
$file = file_get_contents(SOURCE_PATH . '/php-src/main/php_version.h');
|
|
|
|
|
if (preg_match('/PHP_VERSION "(.*)"/', $file, $match) !== 0) {
|
|
|
|
|
return $match[1];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
throw new RuntimeException('PHP version file format is malformed, please remove it and download again');
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-20 19:51:45 +08:00
|
|
|
/**
|
|
|
|
|
* Get build type name string to display.
|
|
|
|
|
*
|
|
|
|
|
* @param int $type Build target type
|
|
|
|
|
*/
|
2023-04-23 20:31:58 +08:00
|
|
|
public function getBuildTypeName(int $type): string
|
|
|
|
|
{
|
|
|
|
|
$ls = [];
|
|
|
|
|
if (($type & BUILD_TARGET_CLI) === BUILD_TARGET_CLI) {
|
|
|
|
|
$ls[] = 'cli';
|
|
|
|
|
}
|
|
|
|
|
if (($type & BUILD_TARGET_MICRO) === BUILD_TARGET_MICRO) {
|
|
|
|
|
$ls[] = 'micro';
|
|
|
|
|
}
|
|
|
|
|
if (($type & BUILD_TARGET_FPM) === BUILD_TARGET_FPM) {
|
|
|
|
|
$ls[] = 'fpm';
|
|
|
|
|
}
|
2023-08-21 09:30:46 +02:00
|
|
|
if (($type & BUILD_TARGET_EMBED) === BUILD_TARGET_EMBED) {
|
|
|
|
|
$ls[] = 'embed';
|
|
|
|
|
}
|
2023-04-23 20:31:58 +08:00
|
|
|
return implode(', ', $ls);
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-20 19:51:45 +08:00
|
|
|
/**
|
|
|
|
|
* Get builder options (maybe changed by user)
|
|
|
|
|
*
|
|
|
|
|
* @param string $key Option key
|
|
|
|
|
* @param mixed $default If not exists, return this value
|
|
|
|
|
*/
|
|
|
|
|
public function getOption(string $key, mixed $default = null): mixed
|
|
|
|
|
{
|
|
|
|
|
return $this->options[$key] ?? $default;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get all builder options
|
|
|
|
|
*/
|
|
|
|
|
public function getOptions(): array
|
|
|
|
|
{
|
|
|
|
|
return $this->options;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set builder options if not exists.
|
|
|
|
|
*/
|
|
|
|
|
public function setOptionIfNotExist(string $key, mixed $value): void
|
|
|
|
|
{
|
|
|
|
|
if (!isset($this->options[$key])) {
|
|
|
|
|
$this->options[$key] = $value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set builder options.
|
|
|
|
|
*/
|
|
|
|
|
public function setOption(string $key, mixed $value): void
|
2023-05-10 21:59:33 +08:00
|
|
|
{
|
2023-08-20 19:51:45 +08:00
|
|
|
$this->options[$key] = $value;
|
2023-05-10 21:59:33 +08:00
|
|
|
}
|
|
|
|
|
|
2023-10-24 12:21:36 +02:00
|
|
|
public function getEnvString(array $vars = ['cc', 'cxx', 'ar', 'ld']): string
|
|
|
|
|
{
|
|
|
|
|
$env = [];
|
|
|
|
|
foreach ($vars as $var) {
|
|
|
|
|
$var = strtoupper($var);
|
|
|
|
|
if (getenv($var) !== false) {
|
|
|
|
|
$env[] = "{$var}=" . getenv($var);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return implode(' ', $env);
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-03 15:57:05 +08:00
|
|
|
/**
|
|
|
|
|
* Get builder patch point name.
|
|
|
|
|
*/
|
|
|
|
|
public function getPatchPoint(): string
|
|
|
|
|
{
|
|
|
|
|
return $this->patch_point;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function emitPatchPoint(string $point_name): void
|
|
|
|
|
{
|
|
|
|
|
$this->patch_point = $point_name;
|
|
|
|
|
if (($patches = $this->getOption('with-added-patch', [])) === []) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach ($patches as $patch) {
|
|
|
|
|
try {
|
|
|
|
|
if (!file_exists($patch)) {
|
|
|
|
|
throw new RuntimeException("Additional patch script file {$patch} not found!");
|
|
|
|
|
}
|
|
|
|
|
logger()->debug('Running additional patch script: ' . $patch);
|
|
|
|
|
require $patch;
|
|
|
|
|
} catch (\Throwable $e) {
|
|
|
|
|
logger()->critical('Patch script ' . $patch . ' failed to run.');
|
|
|
|
|
if ($this->getOption('debug')) {
|
|
|
|
|
ExceptionHandler::getInstance()->handle($e);
|
|
|
|
|
} else {
|
|
|
|
|
logger()->critical('Please check with --debug option to see more details.');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-18 17:32:21 +08:00
|
|
|
/**
|
2023-08-20 19:51:45 +08:00
|
|
|
* Check if all libs are downloaded.
|
|
|
|
|
* If not, throw exception.
|
2023-03-18 17:32:21 +08:00
|
|
|
*
|
|
|
|
|
* @throws RuntimeException
|
|
|
|
|
*/
|
|
|
|
|
protected function checkLibsSource(): void
|
|
|
|
|
{
|
|
|
|
|
$not_downloaded = [];
|
|
|
|
|
foreach ($this->libs as $lib) {
|
|
|
|
|
if (!file_exists($lib->getSourceDir())) {
|
|
|
|
|
$not_downloaded[] = $lib::NAME;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if ($not_downloaded !== []) {
|
|
|
|
|
throw new RuntimeException(
|
|
|
|
|
'"' . implode(', ', $not_downloaded) .
|
|
|
|
|
'" totally ' . count($not_downloaded) .
|
|
|
|
|
' source' . (count($not_downloaded) === 1 ? '' : 's') .
|
|
|
|
|
' not downloaded, maybe you need to "fetch" ' . (count($not_downloaded) === 1 ? 'it' : 'them') . ' first?'
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|