Skip to content

Commit afe9c7a

Browse files
committed
fix eng -
1 parent f861524 commit afe9c7a

6 files changed

Lines changed: 323 additions & 85 deletions

File tree

‎lib/G2P/Core/Manager.cpp‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <stdcorelib/pimpl.h>
1010

1111
#include <synthrt/Core/Dependency/DependencyGraph.h>
12+
#include <synthrt/Core/Dependency/DependencyResolver.h>
1213
#include <synthrt/Core/Dependency/LevelCompatibilityChecker.h>
1314
#include <synthrt/Core/Support/Logging.h>
1415
#include <synthrt/G2P/Support/ContextUtils.h>
@@ -86,6 +87,14 @@ namespace srt::g2p {
8687
return compatible;
8788
}
8889

90+
/// 解析模块间声明的依赖(package.json 的 dependencies),
91+
/// 填充 resolvedDependencies,使依赖图能按拓扑序初始化包
92+
/// (如 chain 包依赖 multig2p 时,multig2p 必须先于 chain 创建)。
93+
static bool resolveModuleDependencies(std::vector<srt::dependency::ModuleMetadata> &compatibleModules) {
94+
srt::dependency::DependencyResolver resolver;
95+
return resolver.resolveAllDependencies(compatibleModules, {});
96+
}
97+
8998
srt::core::Expected<void> Manager::initialize() {
9099
auto &impl = *static_cast<PackageManager::Impl *>(_impl.get());
91100

@@ -156,6 +165,10 @@ namespace srt::g2p {
156165
"Ord-1: Default context has no compatible modules after Level check; "
157166
"official G2P unavailable");
158167
} else {
168+
if (!resolveModuleDependencies(compatibleModules)) {
169+
return Error(ErrorCode::G2pDependencyError,
170+
"Ord-1: Failed to resolve module dependencies for default context");
171+
}
159172
auto &depGraph = impl.m_contextDependencyGraphs[srt::core::ContextKey("")];
160173
depGraph.clear();
161174
for (const auto &info : compatibleModules)

0 commit comments

Comments
 (0)