Skip to content

Commit

Permalink
follow rime/librime pr 806, breaking change
Browse files Browse the repository at this point in the history
build librime in ci
  • Loading branch information
fxliang committed Feb 6, 2024
1 parent f69f2c2 commit 672f531
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 52 deletions.
16 changes: 13 additions & 3 deletions .github/workflows/commit-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Checkout last commit
uses: actions/checkout@v3
with:
submodules: true
submodules: recursive

- name: Configure build environment
run: |
Expand All @@ -46,12 +46,22 @@ jobs:
- name: Add msbuild to PATH
uses: microsoft/[email protected]

- 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
Expand Down
24 changes: 17 additions & 7 deletions .github/workflows/release-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,32 @@ jobs:
- name: Add msbuild to PATH
uses: microsoft/[email protected]

- 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
Expand Down
6 changes: 4 additions & 2 deletions RimeWithWeasel/RimeWithWeasel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,10 @@ void _RefreshTrayIcon(const UINT session_id, const std::function<void()> _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();
Expand Down
21 changes: 10 additions & 11 deletions RimeWithWeasel/WeaselUtility.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "stdafx.h"
#include <string>
#include <WeaselUtility.h>

std::wstring WeaselUserDataPath() {
WCHAR path[MAX_PATH] = {0};
Expand All @@ -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)
Expand Down
6 changes: 4 additions & 2 deletions WeaselDeployer/Configurator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
23 changes: 0 additions & 23 deletions github.install.bat

This file was deleted.

5 changes: 2 additions & 3 deletions include/WeaselUtility.h
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
2 changes: 1 addition & 1 deletion librime
Submodule librime updated 136 files

0 comments on commit 672f531

Please sign in to comment.