`vendor/MetasequoiaImeEngine` submodule 改为 `engine/` 目录,导入的是 product-lock.json 原本钉住的提交 c810d201,逐文件核对过 blob,因此这是一次 搬迁而不是引擎升级。引擎自己的嵌套 submodule(googlepinyinime-rev、utfcpp、 miniaudio)按各自 gitlink 一并展开,来源与提交见 engine/UPSTREAM.md。 Windows 专门化裁掉了不属于本产品的部分:whisper.cpp 与本地推理 provider、 macOS 示例宿主、整个 dictionary/ 建库流水线、上游 CI 与 release-please 配置。 词库仍按 product-lock.json 在构建时取发布产物。 引擎不再进 product-lock.json:没有 gitlink 就没有可比对的东西,锁里写一个上游 commit 等于宣称这棵树仍等于上游,而第一个 Windows 专门化改动落地时这句话就假了。 verify-contracts / verify-checkout 随之移除,verify-published 保留。 CI 与工具链:引擎源码并入根 scripts/format.sh(删掉引擎自己的那份,避免两套排除 列表分叉);引擎 voice.yml 里的 silero_vad.onnx 摘要校验移到本仓 lock job; engine-bump-triage 工作流与其测试删除;gitsubmodule 的 dependabot 频率由 daily 改为 monthly。 README、README.en、AGENTS.md、CONTRIBUTING、docs/product-release.md 及各子目录 文档同步说明新的位置与边界。
119 lines
3.9 KiB
Python
119 lines
3.9 KiB
Python
import os
|
|
import re
|
|
|
|
|
|
def normpath(path):
|
|
return path.replace("\\", "/")
|
|
|
|
|
|
cur_file_path = os.path.dirname(os.path.abspath(__file__))
|
|
project_root_path = os.path.dirname(cur_file_path)
|
|
|
|
user_home = os.path.expanduser("~")
|
|
|
|
# vcpkg location. Prefer the VCPKG_ROOT environment variable so that installs
|
|
# outside Scoop work as well; fall back to the historical Scoop path.
|
|
vcpkg_root = normpath(
|
|
os.environ.get("VCPKG_ROOT") or os.path.join(user_home, "scoop", "apps", "vcpkg", "current")
|
|
).rstrip("/")
|
|
|
|
MetasequoiaImeServer_root_path = normpath(project_root_path)
|
|
MetasequoiaImeServer_src_path = normpath(os.path.join(MetasequoiaImeServer_root_path, "src"))
|
|
vcpkg_include_path = normpath(
|
|
os.path.join(
|
|
MetasequoiaImeServer_root_path,
|
|
"build",
|
|
"vcpkg_installed",
|
|
"x64-windows",
|
|
"include",
|
|
)
|
|
)
|
|
monorepo_root_path = normpath(os.path.dirname(project_root_path))
|
|
engine_path = normpath(os.path.join(monorepo_root_path, "engine"))
|
|
utfcpp_path = normpath(os.path.join(engine_path, "utfcpp", "source"))
|
|
webview2_path = normpath(
|
|
os.path.join(
|
|
user_home,
|
|
".nuget",
|
|
"packages",
|
|
"microsoft.web.webview2",
|
|
"1.0.3240.44",
|
|
"build",
|
|
"native",
|
|
"include",
|
|
)
|
|
)
|
|
wil_path = normpath(
|
|
os.path.join(
|
|
user_home,
|
|
".nuget",
|
|
"packages",
|
|
"microsoft.windows.implementationlibrary",
|
|
"1.0.240803.1",
|
|
"include",
|
|
)
|
|
)
|
|
# Boost location. CMakeLists.txt already honours the BOOST_ROOT environment
|
|
# variable; mirror that here instead of assuming a Scoop install.
|
|
boost_path = normpath(
|
|
os.environ.get("BOOST_ROOT") or os.path.join(user_home, "scoop", "apps", "boost", "current")
|
|
).rstrip("/")
|
|
|
|
#
|
|
# project_root/.clangd
|
|
#
|
|
# The template carries @NAME@ placeholders rather than fixed line numbers. The
|
|
# previous version addressed lines by index, and the indices had drifted: the
|
|
# Boost path was written over the WebView2 include and the Sciter path over a
|
|
# comment, which left clangd unable to resolve the WebView2 headers.
|
|
#
|
|
clangd_substitutions = {
|
|
"@SERVER_ROOT@": MetasequoiaImeServer_root_path,
|
|
"@SERVER_SRC@": MetasequoiaImeServer_src_path,
|
|
"@VCPKG_INCLUDE@": vcpkg_include_path,
|
|
"@ENGINE_ROOT@": engine_path,
|
|
"@UTFCPP@": utfcpp_path,
|
|
"@VOICE_INCLUDE@": engine_path + "/voice/include",
|
|
"@MINIAUDIO@": engine_path + "/voice/third_party/miniaudio",
|
|
"@GUI_INCLUDE@": monorepo_root_path + "/ui/include",
|
|
"@WEBVIEW2@": webview2_path,
|
|
"@WIL@": wil_path,
|
|
"@BOOST@": boost_path,
|
|
}
|
|
dot_clangd_file = os.path.join(
|
|
MetasequoiaImeServer_root_path, "scripts", "config_files", ".clangd"
|
|
)
|
|
dot_clangd_output_file = os.path.join(MetasequoiaImeServer_root_path, ".clangd")
|
|
with open(dot_clangd_file, "r", encoding="utf-8") as f:
|
|
content = f.read()
|
|
for placeholder, value in clangd_substitutions.items():
|
|
content = content.replace(placeholder, value)
|
|
leftover = re.findall(r"@[A-Z0-9_]+@", content)
|
|
if leftover:
|
|
raise SystemExit(f"unsubstituted placeholders in the .clangd template: {sorted(set(leftover))}")
|
|
with open(dot_clangd_output_file, "w", encoding="utf-8") as f:
|
|
f.write(content)
|
|
|
|
#
|
|
# project_root/CMakePresets.json
|
|
#
|
|
# Rewritten in place rather than copied from a template. The template that used
|
|
# to be copied here had fallen behind the tracked file and would have dropped
|
|
# the vcpkg-release preset that llaunch-release.ps1 depends on.
|
|
#
|
|
CMakePresets_file = os.path.join(MetasequoiaImeServer_root_path, "CMakePresets.json")
|
|
with open(CMakePresets_file, "r", encoding="utf-8") as f:
|
|
content = f.read()
|
|
content = re.sub(
|
|
r'("VCPKG_ROOT":\s*")[^"]*(")',
|
|
lambda m: f"{m.group(1)}{vcpkg_root}/{m.group(2)}",
|
|
content,
|
|
)
|
|
content = re.sub(
|
|
r'("CMAKE_TOOLCHAIN_FILE":\s*")[^"]*(")',
|
|
lambda m: f"{m.group(1)}{vcpkg_root}/scripts/buildsystems/vcpkg.cmake{m.group(2)}",
|
|
content,
|
|
)
|
|
with open(CMakePresets_file, "w", encoding="utf-8") as f:
|
|
f.write(content)
|