turn pkg-config into a package instead of a library

This commit is contained in:
DubbleClick
2025-08-27 14:33:39 +07:00
parent a5351e1546
commit 694fd2f1e0
13 changed files with 168 additions and 100 deletions

View File

@@ -5,7 +5,9 @@ declare(strict_types=1);
namespace SPC\toolchain;
use SPC\builder\linux\SystemUtil;
use SPC\exception\EnvironmentException;
use SPC\exception\WrongUsageException;
use SPC\store\pkg\PkgConfig;
use SPC\util\GlobalEnvManager;
use SPC\util\SPCTarget;
@@ -56,6 +58,10 @@ class ToolchainManager
if (SPCTarget::getLibc() === 'glibc' && SystemUtil::isMuslDist()) {
throw new WrongUsageException('You are linking against glibc dynamically, which is only supported on glibc distros.');
}
if (!is_dir(PkgConfig::getEnvironment()['PATH'])) {
throw new EnvironmentException('Please install pkg-config first. (You can use `doctor` command to install it)');
}
GlobalEnvManager::addPathIfNotExists(PkgConfig::getEnvironment()['PATH']);
$toolchain = getenv('SPC_TOOLCHAIN');
/* @var ToolchainInterface $toolchain */
$instance = new $toolchain();