add hasCppExtension check

This commit is contained in:
crazywhalecc
2023-07-24 23:49:52 +08:00
parent 0e024a8c43
commit b8e6f9d1be
4 changed files with 40 additions and 3 deletions

View File

@@ -140,6 +140,37 @@ abstract class BuilderBase
return $this->exts[$name] ?? null;
}
/**
* 获取所有要编译的扩展对象
*
* @return Extension[]
*/
public function getExts(): array
{
return $this->exts;
}
/**
* 检查 C++ 扩展是否存在
*
* @throws FileSystemException
* @throws RuntimeException
* @throws WrongUsageException
*/
public function hasCppExtension(): bool
{
// judge cpp-extension
$exts = array_keys($this->getExts());
$cpp = false;
foreach ($exts as $ext) {
if (Config::getExt($ext, 'cpp-extension', false) === true) {
$cpp = true;
break;
}
}
return $cpp;
}
/**
* 设置本次 Builder 是否为仅编译库的模式
*/