diff --git a/config/ext.json b/config/ext.json index 664dba9f..35d1ea95 100644 --- a/config/ext.json +++ b/config/ext.json @@ -36,9 +36,9 @@ }, "enchant": { "type": "builtin", - "arg-type": "with", + "arg-type": "custom", "lib-depends": [ - "enchant2" + "enchant" ] }, "exif": { diff --git a/config/lib.json b/config/lib.json index ada177ab..5a535084 100644 --- a/config/lib.json +++ b/config/lib.json @@ -49,9 +49,7 @@ "brotli", "nghttp2", "zstd", - "openssl", - "idn2", - "psl" + "openssl" ], "lib-suggests-windows": [ "zlib", @@ -120,6 +118,35 @@ "zlib" ] }, + "enchant": { + "source": "enchant", + "static-libs-unix":[ + "libenchant-2.a" + ], + "lib-depends": [ + "glib" + ], + "headers": [ + "enchant-2" + ] + }, + "glib": { + "source": "glib", + "static-libs-unix": [ + "libglib-2.0.a", + "libgio-2.0.a", + "libgmodule-2.0.a", + "libgobject-2.0.a", + "libgthread-2.0.a" + ], + "bin-depends-unix": [ + "meson", + "ninja" + ], + "headers": [ + "glib-2.0" + ] + }, "libssh2": { "source": "libssh2", "static-libs-unix": [ @@ -158,7 +185,6 @@ "libiconv" ], "lib-suggests": [ - "icu", "xz", "zlib" ], diff --git a/src/SPC/util/DependencyUtil.php b/src/SPC/util/DependencyUtil.php index d2532115..e28516b5 100644 --- a/src/SPC/util/DependencyUtil.php +++ b/src/SPC/util/DependencyUtil.php @@ -67,7 +67,39 @@ class DependencyUtil self::visitLibDeps($lib, $visited, $sorted); } } - return $sorted; + + $sorted_suggests = []; + $visited_suggests = []; + $final = []; + foreach ($libs as $lib) { + if (!isset($visited_suggests[$lib])) { + self::visitLibAllDeps($lib, $visited_suggests, $sorted_suggests); + } + } + foreach ($sorted_suggests as $suggest) { + if (in_array($suggest, $sorted)) { + $final[] = $suggest; + } + } + return $final; + } + + /** + * @throws RuntimeException + * @throws FileSystemException + */ + private static function visitLibAllDeps(string $lib_name, array &$visited, array &$sorted): void + { + // 如果已经识别到了,那就不管 + if (isset($visited[$lib_name])) { + return; + } + $visited[$lib_name] = true; + // 遍历该依赖的所有依赖(此处的 getLib 如果检测到当前库不存在的话,会抛出异常) + foreach (array_merge(Config::getLib($lib_name, 'lib-depends', []), Config::getLib($lib_name, 'lib-suggests', [])) as $dep) { + self::visitLibDeps($dep, $visited, $sorted); + } + $sorted[] = $lib_name; } /**