Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into choose
Browse files Browse the repository at this point in the history
  • Loading branch information
groverlynn committed Nov 13, 2023
2 parents 0cbbe72 + 78587b8 commit 8779bc8
Show file tree
Hide file tree
Showing 16 changed files with 89 additions and 214 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/windows-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ jobs:
fail-fast: false
matrix:
compiler: [msvc, clang]
include:
- { compiler: msvc, cc: cl, cxx: cl }
- { compiler: clang, cc: clang, cxx: clang++ }
env:
boost_version: 1.83.0
BOOST_ROOT: ${{ github.workspace }}\deps\boost_1_83_0
build_script: ${{ matrix.compiler == 'msvc' && './build.bat' || './build-clang.bat' }}
RIME_PLUGINS: ${{ inputs.rime_plugins }}

steps:
Expand All @@ -30,15 +32,13 @@ jobs:
submodules: recursive

- name: Create env.bat
if: ${{ matrix.compiler == 'msvc' }}
run: |
$envfile = ".\env.bat"
$envcontent = @"
set RIME_ROOT=%CD%
if not defined BOOST_ROOT set BOOST_ROOT=%RIME_ROOT%\deps\boost_1_83_0
set CXX=cl
set CC=cl
set CXX=${{ matrix.cxx }}
set CC=${{ matrix.cc }}
set CMAKE_GENERATOR=Ninja
"@
Set-Content -Path $envfile -Value $envcontent
Expand Down Expand Up @@ -95,13 +95,13 @@ jobs:

- name: Build dependencies
if: steps.cache-deps.outputs.cache-hit != 'true'
run: ${{ env.build_script }} deps
run: .\build.bat deps

- name: Install Rime plugins
run: .\action-install-plugins-windows.bat

- name: Build and test
run: ${{ env.build_script }} test
run: .\build.bat test

- name: Create distributable
run: |
Expand Down
14 changes: 7 additions & 7 deletions README-mac.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ These dependencies include a few compiled (non-header-only) Boost libraries.

``` sh
cd librime
make xcode/deps/boost
bash install-boost.sh
```

The make script will download Boost source tarball, extract it to
Expand Down Expand Up @@ -82,7 +82,7 @@ Required third-party libraries other than Boost are included as git submodules:
# if you didn't checked out the submodules with git clone --recursive, now do:
# git submodule update --init

make xcode/deps
make deps
```

This builds libraries located at `librime/deps/*`, and installs the build
Expand All @@ -91,33 +91,33 @@ artifacts to `librime/include`, `librime/lib` and `librime/bin`.
You can also build an individual library, eg. `opencc`, with:

``` sh
make xcode/deps/opencc
make deps/opencc
```

## Build librime

``` sh
make xcode
make
```
This creates `build/lib/Release/librime*.dylib` and command line tools
`build/bin/Release/rime_*`.

Or, create a debug build:

``` sh
make xcode/debug
make debug
```

## Run unit tests

``` sh
make xcode/test
make test
```

Or, test the debug build:

``` sh
make xcode/test-debug
make test-debug
```

## Try it in the console
Expand Down
134 changes: 0 additions & 134 deletions build-clang.bat

This file was deleted.

32 changes: 17 additions & 15 deletions build.bat
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@echo off
rem Rime build script for msvc toolchain.
rem Rime build script for Windows platform.
rem Maintainer: Chen Gong <[email protected]>

setlocal
Expand Down Expand Up @@ -100,23 +100,25 @@ if defined ARCH (
if defined PLATFORM_TOOLSET (
set common_cmake_flags=%common_cmake_flags% -T%PLATFORM_TOOLSET%
)

set common_cmake_flags=%common_cmake_flags%^
-DCMAKE_CONFIGURATION_TYPES:STRING="%build_config%"^
-DCMAKE_BUILD_TYPE:STRING="%build_config%"^
-DCMAKE_USER_MAKE_RULES_OVERRIDE:PATH="%RIME_ROOT%\cmake\c_flag_overrides.cmake"^
-DCMAKE_USER_MAKE_RULES_OVERRIDE_CXX:PATH="%RIME_ROOT%\cmake\cxx_flag_overrides.cmake"^
-DCMAKE_EXE_LINKER_FLAGS_INIT:STRING="-llibcmt"^
-DCMAKE_MSVC_RUNTIME_LIBRARY="MultiThreaded$<$<CONFIG:Debug>:Debug>"

set deps_cmake_flags=%common_cmake_flags%^
-DCMAKE_CONFIGURATION_TYPES:STRING="%build_config%"^
-DCMAKE_BUILD_TYPE:STRING="%build_config%"^
-DCMAKE_CXX_FLAGS_RELEASE:STRING="/MT /O2 /Ob2 /DNDEBUG"^
-DCMAKE_C_FLAGS_RELEASE:STRING="/MT /O2 /Ob2 /DNDEBUG"^
-DCMAKE_CXX_FLAGS_DEBUG:STRING="/MTd /Od"^
-DCMAKE_C_FLAGS_DEBUG:STRING="/MTd /Od"^
-DCMAKE_INSTALL_PREFIX:PATH="%RIME_ROOT%"
-DBUILD_SHARED_LIBS:BOOL=OFF^
-DCMAKE_INSTALL_PREFIX:PATH="%RIME_ROOT%"

if %build_deps% == 1 (
echo building glog.
pushd deps\glog
cmake . -B%build_dir% %deps_cmake_flags%^
-DBUILD_SHARED_LIBS:BOOL=OFF^
-DBUILD_TESTING:BOOL=OFF^
-DWITH_GFLAGS:BOOL=OFF^
-DCMAKE_MSVC_RUNTIME_LIBRARY="MultiThreaded$<$<CONFIG:Debug>:Debug>"
-DWITH_GFLAGS:BOOL=OFF
if errorlevel 1 goto error
cmake --build %build_dir% --config %build_config% --target install
if errorlevel 1 goto error
Expand Down Expand Up @@ -164,9 +166,11 @@ if %build_deps% == 1 (

echo building opencc.
pushd deps\opencc
powershell -NoProfile -c "$Content = gc CMakeLists.txt; if ($Content[212] -match ' find_library\(LIBMARISA NAMES marisa\)') { $Content[212] = ' find_package(marisa)', ' set(LIBMARISA marisa)'; } sc CMakeLists.txt $Content"
cmake . -B%build_dir% %deps_cmake_flags%^
-DBUILD_SHARED_LIBS=OFF^
-DBUILD_TESTING=OFF
-DBUILD_TESTING=OFF^
-DUSE_SYSTEM_MARISA=ON^
-Dmarisa_DIR="%RIME_ROOT%\lib\cmake\marisa"
if errorlevel 1 goto error
cmake --build %build_dir% --config %build_config% --target install
if errorlevel 1 goto error
Expand All @@ -180,8 +184,6 @@ set rime_cmake_flags=%common_cmake_flags%^
-DBUILD_SHARED_LIBS=%build_shared%^
-DBUILD_TEST=%build_test%^
-DENABLE_LOGGING=%enable_logging%^
-DCMAKE_CONFIGURATION_TYPES="%build_config%"^
-DCMAKE_BUILD_TYPE:STRING="%build_config%"^
-DCMAKE_INSTALL_PREFIX:PATH="%RIME_ROOT%\dist"

echo on
Expand Down
3 changes: 3 additions & 0 deletions cmake/cxx_flag_overrides.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ if(WIN32)
set(CMAKE_CXX_FLAGS_MINSIZEREL_INIT "/MT /O1 /Ob1 /D NDEBUG")
set(CMAKE_CXX_FLAGS_RELEASE_INIT "/MT /O2 /Ob2 /D NDEBUG")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "/MT /Zi /Od /Ob1 /D NDEBUG")
elseif(MINGW)
set(CMAKE_CXX_FLAGS_RELEASE_INIT "-D_MT -O3 -DNDEBUG")
else()
set(CMAKE_CXX_FLAGS_RELEASE_INIT "-D_MT -O3 -DNDEBUG")
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-Wno-error=deprecated-declarations")
endif()
endif()
2 changes: 1 addition & 1 deletion deps/marisa-trie
3 changes: 2 additions & 1 deletion plugins/plugins_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// Distributed under the BSD License
//

#include <algorithm>
#include <boost/algorithm/string.hpp>
#include <boost/dll.hpp>
#include <filesystem>
Expand Down Expand Up @@ -78,7 +79,7 @@ string PluginManager::plugin_name_of(fs::path plugin_file) {
}
// replace dash with underscore, for the plugin name is part of the module
// initializer function name.
boost::replace_all(name, "-", "_");
std::replace(name.begin(), name.end(), '-', '_');
return name;
}

Expand Down
36 changes: 13 additions & 23 deletions src/rime/algo/utilities.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,25 @@
//
#include <fstream>
#include <sstream>
#include <boost/algorithm/string.hpp>
#include <rime/algo/utilities.h>

namespace rime {

int CompareVersionString(const string& x, const string& y) {
if (x.empty() && y.empty())
return 0;
if (x.empty())
return -1;
if (y.empty())
return 1;
vector<string> xx, yy;
boost::split(xx, x, boost::is_any_of("."));
boost::split(yy, y, boost::is_any_of("."));
size_t i = 0;
for (; i < xx.size() && i < yy.size(); ++i) {
int dx = atoi(xx[i].c_str());
int dy = atoi(yy[i].c_str());
if (dx != dy)
return dx - dy;
int c = xx[i].compare(yy[i]);
if (c != 0)
return c;
size_t i = 0, j = 0, m = x.size(), n = y.size();
while (i < m || j < n) {
int v1 = 0, v2 = 0;
while (i < m && x[i] != '.')
v1 = v1 * 10 + (int)(x[i++] - '0');
++i;
while (j < n && y[j] != '.')
v2 = v2 * 10 + (int)(y[j++] - '0');
++j;
if (v1 > v2)
return 1;
if (v1 < v2)
return -1;
}
if (i < xx.size())
return 1;
if (i < yy.size())
return -1;
return 0;
}

Expand Down
Loading

0 comments on commit 8779bc8

Please sign in to comment.