From 099425abc8c62dd579e458c5de5315ba64ebec26 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 22 Jul 2025 22:46:13 +0800 Subject: [PATCH] Fix c++, check pkg-config exists before calling PkgConfigUtil --- src/SPC/util/SPCConfigUtil.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/SPC/util/SPCConfigUtil.php b/src/SPC/util/SPCConfigUtil.php index 770f8762..bcac8287 100644 --- a/src/SPC/util/SPCConfigUtil.php +++ b/src/SPC/util/SPCConfigUtil.php @@ -86,8 +86,9 @@ class SPCConfigUtil if (SPCTarget::getTargetOS() === 'Darwin') { $libs .= " {$this->getFrameworksString($extensions)}"; } - $libs .= $this->builder->hasCpp() && $this->builder instanceof MacOSBuilder ? ' -lc++' : ' -lstdc++'; - + if ($this->builder->hasCpp()) { + $libs .= $this->builder instanceof MacOSBuilder ? ' -lc++' : ' -lstdc++'; + } if ($this->libs_only_deps) { return [ 'cflags' => trim(getenv('CFLAGS') . ' ' . $cflags), @@ -130,7 +131,13 @@ class SPCConfigUtil // parse pkg-configs foreach ($libraries as $library) { - $pc_cflags = implode(' ', Config::getLib($library, 'pkg-configs', [])); + $pc = Config::getLib($library, 'pkg-configs', []); + foreach ($pc as $file) { + if (!file_exists(BUILD_LIB_PATH . "/pkgconfig/{$file}.pc")) { + throw new WrongUsageException("pkg-config file '{$file}.pc' for lib [{$library}] does not exist in '" . BUILD_LIB_PATH . "/pkgconfig'. Please build it first."); + } + } + $pc_cflags = implode(' ', $pc); if ($pc_cflags !== '') { $pc_cflags = PkgConfigUtil::getCflags($pc_cflags); $includes[] = $pc_cflags;