diff --git a/.github/workflows/commit-ci.yml b/.github/workflows/commit-ci.yml index 8662e3dcb..5bf5d7812 100644 --- a/.github/workflows/commit-ci.yml +++ b/.github/workflows/commit-ci.yml @@ -23,7 +23,7 @@ jobs: - name: Checkout last commit uses: actions/checkout@v3 with: - submodules: true + submodules: recursive - name: Configure build environment run: | @@ -46,12 +46,22 @@ jobs: - name: Add msbuild to PATH uses: microsoft/setup-msbuild@v1.1.3 - - name: Copy Rime files - run: .\github.install.bat + - name: build librime + if: ${{ success() }} + run: | + # load plugins + pushd librime\plugins\ + git clone -v --depth=1 https://github.com/hchunhui/librime-lua.git + git clone -v --depth=1 -b thirdparty https://github.com/hchunhui/librime-lua.git librime-lua\thirdparty + git clone -v --depth=1 https://github.com/rime/librime-predict.git + git clone -v --depth=1 https://github.com/lotem/librime-octagram.git + popd + .\build.bat librime - name: Build Weasel id: build_weasel run: | + .\build.bat opencc .\build.bat data .\build.bat hant .\build.bat installer diff --git a/.github/workflows/release-ci.yml b/.github/workflows/release-ci.yml index be87d1f40..9d6767bcc 100644 --- a/.github/workflows/release-ci.yml +++ b/.github/workflows/release-ci.yml @@ -43,22 +43,32 @@ jobs: - name: Add msbuild to PATH uses: microsoft/setup-msbuild@v1.1.3 - - name: Copy Rime files - run: .\github.install.bat + - name: build librime + if: ${{ success() }} + run: | + # load plugins + pushd librime\plugins\ + git clone -v --depth=1 https://github.com/hchunhui/librime-lua.git + git clone -v --depth=1 -b thirdparty https://github.com/hchunhui/librime-lua.git librime-lua\thirdparty + git clone -v --depth=1 https://github.com/rime/librime-predict.git + git clone -v --depth=1 https://github.com/lotem/librime-octagram.git + popd + .\build.bat librime - name: Build Weasel id: build_weasel run: | + .\build.bat opencc .\build.bat data .\build.bat hant .\build.bat installer if: ${{ success() }} - - name: Compress Debug Symbols - shell: pwsh - run: | - Compress-Archive -Path output\*.pdb -CompressionLevel Optimal -DestinationPath .\output\archives\symbols.zip - if: ${{ success() }} + #- name: Compress Debug Symbols + # shell: pwsh + # run: | + # Compress-Archive -Path output\*.pdb -CompressionLevel Optimal -DestinationPath .\output\archives\symbols.zip + # if: ${{ success() }} - name: Extract changelog shell: pwsh diff --git a/RimeWithWeasel/RimeWithWeasel.cpp b/RimeWithWeasel/RimeWithWeasel.cpp index 914e27878..f567fe6d0 100644 --- a/RimeWithWeasel/RimeWithWeasel.cpp +++ b/RimeWithWeasel/RimeWithWeasel.cpp @@ -70,8 +70,10 @@ void _RefreshTrayIcon(const UINT session_id, const std::function _Update void RimeWithWeaselHandler::_Setup() { RIME_STRUCT(RimeTraits, weasel_traits); - weasel_traits.shared_data_dir = weasel_shared_data_dir(); - weasel_traits.user_data_dir = weasel_user_data_dir(); + std::string shared_dir = weasel_shared_data_dir(); + std::string user_dir = weasel_user_data_dir(); + weasel_traits.shared_data_dir = shared_dir.c_str(); + weasel_traits.user_data_dir = user_dir.c_str(); weasel_traits.prebuilt_data_dir = weasel_traits.shared_data_dir; std::string distribution_name(wstring_to_string(WEASEL_IME_NAME, CP_UTF8)); weasel_traits.distribution_name = distribution_name.c_str(); diff --git a/RimeWithWeasel/WeaselUtility.cpp b/RimeWithWeasel/WeaselUtility.cpp index b0887373d..893dee534 100644 --- a/RimeWithWeasel/WeaselUtility.cpp +++ b/RimeWithWeasel/WeaselUtility.cpp @@ -1,5 +1,6 @@ #include "stdafx.h" #include +#include std::wstring WeaselUserDataPath() { WCHAR path[MAX_PATH] = {0}; @@ -23,20 +24,18 @@ std::wstring WeaselUserDataPath() { return path; } -const char* weasel_shared_data_dir() { - static char path[MAX_PATH] = {0}; - 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"); - return path; +std::string weasel_shared_data_dir() { + wchar_t _path[MAX_PATH] = {0}; + GetModuleFileNameW(NULL, _path, _countof(_path)); + std::wstring _pathw(_path); + return wstring_to_string(_pathw, CP_UTF8); } -const char* weasel_user_data_dir() { - static char path[MAX_PATH] = {0}; +std::string weasel_user_data_dir() { + char path[MAX_PATH] = {0}; // Windows wants multi-byte file paths in native encoding - WideCharToMultiByte(CP_ACP, 0, WeaselUserDataPath().c_str(), -1, path, _countof(path) - 1, NULL, NULL); - return path; + WideCharToMultiByte(CP_UTF8, 0, WeaselUserDataPath().c_str(), -1, path, _countof(path) - 1, NULL, NULL); + return std::string(path); } std::string GetCustomResource(const char *name, const char *type) diff --git a/WeaselDeployer/Configurator.cpp b/WeaselDeployer/Configurator.cpp index 1ede65533..822a0453f 100644 --- a/WeaselDeployer/Configurator.cpp +++ b/WeaselDeployer/Configurator.cpp @@ -36,8 +36,10 @@ Configurator::Configurator() void Configurator::Initialize() { RIME_STRUCT(RimeTraits, weasel_traits); - weasel_traits.shared_data_dir = weasel_shared_data_dir(); - weasel_traits.user_data_dir = weasel_user_data_dir(); + std::string shared_dir = weasel_shared_data_dir(); + std::string user_dir = weasel_user_data_dir(); + weasel_traits.shared_data_dir = shared_dir.c_str(); + weasel_traits.user_data_dir = user_dir.c_str(); weasel_traits.prebuilt_data_dir = weasel_traits.shared_data_dir; const int len = 20; char utf8_str[len]; diff --git a/github.install.bat b/github.install.bat deleted file mode 100644 index f7256d04b..000000000 --- a/github.install.bat +++ /dev/null @@ -1,23 +0,0 @@ -setlocal - -git submodule init -git submodule update plum - -set rime_version=1.9.0 - -set download_archive=rime-a608767-Windows-msvc.7z -set download_archive_deps=rime-deps-a608767-Windows-msvc.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% - -7z x %download_archive% * -olibrime\ -y -7z x %download_archive_deps% * -olibrime\ -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\ - -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 e2fb5b831..c21bcf04b 100644 --- a/include/WeaselUtility.h +++ b/include/WeaselUtility.h @@ -28,9 +28,8 @@ inline std::wstring getUsername() { // data directories std::wstring WeaselUserDataPath(); - -const char* weasel_shared_data_dir(); -const char* weasel_user_data_dir(); +std::string weasel_shared_data_dir(); +std::string weasel_user_data_dir(); inline BOOL IsUserDarkMode() { diff --git a/librime b/librime index a60876745..6546689a2 160000 --- a/librime +++ b/librime @@ -1 +1 @@ -Subproject commit a60876745af20ecc8489ec6997c6c195949b99ac +Subproject commit 6546689a2c9061860a0af5fa1209f9e8ea7d2132