137 lines
4.3 KiB
Python
137 lines
4.3 KiB
Python
import os
|
|
|
|
|
|
def normpath(path):
|
|
return path.replace("\\", "/")
|
|
|
|
|
|
local_app_data_dir = os.environ.get("LOCALAPPDATA")
|
|
home_dir = os.path.expanduser("~")
|
|
|
|
cur_file_path = os.path.dirname(os.path.abspath(__file__))
|
|
project_root_path = os.path.dirname(cur_file_path)
|
|
|
|
user_home = os.path.expanduser("~")
|
|
|
|
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",
|
|
)
|
|
)
|
|
utfcpp_path = normpath(
|
|
os.path.join(MetasequoiaImeServer_root_path, "MetasequoiaImeEngine", "utfcpp", "source")
|
|
)
|
|
webview2_path = normpath(
|
|
os.path.join(
|
|
user_home,
|
|
".nuget",
|
|
"packages",
|
|
"microsoft.web.webview2",
|
|
"1.0.3240.44",
|
|
"build",
|
|
"native",
|
|
"include",
|
|
)
|
|
)
|
|
wim_path = normpath(
|
|
os.path.join(
|
|
user_home,
|
|
".nuget",
|
|
"packages",
|
|
"microsoft.windows.implementationlibrary",
|
|
"1.0.240803.1",
|
|
"include",
|
|
)
|
|
)
|
|
boost_path = normpath(os.path.join(user_home, "scoop", "apps", "boost", "current"))
|
|
sciter_path = normpath(os.path.join(os.path.dirname(project_root_path) , "sciter-js-sdk-main", "include"))
|
|
|
|
#
|
|
# project_root/.clangd
|
|
# line 7, 8, 9, 11, 13, 15
|
|
#
|
|
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:
|
|
lines = f.readlines()
|
|
lines[6] = f' "-I{MetasequoiaImeServer_root_path}",\n'
|
|
lines[7] = f' "-I{MetasequoiaImeServer_src_path}",\n'
|
|
lines[8] = f' "-I{vcpkg_include_path}",\n'
|
|
lines[10] = f' "-I{utfcpp_path}",\n'
|
|
lines[12] = f' "-I{boost_path}",\n'
|
|
lines[14] = f' "-I{sciter_path}",\n'
|
|
with open(dot_clangd_output_file, "w", encoding="utf-8") as f:
|
|
f.writelines(lines)
|
|
|
|
#
|
|
# project_root/CMakeLists.txt
|
|
#
|
|
CMakeLists_file = os.path.join(
|
|
MetasequoiaImeServer_root_path, "scripts", "config_files", "CMakeLists.txt"
|
|
)
|
|
CMakeLists_output_file = os.path.join(MetasequoiaImeServer_root_path, "CMakeLists.txt")
|
|
with open(CMakeLists_file, "r", encoding="utf-8") as f:
|
|
lines = f.readlines()
|
|
lines[8] = f'set(Boost_ROOT "{boost_path}")\n'
|
|
with open(CMakeLists_output_file, "w", encoding="utf-8") as f:
|
|
f.writelines(lines)
|
|
|
|
#
|
|
# CMakePresets.json
|
|
#
|
|
CMakePresets_file = os.path.join(
|
|
MetasequoiaImeServer_root_path, "scripts", "config_files", "CMakePresets.json"
|
|
)
|
|
CMakePresets_file_output_file = os.path.join(
|
|
MetasequoiaImeServer_root_path, "CMakePresets.json"
|
|
)
|
|
with open(CMakePresets_file, "r", encoding="utf-8") as f:
|
|
lines = f.readlines()
|
|
lines[8] = f' "VCPKG_ROOT": "{normpath(user_home)}/scoop/apps/vcpkg/current/"\n'
|
|
lines[11] = (
|
|
f' "CMAKE_TOOLCHAIN_FILE": "{normpath(user_home)}/scoop/apps/vcpkg/current/scripts/buildsystems/vcpkg.cmake",\n'
|
|
)
|
|
with open(CMakePresets_file_output_file, "w", encoding="utf-8") as f:
|
|
f.writelines(lines)
|
|
|
|
#
|
|
# project_root/tests/CMakeLists.txt
|
|
#
|
|
Tests_CMakeLists_file = os.path.join(
|
|
MetasequoiaImeServer_root_path, "scripts", "config_files", "tests", "CMakeLists.txt"
|
|
)
|
|
Tests_CMakeLists_output_file = os.path.join(
|
|
MetasequoiaImeServer_root_path, "tests", "CMakeLists.txt"
|
|
)
|
|
with open(Tests_CMakeLists_file, "r", encoding="utf-8") as f:
|
|
lines = f.readlines()
|
|
lines[10] = f'set(Boost_ROOT "{boost_path}")\n'
|
|
with open(Tests_CMakeLists_output_file, "w", encoding="utf-8") as f:
|
|
f.writelines(lines)
|
|
|
|
#
|
|
# project_root/tests/CMakePresets.json
|
|
#
|
|
Tests_CMakePresets_file = os.path.join(
|
|
MetasequoiaImeServer_root_path, "scripts", "config_files", "tests", "CMakePresets.json"
|
|
)
|
|
Tests_CMakePresets_output_file = os.path.join(
|
|
MetasequoiaImeServer_root_path, "tests", "CMakePresets.json"
|
|
)
|
|
with open(Tests_CMakePresets_file, "r", encoding="utf-8") as f:
|
|
lines = f.readlines()
|
|
lines[8] = f' "VCPKG_ROOT": "{normpath(user_home)}/scoop/apps/vcpkg/current/"\n'
|
|
lines[11] = (
|
|
f' "CMAKE_TOOLCHAIN_FILE": "{normpath(user_home)}/scoop/apps/vcpkg/current/scripts/buildsystems/vcpkg.cmake",\n'
|
|
)
|
|
with open(Tests_CMakePresets_output_file, "w", encoding="utf-8") as f:
|
|
f.writelines(lines)
|