Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weaseldeployer x64 #1006

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
434 changes: 219 additions & 215 deletions RimeWithWeasel/RimeWithWeasel.vcxproj

Large diffs are not rendered by default.

10 changes: 7 additions & 3 deletions WeaselDeployer/Configurator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
#include <rime_levers_api.h>
#pragma warning(default: 4005)
#include <fstream>
#include <regex>
#include "WeaselDeployer.h"

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();
Expand All @@ -36,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"), "");
fxliang marked this conversation as resolved.
Show resolved Hide resolved
#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;
Expand Down
7 changes: 0 additions & 7 deletions WeaselDeployer/UIStyleSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,6 @@ bool UIStyleSettings::GetPresetColorSchemes(std::vector<ColorSchemeInfo>* 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();
Expand Down
348 changes: 216 additions & 132 deletions WeaselDeployer/WeaselDeployer.vcxproj

Large diffs are not rendered by default.

16 changes: 12 additions & 4 deletions WeaselServer/WeaselServerApp.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "stdafx.h"
#include "WeaselServerApp.h"
#include "WeaselUtility.h"

WeaselServerApp::WeaselServerApp()
: m_handler(std::make_unique<RimeWithWeaselHandler>(&m_ui))
Expand Down Expand Up @@ -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/"));
Expand Down
12 changes: 0 additions & 12 deletions WeaselTSF/LanguageBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 10 additions & 0 deletions github.install.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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\

2 changes: 1 addition & 1 deletion include/WeaselCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
24 changes: 24 additions & 0 deletions include/WeaselUtility.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
6 changes: 6 additions & 0 deletions output/install.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Empty file added output/x64/.placeholder
Empty file.
13 changes: 8 additions & 5 deletions weasel.sln
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down