From ed33c7e6de1eac92e239b9ef1b4c2f7bb0158118 Mon Sep 17 00:00:00 2001 From: fxliang Date: Sun, 8 Oct 2023 14:07:24 +0800 Subject: [PATCH 1/7] fix typo in WeaselCommon.h --- include/WeaselCommon.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/WeaselCommon.h b/include/WeaselCommon.h index 4ba8ae74f..aa19027af 100644 --- a/include/WeaselCommon.h +++ b/include/WeaselCommon.h @@ -176,7 +176,7 @@ namespace weasel } bool operator==(const Context& ctx) { - if (preedit == ctx.preedit && aux == ctx.aux || cinfo == ctx.cinfo) + if (preedit == ctx.preedit && aux == ctx.aux && cinfo == ctx.cinfo) return true; return false; } From b8413855ecf587af3e63de911e169be226bbaca1 Mon Sep 17 00:00:00 2001 From: fxliang Date: Tue, 5 Sep 2023 10:47:20 +0800 Subject: [PATCH 2/7] feat: add x64/WeaselDeployer.exe for wow64 situation, for huge dictionary deployment. --- RimeWithWeasel/RimeWithWeasel.vcxproj | 434 +++++++++++++------------- RimeWithWeasel/WeaselUtility.cpp | 6 +- WeaselDeployer/Configurator.cpp | 3 +- WeaselDeployer/UIStyleSettings.cpp | 7 - WeaselDeployer/WeaselDeployer.vcxproj | 348 +++++++++++++-------- WeaselServer/WeaselServerApp.cpp | 16 +- WeaselTSF/LanguageBar.cpp | 12 - github.install.bat | 10 + include/WeaselUtility.h | 24 ++ output/install.nsi | 6 + output/x64/.placeholder | 0 weasel.sln | 13 +- 12 files changed, 501 insertions(+), 378 deletions(-) create mode 100644 output/x64/.placeholder diff --git a/RimeWithWeasel/RimeWithWeasel.vcxproj b/RimeWithWeasel/RimeWithWeasel.vcxproj index 04ae9169e..1cc749487 100644 --- a/RimeWithWeasel/RimeWithWeasel.vcxproj +++ b/RimeWithWeasel/RimeWithWeasel.vcxproj @@ -1,216 +1,220 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - ReleaseHant - Win32 - - - ReleaseHant - x64 - - - Release - Win32 - - - Release - x64 - - - - {1C497821-BD63-4F02-9094-32B185B62F23} - RimeWithWeasel - Win32Proj - - - - - StaticLibrary - Unicode - true - $(PLATFORM_TOOLSET) - - - StaticLibrary - Unicode - true - $(PLATFORM_TOOLSET) - - - StaticLibrary - Unicode - $(PLATFORM_TOOLSET) - - - StaticLibrary - Unicode - true - $(PLATFORM_TOOLSET) - - - StaticLibrary - Unicode - true - $(PLATFORM_TOOLSET) - - - StaticLibrary - Unicode - $(PLATFORM_TOOLSET) - - - - - - - - - - - - - - - - - - - - - - - - - - Disabled - $(SolutionDir)\include;$(BOOST_ROOT);$(SolutionDir)\librime\include;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - Use - Level3 - EditAndContinue - /Zc:threadSafeInit- %(AdditionalOptions) - - - - - MaxSpeed - true - $(SolutionDir)\include;$(BOOST_ROOT);$(SolutionDir)\librime\include;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) - MultiThreaded - true - Use - Level3 - ProgramDatabase - /Zc:threadSafeInit- %(AdditionalOptions) - - - - - - X64 - - - Disabled - $(SolutionDir)\include;$(BOOST_ROOT);$(SolutionDir)\librime\include;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - Use - Level3 - ProgramDatabase - /Zc:threadSafeInit- %(AdditionalOptions) - - - - - X64 - - - MaxSpeed - true - $(SolutionDir)\include;$(BOOST_ROOT);$(SolutionDir)\librime\include;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) - MultiThreaded - true - Use - Level3 - ProgramDatabase - /Zc:threadSafeInit- %(AdditionalOptions) - - - - - MaxSpeed - true - $(SolutionDir)\include;$(BOOST_ROOT);$(SolutionDir)\librime\include;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) - MultiThreaded - true - Use - Level3 - ProgramDatabase - /Zc:threadSafeInit- %(AdditionalOptions) - - - - - X64 - - - MaxSpeed - true - $(SolutionDir)\include;$(BOOST_ROOT);$(SolutionDir)\librime\include;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) - MultiThreaded - true - Use - Level3 - ProgramDatabase - /Zc:threadSafeInit- %(AdditionalOptions) - - - - - - Create - Create - Create - Create - Create - Create - - - - - - - - - - - - - - - {10b3b8bf-7294-4661-9a8a-2ffc920fa2f4} - false - - - - - + + + + + Debug + Win32 + + + Debug + x64 + + + ReleaseHant + Win32 + + + ReleaseHant + x64 + + + Release + Win32 + + + Release + x64 + + + + {1C497821-BD63-4F02-9094-32B185B62F23} + RimeWithWeasel + Win32Proj + 10.0 + + + + + StaticLibrary + Unicode + true + $(PLATFORM_TOOLSET) + + + StaticLibrary + Unicode + true + $(PLATFORM_TOOLSET) + + + StaticLibrary + Unicode + $(PLATFORM_TOOLSET) + + + StaticLibrary + Unicode + true + $(PLATFORM_TOOLSET) + + + StaticLibrary + Unicode + true + $(PLATFORM_TOOLSET) + + + StaticLibrary + Unicode + $(PLATFORM_TOOLSET) + + + + + + + + + + + + + + + + + + + + + + + + + $(Platform)$(Platform)\$(Configuration)\ + + + + Disabled + $(SolutionDir)\include;$(BOOST_ROOT);$(SolutionDir)\librime\include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebug + Use + Level3 + EditAndContinue + /Zc:threadSafeInit- %(AdditionalOptions) + + + + + MaxSpeed + true + $(SolutionDir)\include;$(BOOST_ROOT);$(SolutionDir)\librime\include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + MultiThreaded + true + Use + Level3 + ProgramDatabase + /Zc:threadSafeInit- %(AdditionalOptions) + + + + + + X64 + + + Disabled + $(SolutionDir)\include;$(BOOST_ROOT);$(SolutionDir)\librime\include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebug + Use + Level3 + ProgramDatabase + /Zc:threadSafeInit- %(AdditionalOptions) + + + + + X64 + + + MaxSpeed + true + $(SolutionDir)\include;$(BOOST_ROOT);$(SolutionDir)\librime\include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + MultiThreaded + true + Use + Level3 + ProgramDatabase + /Zc:threadSafeInit- %(AdditionalOptions) + + + + + MaxSpeed + true + $(SolutionDir)\include;$(BOOST_ROOT);$(SolutionDir)\librime\include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + MultiThreaded + true + Use + Level3 + ProgramDatabase + /Zc:threadSafeInit- %(AdditionalOptions) + + + + + X64 + + + MaxSpeed + true + $(SolutionDir)\include;$(BOOST_ROOT);$(SolutionDir)\librime\include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + MultiThreaded + true + Use + Level3 + ProgramDatabase + /Zc:threadSafeInit- %(AdditionalOptions) + + + + + + Create + Create + Create + Create + Create + Create + + + + + + + + + + + + + + + {10b3b8bf-7294-4661-9a8a-2ffc920fa2f4} + false + + + + + \ No newline at end of file diff --git a/RimeWithWeasel/WeaselUtility.cpp b/RimeWithWeasel/WeaselUtility.cpp index b0887373d..53b60091f 100644 --- a/RimeWithWeasel/WeaselUtility.cpp +++ b/RimeWithWeasel/WeaselUtility.cpp @@ -28,7 +28,11 @@ const char* weasel_shared_data_dir() { GetModuleFileNameA(NULL, path, _countof(path)); std::string str_path(path); size_t k = str_path.find_last_of("/\\"); - strcpy_s(path + k + 1, _countof(path) - (k + 1), "data"); +#ifdef _WIN64 + strcpy_s(path + k - 3 , _countof(path) - (k + 3), "data"); +#else + strcpy_s(path + k + 1, _countof(path) - (k + 1), "data"); +#endif return path; } diff --git a/WeaselDeployer/Configurator.cpp b/WeaselDeployer/Configurator.cpp index 1ede65533..0962fb123 100644 --- a/WeaselDeployer/Configurator.cpp +++ b/WeaselDeployer/Configurator.cpp @@ -20,8 +20,7 @@ static void CreateFileIfNotExist(std::string filename) { std::string user_data_dir = weasel_user_data_dir(); std::wstring filepathw = string_to_wstring(user_data_dir) + L"\\" + string_to_wstring(filename); - DWORD dwAttrib = GetFileAttributes(filepathw.c_str()); - if (!(INVALID_FILE_ATTRIBUTES != dwAttrib && 0 == (dwAttrib & FILE_ATTRIBUTE_DIRECTORY))) + if (!IfFileExistW(filepathw)) { std::wofstream o(filepathw, std::ios::app); o.close(); diff --git a/WeaselDeployer/UIStyleSettings.cpp b/WeaselDeployer/UIStyleSettings.cpp index 20d093808..9b9a9f415 100644 --- a/WeaselDeployer/UIStyleSettings.cpp +++ b/WeaselDeployer/UIStyleSettings.cpp @@ -36,13 +36,6 @@ bool UIStyleSettings::GetPresetColorSchemes(std::vector* result return true; } -// check if a file exists -static inline bool IfFileExist(std::string filename) -{ - DWORD dwAttrib = GetFileAttributes(string_to_wstring(filename).c_str()); - return (INVALID_FILE_ATTRIBUTES != dwAttrib && 0 == (dwAttrib & FILE_ATTRIBUTE_DIRECTORY)); -} - // get preview image from user dir first, then shared_dir std::string UIStyleSettings::GetColorSchemePreview(const std::string& color_scheme_id) { std::string shared_dir = rime_get_api()->get_shared_data_dir(); diff --git a/WeaselDeployer/WeaselDeployer.vcxproj b/WeaselDeployer/WeaselDeployer.vcxproj index 2c12c00a0..8949a037f 100644 --- a/WeaselDeployer/WeaselDeployer.vcxproj +++ b/WeaselDeployer/WeaselDeployer.vcxproj @@ -1,133 +1,217 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {F53F3E9C-CC4D-4D1D-9C2E-719FE60A7E6B} - Win32Proj - WeaselDeployer - - - - - Application - true - Unicode - $(PLATFORM_TOOLSET) - - - Application - false - true - Unicode - $(PLATFORM_TOOLSET) - - - - - - - - - - - - - true - $(SolutionDir)output\ - - - false - $(SolutionDir)output\ - - - - Use - Level3 - Disabled - WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) - $(SolutionDir)\include;$(BOOST_ROOT);$(SolutionDir)\librime\include;%(AdditionalIncludeDirectories) - MultiThreadedDebug - /Zc:threadSafeInit- %(AdditionalOptions) - - - Windows - true - $(SolutionDir)\lib;$(BOOST_ROOT)\stage\lib;$(SolutionDir)\librime\build\lib\Debug;%(AdditionalLibraryDirectories) - rime.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - $(SolutionDir)output\$(ProjectName)$(TargetExt) - - - - - Level3 - Use - Disabled - true - true - WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) - $(SolutionDir)\include;$(BOOST_ROOT);$(SolutionDir)\librime\include - MultiThreaded - /Zc:threadSafeInit- %(AdditionalOptions) - - - Windows - true - true - true - rime.lib;rime.lib;%(AdditionalDependencies) - $(SolutionDir)\lib;$(BOOST_ROOT)\stage\lib;$(SolutionDir)\librime\build\lib\Release;%(AdditionalLibraryDirectories) - $(SolutionDir)output\$(ProjectName)$(TargetExt) - - - PerMonitorHighDPIAware - - - - - - - - - - - - - - - - - - - Create - Create - - - - - - - - - - - - {ce11a2df-8d20-4b07-a935-4b0d03f0303d} - false - - - - - - - - + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {F53F3E9C-CC4D-4D1D-9C2E-719FE60A7E6B} + Win32Proj + WeaselDeployer + 10.0 + + + + + Application + true + Unicode + $(PLATFORM_TOOLSET) + + + Application + true + Unicode + $(PLATFORM_TOOLSET) + + + Application + false + true + Unicode + $(PLATFORM_TOOLSET) + + + Application + false + true + Unicode + $(PLATFORM_TOOLSET) + + + + + + + + + + + + + + + + + + + true + $(SolutionDir)output\ + + + true + + + false + $(SolutionDir)output\ + + + false + $(SolutionDir)output\$(Platform) + $(ProjectName) + + + + Use + Level3 + Disabled + WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + $(SolutionDir)\include;$(BOOST_ROOT);$(SolutionDir)\librime\include;%(AdditionalIncludeDirectories) + MultiThreadedDebug + /Zc:threadSafeInit- %(AdditionalOptions) + + + Windows + true + $(SolutionDir)\lib;$(BOOST_ROOT)\stage\lib;$(SolutionDir)\librime\build\lib\Debug;%(AdditionalLibraryDirectories) + rime.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + $(SolutionDir)output\$(ProjectName)$(TargetExt) + + + + + Use + Level3 + Disabled + WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + $(SolutionDir)\include;$(BOOST_ROOT);$(SolutionDir)\librime\include;%(AdditionalIncludeDirectories) + MultiThreadedDebug + /Zc:threadSafeInit- %(AdditionalOptions) + + + Windows + true + $(SolutionDir)$(Platform)\$(Configuration);$(SolutionDir)\lib;$(BOOST_ROOT)\stage\lib;$(SolutionDir)\librime\build\lib\Debug;%(AdditionalLibraryDirectories) + rimex64.lib;RimeWithWeasel.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + $(SolutionDir)output\$(ProjectName)x64$(TargetExt) + + + + + Level3 + Use + Disabled + true + true + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + $(SolutionDir)\include;$(BOOST_ROOT);$(SolutionDir)\librime\include + MultiThreaded + /Zc:threadSafeInit- %(AdditionalOptions) + + + Windows + true + true + true + rime.lib;rime.lib;%(AdditionalDependencies) + $(SolutionDir)\lib;$(BOOST_ROOT)\stage\lib;$(SolutionDir)\librime\build\lib\Release;%(AdditionalLibraryDirectories) + $(SolutionDir)output\$(ProjectName)$(TargetExt) + + + PerMonitorHighDPIAware + + + + + Level3 + Use + Disabled + true + true + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + $(SolutionDir)\include;$(BOOST_ROOT);$(SolutionDir)\librime\include + MultiThreaded + /Zc:threadSafeInit- %(AdditionalOptions) + + + Windows + true + true + true + rime$(Platform).lib;%(AdditionalDependencies);RimeWithWeasel.lib + $(SolutionDir)$(Platform)\$(Configuration);$(SolutionDir)\lib;$(BOOST_ROOT)\stage\lib;$(SolutionDir)\librime\build\lib\Release;%(AdditionalLibraryDirectories) + $(SolutionDir)output\$(Platform)\$(ProjectName)$(TargetExt) + + + PerMonitorHighDPIAware + + + + + + + + + + + + + + + + + + + Create + Create + Create + Create + + + + + + + + + + + + {1c497821-bd63-4f02-9094-32b185b62f23} + + + {ce11a2df-8d20-4b07-a935-4b0d03f0303d} + false + + + + + + + + \ No newline at end of file diff --git a/WeaselServer/WeaselServerApp.cpp b/WeaselServer/WeaselServerApp.cpp index 851309885..b4bf882a3 100644 --- a/WeaselServer/WeaselServerApp.cpp +++ b/WeaselServer/WeaselServerApp.cpp @@ -1,5 +1,6 @@ #include "stdafx.h" #include "WeaselServerApp.h" +#include "WeaselUtility.h" WeaselServerApp::WeaselServerApp() : m_handler(std::make_unique(&m_ui)) @@ -46,10 +47,17 @@ void WeaselServerApp::SetupMenuHandlers() { std::wstring dir(install_dir()); m_server.AddMenuHandler(ID_WEASELTRAY_QUIT, [this] { return m_server.Stop() == 0; }); - m_server.AddMenuHandler(ID_WEASELTRAY_DEPLOY, std::bind(execute, dir + L"\\WeaselDeployer.exe", std::wstring(L"/deploy"))); - m_server.AddMenuHandler(ID_WEASELTRAY_SETTINGS, std::bind(execute, dir + L"\\WeaselDeployer.exe", std::wstring())); - m_server.AddMenuHandler(ID_WEASELTRAY_DICT_MANAGEMENT, std::bind(execute, dir + L"\\WeaselDeployer.exe", std::wstring(L"/dict"))); - m_server.AddMenuHandler(ID_WEASELTRAY_SYNC, std::bind(execute, dir + L"\\WeaselDeployer.exe", std::wstring(L"/sync"))); + if (is_wow64() && IfFileExistW(dir + L"\\x64\\WeaselDeployer.exe") && IfFileExistW(dir + L"\\x64\\rime.dll")) { + m_server.AddMenuHandler(ID_WEASELTRAY_DEPLOY, std::bind(execute, dir + L"\\x64\\WeaselDeployer.exe", std::wstring(L"/deploy"))); + m_server.AddMenuHandler(ID_WEASELTRAY_SETTINGS, std::bind(execute, dir + L"\\x64\\WeaselDeployer.exe", std::wstring())); + m_server.AddMenuHandler(ID_WEASELTRAY_DICT_MANAGEMENT, std::bind(execute, dir + L"\\x64\\WeaselDeployer.exe", std::wstring(L"/dict"))); + m_server.AddMenuHandler(ID_WEASELTRAY_SYNC, std::bind(execute, dir + L"\\x64\\WeaselDeployer.exe", std::wstring(L"/sync"))); + } else { + m_server.AddMenuHandler(ID_WEASELTRAY_DEPLOY, std::bind(execute, dir + L"\\WeaselDeployer.exe", std::wstring(L"/deploy"))); + m_server.AddMenuHandler(ID_WEASELTRAY_SETTINGS, std::bind(execute, dir + L"\\WeaselDeployer.exe", std::wstring())); + m_server.AddMenuHandler(ID_WEASELTRAY_DICT_MANAGEMENT, std::bind(execute, dir + L"\\WeaselDeployer.exe", std::wstring(L"/dict"))); + m_server.AddMenuHandler(ID_WEASELTRAY_SYNC, std::bind(execute, dir + L"\\WeaselDeployer.exe", std::wstring(L"/sync"))); + } m_server.AddMenuHandler(ID_WEASELTRAY_WIKI, std::bind(open, L"https://rime.im/docs/")); m_server.AddMenuHandler(ID_WEASELTRAY_HOMEPAGE, std::bind(open, L"https://rime.im/")); m_server.AddMenuHandler(ID_WEASELTRAY_FORUM, std::bind(open, L"https://rime.im/discuss/")); diff --git a/WeaselTSF/LanguageBar.cpp b/WeaselTSF/LanguageBar.cpp index 0e02babc2..fcc4efcb2 100644 --- a/WeaselTSF/LanguageBar.cpp +++ b/WeaselTSF/LanguageBar.cpp @@ -283,18 +283,6 @@ void CLangBarItemButton::SetLangbarStatus(DWORD dwStatus, BOOL fSet) return; } -BOOL is_wow64() -{ - DWORD errorCode; - if (GetSystemWow64DirectoryW(NULL, 0) == 0) - if ((errorCode = GetLastError()) == ERROR_CALL_NOT_IMPLEMENTED) - return FALSE; - else - ExitProcess((UINT)errorCode); - else - return TRUE; -} - void WeaselTSF::_HandleLangBarMenuSelect(UINT wID) { if(wID != ID_WEASELTRAY_RERUN_SERVICE) diff --git a/github.install.bat b/github.install.bat index f7256d04b..e7ea28eb5 100644 --- a/github.install.bat +++ b/github.install.bat @@ -8,16 +8,26 @@ set rime_version=1.9.0 set download_archive=rime-a608767-Windows-msvc.7z set download_archive_deps=rime-deps-a608767-Windows-msvc.7z +set download_archive_x64=rime-a608767-Windows-clang.7z +set download_archive_deps_x64=rime-deps-a608767-Windows-clang.7z + curl -LO https://github.com/rime/librime/releases/download/%rime_version%/%download_archive% curl -LO https://github.com/rime/librime/releases/download/%rime_version%/%download_archive_deps% +curl -LO https://github.com/rime/librime/releases/download/%rime_version%/%download_archive_x64% +curl -LO https://github.com/rime/librime/releases/download/%rime_version%/%download_archive_deps_x64% 7z x %download_archive% * -olibrime\ -y 7z x %download_archive_deps% * -olibrime\ -y +7z x %download_archive_x64% * -olibrime_x64\ -y +7z x %download_archive_deps_x64% * -olibrime_x64\ -y copy /Y librime\dist\include\rime_*.h include\ copy /Y librime\dist\lib\rime.lib lib\ copy /Y librime\dist\lib\rime.dll output\ +copy /Y librime_x64\dist\lib\rime.dll output\x64\ +copy /Y librime_x64\dist\lib\rime.lib lib\rimex64.lib + if not exist output\data\opencc mkdir output\data\opencc copy /Y librime\share\opencc\*.* output\data\opencc\ diff --git a/include/WeaselUtility.h b/include/WeaselUtility.h index dfc18a5bc..7bb587313 100644 --- a/include/WeaselUtility.h +++ b/include/WeaselUtility.h @@ -63,5 +63,29 @@ inline std::string wstring_to_string(const std::wstring& wstr, int code_page = C return res; } +inline bool IfFileExistW(std::wstring filepathw) +{ + DWORD dwAttrib = GetFileAttributes(filepathw.c_str()); + return (INVALID_FILE_ATTRIBUTES != dwAttrib && 0 == (dwAttrib & FILE_ATTRIBUTE_DIRECTORY)); +} + +inline bool IfFileExist(std::string filepath, int code_page = CP_ACP) +{ + std::wstring filepathw{string_to_wstring(filepath, code_page)}; + DWORD dwAttrib = GetFileAttributes(filepathw.c_str()); + return (INVALID_FILE_ATTRIBUTES != dwAttrib && 0 == (dwAttrib & FILE_ATTRIBUTE_DIRECTORY)); +} + +inline bool is_wow64() { + DWORD errorCode; + if (GetSystemWow64DirectoryW(NULL, 0) == 0) + if ((errorCode = GetLastError()) == ERROR_CALL_NOT_IMPLEMENTED) + return false; + else + ExitProcess((UINT)errorCode); + else + return true; +} + // resource std::string GetCustomResource(const char *name, const char *type); diff --git a/output/install.nsi b/output/install.nsi index a9cf80f7b..7f0466d3f 100644 --- a/output/install.nsi +++ b/output/install.nsi @@ -204,6 +204,12 @@ program_files: ; images SetOutPath $INSTDIR\data\preview File "data\preview\*.png" + ; WeaselDeployerx64 files + ${If} ${RunningX64} + SetOutPath $INSTDIR\x64 + File /nonfatal "x64\WeaselDeployer.exe" + File /nonfatal "x64\rime.dll" + ${EndIf} SetOutPath $INSTDIR diff --git a/output/x64/.placeholder b/output/x64/.placeholder new file mode 100644 index 000000000..e69de29bb diff --git a/weasel.sln b/weasel.sln index 7c90e714c..6104f0cb9 100644 --- a/weasel.sln +++ b/weasel.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.5.33516.290 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.33529.622 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{53F79A24-5390-4640-84B5-19984EB3353B}" ProjectSection(SolutionItems) = preProject @@ -136,17 +136,20 @@ Global {1C497821-BD63-4F02-9094-32B185B62F23}.Debug|Win32.ActiveCfg = Debug|Win32 {1C497821-BD63-4F02-9094-32B185B62F23}.Debug|Win32.Build.0 = Debug|Win32 {1C497821-BD63-4F02-9094-32B185B62F23}.Debug|x64.ActiveCfg = Debug|x64 + {1C497821-BD63-4F02-9094-32B185B62F23}.Debug|x64.Build.0 = Debug|x64 {1C497821-BD63-4F02-9094-32B185B62F23}.Release|Win32.ActiveCfg = Release|Win32 {1C497821-BD63-4F02-9094-32B185B62F23}.Release|Win32.Build.0 = Release|Win32 {1C497821-BD63-4F02-9094-32B185B62F23}.Release|x64.ActiveCfg = Release|x64 + {1C497821-BD63-4F02-9094-32B185B62F23}.Release|x64.Build.0 = Release|x64 {1C497821-BD63-4F02-9094-32B185B62F23}.ReleaseHant|Win32.ActiveCfg = ReleaseHant|Win32 {1C497821-BD63-4F02-9094-32B185B62F23}.ReleaseHant|x64.ActiveCfg = ReleaseHant|x64 - {F53F3E9C-CC4D-4D1D-9C2E-719FE60A7E6B}.Debug|Win32.ActiveCfg = Debug|Win32 - {F53F3E9C-CC4D-4D1D-9C2E-719FE60A7E6B}.Debug|Win32.Build.0 = Debug|Win32 + {F53F3E9C-CC4D-4D1D-9C2E-719FE60A7E6B}.Debug|Win32.ActiveCfg = Debug|x64 + {F53F3E9C-CC4D-4D1D-9C2E-719FE60A7E6B}.Debug|Win32.Build.0 = Debug|x64 {F53F3E9C-CC4D-4D1D-9C2E-719FE60A7E6B}.Debug|x64.ActiveCfg = Debug|Win32 {F53F3E9C-CC4D-4D1D-9C2E-719FE60A7E6B}.Release|Win32.ActiveCfg = Release|Win32 {F53F3E9C-CC4D-4D1D-9C2E-719FE60A7E6B}.Release|Win32.Build.0 = Release|Win32 - {F53F3E9C-CC4D-4D1D-9C2E-719FE60A7E6B}.Release|x64.ActiveCfg = Release|Win32 + {F53F3E9C-CC4D-4D1D-9C2E-719FE60A7E6B}.Release|x64.ActiveCfg = Release|x64 + {F53F3E9C-CC4D-4D1D-9C2E-719FE60A7E6B}.Release|x64.Build.0 = Release|x64 {F53F3E9C-CC4D-4D1D-9C2E-719FE60A7E6B}.ReleaseHant|Win32.ActiveCfg = Release|Win32 {F53F3E9C-CC4D-4D1D-9C2E-719FE60A7E6B}.ReleaseHant|x64.ActiveCfg = Release|Win32 {39F6E3F5-8F0B-4023-BC40-A66AE6C37095}.Debug|Win32.ActiveCfg = Debug|Win32 From 21c10cc973d0324f63fcdd54dca29e3a10e09c19 Mon Sep 17 00:00:00 2001 From: fxliang Date: Fri, 19 Jan 2024 12:39:02 +0800 Subject: [PATCH 3/7] change method weasel_shared_data_dir --- RimeWithWeasel/WeaselUtility.cpp | 6 +----- WeaselDeployer/Configurator.cpp | 7 ++++++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/RimeWithWeasel/WeaselUtility.cpp b/RimeWithWeasel/WeaselUtility.cpp index 53b60091f..b0887373d 100644 --- a/RimeWithWeasel/WeaselUtility.cpp +++ b/RimeWithWeasel/WeaselUtility.cpp @@ -28,11 +28,7 @@ const char* weasel_shared_data_dir() { GetModuleFileNameA(NULL, path, _countof(path)); std::string str_path(path); size_t k = str_path.find_last_of("/\\"); -#ifdef _WIN64 - strcpy_s(path + k - 3 , _countof(path) - (k + 3), "data"); -#else - strcpy_s(path + k + 1, _countof(path) - (k + 1), "data"); -#endif + strcpy_s(path + k + 1, _countof(path) - (k + 1), "data"); return path; } diff --git a/WeaselDeployer/Configurator.cpp b/WeaselDeployer/Configurator.cpp index 0962fb123..59eb75d21 100644 --- a/WeaselDeployer/Configurator.cpp +++ b/WeaselDeployer/Configurator.cpp @@ -14,6 +14,7 @@ #include #pragma warning(default: 4005) #include +#include #include "WeaselDeployer.h" static void CreateFileIfNotExist(std::string filename) @@ -35,7 +36,11 @@ Configurator::Configurator() void Configurator::Initialize() { RIME_STRUCT(RimeTraits, weasel_traits); - weasel_traits.shared_data_dir = weasel_shared_data_dir(); + std::string shared_data_dir = weasel_shared_data_dir(); +#ifdef _WIN64 + shared_data_dir = std::regex_replace(shared_data_dir, std::regex("\\\\x64"), ""); +#endif + weasel_traits.shared_data_dir = shared_data_dir.c_str(); weasel_traits.user_data_dir = weasel_user_data_dir(); weasel_traits.prebuilt_data_dir = weasel_traits.shared_data_dir; const int len = 20; From b96fdabaa5fd0e6f3d0e743036c799d7157e27b7 Mon Sep 17 00:00:00 2001 From: fxliang Date: Sun, 18 Feb 2024 11:48:08 +0800 Subject: [PATCH 4/7] chore: update librime 295cb2a (librime 1.10.0) --- github.install.bat | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/github.install.bat b/github.install.bat index e7ea28eb5..5bb327e89 100644 --- a/github.install.bat +++ b/github.install.bat @@ -3,13 +3,13 @@ setlocal git submodule init git submodule update plum -set rime_version=1.9.0 +set rime_version=1.10.0 -set download_archive=rime-a608767-Windows-msvc.7z -set download_archive_deps=rime-deps-a608767-Windows-msvc.7z +set download_archive=rime-295cb2a-Windows-msvc.7z +set download_archive_deps=rime-deps-295cb2a-Windows-msvc.7z -set download_archive_x64=rime-a608767-Windows-clang.7z -set download_archive_deps_x64=rime-deps-a608767-Windows-clang.7z +set download_archive_x64=rime-295cb2a-Windows-clang.7z +set download_archive_deps_x64=rime-deps-295cb2a-Windows-clang.7z curl -LO https://github.com/rime/librime/releases/download/%rime_version%/%download_archive% curl -LO https://github.com/rime/librime/releases/download/%rime_version%/%download_archive_deps% From a8d99762db8c42d27a4bd1f455d5d4892051fbee Mon Sep 17 00:00:00 2001 From: fxliang Date: Sun, 18 Feb 2024 12:29:57 +0800 Subject: [PATCH 5/7] chore: update submodule librime --- librime | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/librime b/librime index 6546689a2..295cb2ab6 160000 --- a/librime +++ b/librime @@ -1 +1 @@ -Subproject commit 6546689a2c9061860a0af5fa1209f9e8ea7d2132 +Subproject commit 295cb2ab68f89ee9d3237c7d4b8033bda3f3b635 From 853914c046e460ab1becb2b9b4aa10e245628302 Mon Sep 17 00:00:00 2001 From: fxliang Date: Sun, 18 Feb 2024 14:44:07 +0800 Subject: [PATCH 6/7] fix typo --- WeaselDeployer/Configurator.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/WeaselDeployer/Configurator.cpp b/WeaselDeployer/Configurator.cpp index 31061de06..14f1b5502 100644 --- a/WeaselDeployer/Configurator.cpp +++ b/WeaselDeployer/Configurator.cpp @@ -37,10 +37,10 @@ Configurator::Configurator() void Configurator::Initialize() { RIME_STRUCT(RimeTraits, weasel_traits); -#ifdef _WIN64 +#ifndef _WIN64 std::string shared_dir = wstring_to_string(WeaselSharedDataPath().wstring(), CP_UTF8); #else - std::string shared_dir = wstring_to_string((WeaselSharedDataPath().parent_path().append("data")).wstring(), CP_UTF8); + std::string shared_dir = wstring_to_string((WeaselSharedDataPath().parent_path().parent_path().append("data")).wstring(), CP_UTF8); #endif std::string user_dir = wstring_to_string(WeaselUserDataPath().wstring(), CP_UTF8); weasel_traits.shared_data_dir = shared_dir.c_str(); From 77b6af2e9658430022223d32079dfbbcf6de631b Mon Sep 17 00:00:00 2001 From: fxliang Date: Sun, 18 Feb 2024 16:29:04 +0800 Subject: [PATCH 7/7] fix ci --- .github/workflows/commit-ci.yml | 33 +++++++++++++++++++++++++++++++- .github/workflows/release-ci.yml | 33 +++++++++++++++++++++++++++++++- env.bat.template | 3 ++- env.vs2019.bat | 4 ++-- env.vs2022.bat | 4 ++-- 5 files changed, 70 insertions(+), 7 deletions(-) diff --git a/.github/workflows/commit-ci.yml b/.github/workflows/commit-ci.yml index a20c380fc..d5c6ab128 100644 --- a/.github/workflows/commit-ci.yml +++ b/.github/workflows/commit-ci.yml @@ -51,9 +51,10 @@ jobs: if: env.librime_build == 'stable' run: .\github.install.bat - - name: Build librime + - name: Build librime 64 bit if: env.librime_build == 'submodule' env: + ARCH: x64 RIME_PLUGINS: hchunhui/librime-lua lotem/librime-octagram rime/librime-predict shell: bash run: | @@ -61,6 +62,36 @@ jobs: pushd librime ./action-install-plugins-windows.bat popd + # build librime + ./build.bat librime + # copy x64 files to weasel and rename + echo " ./lib/rimex64.dll" + cp ./librime/dist/lib/rime.dll ./lib/rimex64.dll + echo " ./lib/rimex64.lib" + cp ./librime/dist/lib/rime.lib ./lib/rimex64.lib + echo " ./output/x64/rime.dll" + cp ./librime/dist/lib/rime.dll ./output/x64/rime.dll + + - name: Build librime + if: env.librime_build == 'submodule' + env: + ARCH: Win32 + RIME_PLUGINS: hchunhui/librime-lua lotem/librime-octagram rime/librime-predict + shell: bash + run: | + # clean x64 + rm -rf ./librime/deps/opencc/build/ + rm -rf ./librime/deps/glog/build/ + rm -rf ./librime/deps/googletest/build/ + rm -rf ./librime/deps/leveldb/build/ + rm -rf ./librime/deps/marisa-trie/build/ + rm -rf ./librime/deps/yaml-cpp/build/ + rm -rf ./librime/build/ + rm -rf ./librime/lib/*.lib + rm -rf ./librime/lib/cmake + rm -rf ./librime/lib/pkgconfig + rm -rf ./librime/dist + # build librime ./build.bat librime - name: Build Weasel diff --git a/.github/workflows/release-ci.yml b/.github/workflows/release-ci.yml index 32ec6f942..d755a36ba 100644 --- a/.github/workflows/release-ci.yml +++ b/.github/workflows/release-ci.yml @@ -49,9 +49,10 @@ jobs: run: | .\github.install.bat - - name: Build librime + - name: Build librime 64 bit if: env.librime_build == 'submodule' env: + ARCH: x64 RIME_PLUGINS: hchunhui/librime-lua lotem/librime-octagram rime/librime-predict shell: bash run: | @@ -59,6 +60,36 @@ jobs: pushd librime ./action-install-plugins-windows.bat popd + # build librime + ./build.bat librime + # copy x64 files to weasel and rename + echo " ./lib/rimex64.dll" + cp ./librime/dist/lib/rime.dll ./lib/rimex64.dll + echo " ./lib/rimex64.lib" + cp ./librime/dist/lib/rime.lib ./lib/rimex64.lib + echo " ./output/x64/rime.dll" + cp ./librime/dist/lib/rime.dll ./output/x64/rime.dll + + - name: Build librime + if: env.librime_build == 'submodule' + env: + ARCH: Win32 + RIME_PLUGINS: hchunhui/librime-lua lotem/librime-octagram rime/librime-predict + shell: bash + run: | + # clean x64 + rm -rf ./librime/deps/opencc/build/ + rm -rf ./librime/deps/glog/build/ + rm -rf ./librime/deps/googletest/build/ + rm -rf ./librime/deps/leveldb/build/ + rm -rf ./librime/deps/marisa-trie/build/ + rm -rf ./librime/deps/yaml-cpp/build/ + rm -rf ./librime/build/ + rm -rf ./librime/lib/*.lib + rm -rf ./librime/lib/cmake + rm -rf ./librime/lib/pkgconfig + rm -rf ./librime/dist + # build librime ./build.bat librime - name: Build Weasel diff --git a/env.bat.template b/env.bat.template index 8cc16f1a3..a6e36fc0d 100644 --- a/env.bat.template +++ b/env.bat.template @@ -1,9 +1,10 @@ rem Customize your build environment and save the modified copy to env.bat rem REQUIRED: path to Boost source directory -set BOOST_ROOT=C:\Libraries\boost_1_78_0 +set BOOST_ROOT=C:\Libraries\boost_1_83_0 rem OPTIONAL: Visual Studio version and platform toolset +if not defined ARCH set ARCH=Win32 rem set BJAM_TOOLSET=msvc-14.2 rem set PLATFORM_TOOLSET=v142 diff --git a/env.vs2019.bat b/env.vs2019.bat index e01e3dc94..f048165ad 100644 --- a/env.vs2019.bat +++ b/env.vs2019.bat @@ -3,10 +3,10 @@ rem Customize your build environment and save the modified copy to env.bat set WEASEL_ROOT=%CD% rem REQUIRED: path to Boost source directory -if not defined BOOST_ROOT set BOOST_ROOT=%WEASEL_ROOT%\deps\boost_1_78_0 +if not defined BOOST_ROOT set BOOST_ROOT=%WEASEL_ROOT%\deps\boost_1_83_0 rem OPTIONAL: architecture, Visual Studio version and platform toolset -set ARCH=Win32 +if not defined ARCH set ARCH=Win32 set BJAM_TOOLSET=msvc-14.2 set CMAKE_GENERATOR="Visual Studio 16 2019" set PLATFORM_TOOLSET=v142 diff --git a/env.vs2022.bat b/env.vs2022.bat index f289aa026..4c7318aa6 100644 --- a/env.vs2022.bat +++ b/env.vs2022.bat @@ -3,10 +3,10 @@ rem Customize your build environment and save the modified copy to env.bat set WEASEL_ROOT=%CD% rem REQUIRED: path to Boost source directory -if not defined BOOST_ROOT set BOOST_ROOT=%WEASEL_ROOT%\deps\boost_1_78_0 +if not defined BOOST_ROOT set BOOST_ROOT=%WEASEL_ROOT%\deps\boost_1_83_0 rem OPTIONAL: architecture, Visual Studio version and platform toolset -set ARCH=Win32 +if not defined ARCH set ARCH=Win32 set BJAM_TOOLSET=msvc-14.3 set CMAKE_GENERATOR="Visual Studio 17 2022" set PLATFORM_TOOLSET=v143