diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index 9c404dd9..1470ce50 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -4,7 +4,6 @@ declare(strict_types=1); namespace SPC\builder\linux; -use SPC\builder\linux\library\LinuxLibraryBase; use SPC\builder\unix\UnixBuilderBase; use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; @@ -70,35 +69,6 @@ class LinuxBuilder extends UnixBuilderBase f_mkdir(BUILD_INCLUDE_PATH, recursive: true); } - /** - * @throws FileSystemException - * @throws RuntimeException - * @throws WrongUsageException - */ - public function makeAutoconfArgs(string $name, array $libSpecs): string - { - $ret = ''; - foreach ($libSpecs as $libName => $arr) { - $lib = $this->getLib($libName); - if ($lib === null && str_starts_with($libName, 'lib')) { - $lib = $this->getLib(substr($libName, 3)); - } - - $arr = $arr ?? []; - - $disableArgs = $arr[0] ?? null; - $prefix = $arr[1] ?? null; - if ($lib instanceof LinuxLibraryBase) { - logger()->info("{$name} \033[32;1mwith\033[0;1m {$libName} support"); - $ret .= $lib->makeAutoconfEnv($prefix) . ' '; - } else { - logger()->info("{$name} \033[31;1mwithout\033[0;1m {$libName} support"); - $ret .= ($disableArgs ?? "--with-{$libName}=no") . ' '; - } - } - return rtrim($ret); - } - /** * Build PHP from source. * diff --git a/src/SPC/builder/macos/MacOSBuilder.php b/src/SPC/builder/macos/MacOSBuilder.php index d9a0c505..0baf1e7d 100644 --- a/src/SPC/builder/macos/MacOSBuilder.php +++ b/src/SPC/builder/macos/MacOSBuilder.php @@ -44,35 +44,6 @@ class MacOSBuilder extends UnixBuilderBase f_mkdir(BUILD_INCLUDE_PATH, recursive: true); } - /** - * [deprecated] 生成库构建采用的 autoconf 参数列表 - * - * @param string $name 要构建的 lib 库名,传入仅供输出日志 - * @param array $lib_specs 依赖的 lib 库的 autoconf 文件 - */ - public function makeAutoconfArgs(string $name, array $lib_specs): string - { - $ret = ''; - foreach ($lib_specs as $libName => $arr) { - $lib = $this->getLib($libName); - if ($lib === null && str_starts_with($libName, 'lib')) { - $lib = $this->getLib(substr($libName, 3)); - } - - $arr = $arr ?? []; - - $disableArgs = $arr[0] ?? null; - if ($lib instanceof MacOSLibraryBase) { - logger()->info("{$name} \033[32;1mwith\033[0;1m {$libName} support"); - $ret .= '--with-' . $libName . '=yes '; - } else { - logger()->info("{$name} \033[31;1mwithout\033[0;1m {$libName} support"); - $ret .= ($disableArgs ?? "--with-{$libName}=no") . ' '; - } - } - return rtrim($ret); - } - /** * Get dynamically linked macOS frameworks * diff --git a/src/SPC/builder/unix/UnixBuilderBase.php b/src/SPC/builder/unix/UnixBuilderBase.php index 4c8df333..8a6fc5ee 100644 --- a/src/SPC/builder/unix/UnixBuilderBase.php +++ b/src/SPC/builder/unix/UnixBuilderBase.php @@ -5,7 +5,10 @@ declare(strict_types=1); namespace SPC\builder\unix; use SPC\builder\BuilderBase; +use SPC\builder\freebsd\library\BSDLibraryBase; +use SPC\builder\linux\library\LinuxLibraryBase; use SPC\builder\linux\LinuxBuilder; +use SPC\builder\macos\library\MacOSLibraryBase; use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; use SPC\exception\WrongUsageException; @@ -90,6 +93,35 @@ abstract class UnixBuilderBase extends BuilderBase return $extra; } + /** + * @throws FileSystemException + * @throws RuntimeException + * @throws WrongUsageException + */ + public function makeAutoconfArgs(string $name, array $libSpecs): string + { + $ret = ''; + foreach ($libSpecs as $libName => $arr) { + $lib = $this->getLib($libName); + if ($lib === null && str_starts_with($libName, 'lib')) { + $lib = $this->getLib(substr($libName, 3)); + } + + $arr = $arr ?? []; + + $disableArgs = $arr[0] ?? null; + $prefix = $arr[1] ?? null; + if ($lib instanceof LinuxLibraryBase || $lib instanceof MacOSLibraryBase || $lib instanceof BSDLibraryBase) { + logger()->info("{$name} \033[32;1mwith\033[0;1m {$libName} support"); + $ret .= "--with-{$libName}=yes " . $lib->makeAutoconfEnv($prefix) . ' '; + } else { + logger()->info("{$name} \033[31;1mwithout\033[0;1m {$libName} support"); + $ret .= ($disableArgs ?? "--with-{$libName}=no") . ' '; + } + } + return rtrim($ret); + } + public function proveLibs(array $sorted_libraries): void { // search all supported libs diff --git a/src/SPC/builder/unix/library/ngtcp2.php b/src/SPC/builder/unix/library/ngtcp2.php index 654bb8e5..8ea280a8 100644 --- a/src/SPC/builder/unix/library/ngtcp2.php +++ b/src/SPC/builder/unix/library/ngtcp2.php @@ -49,5 +49,10 @@ trait ngtcp2 ->execWithEnv("make -j{$this->builder->concurrency}") ->execWithEnv('make install DESTDIR=' . BUILD_ROOT_PATH); $this->patchPkgconfPrefix(['libngtcp2.pc', 'libngtcp2_crypto_ossl.pc']); + + // on macOS, the static library may contain other static libraries? + // ld: archive member 'libssl.a' not a mach-o file in libngtcp2_crypto_ossl.a + shell()->cd(BUILD_LIB_PATH) + ->exec("ar -t libngtcp2_crypto_ossl.a | grep '\\.a$' | xargs -n1 ar d libngtcp2_crypto_ossl.a"); } }