diff --git a/.github/workflows/windows-build.yml b/.github/workflows/windows-build.yml index 460581d5a..a7b4c5f89 100644 --- a/.github/workflows/windows-build.yml +++ b/.github/workflows/windows-build.yml @@ -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: @@ -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 @@ -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: | diff --git a/build-clang.bat b/build-clang.bat deleted file mode 100644 index 44772c7a4..000000000 --- a/build-clang.bat +++ /dev/null @@ -1,134 +0,0 @@ -@echo off - -if "%BOOST_ROOT%" == "" ( - echo Please set BOOST_ROOT environment variable. - exit -) - -set RIME_ROOT=%CD% - -@REM Build for native architecture -set arch=x86 -if "%PROCESSOR_ARCHITECTURE%" == "ARM64" set arch=arm - -set clean=0 -set build_deps=0 -set build_librime=0 -set build_test=OFF - -:parse_cmdline_options -if "%1" == "" goto end_parsing_cmdline_options -if "%1" == "clean" set clean=1 -if "%1" == "deps" set build_deps=1 -if "%1" == "librime" set build_librime=1 -if "%1" == "test" ( - set build_librime=1 - set build_test=ON -) -shift -goto parse_cmdline_options -:end_parsing_cmdline_options - -if %clean% == 0 ( -if %build_deps% == 0 ( - set build_librime=1 -)) - -if %clean% == 1 ( - rmdir /s /q build - rmdir /s /q deps\glog\build - rmdir /s /q deps\googletest\build - rmdir /s /q deps\leveldb\build - rmdir /s /q deps\marisa-trie\build - rmdir /s /q deps\opencc\build - rmdir /s /q deps\yaml-cpp\build -) - -set common_cmake_flags=-B build^ - -G Ninja^ - -DCMAKE_C_COMPILER=clang^ - -DCMAKE_CXX_COMPILER=clang++^ - -DCMAKE_BUILD_TYPE:STRING=Release^ - -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:STRING=MultiThreaded - -set deps_cmake_flags=%common_cmake_flags%^ - -DBUILD_SHARED_LIBS:BOOL=OFF^ - -DCMAKE_INSTALL_PREFIX:PATH="%RIME_ROOT%" - -if %build_deps% == 1 ( - echo building glog. - pushd deps\glog - cmake . %deps_cmake_flags%^ - -DWITH_GFLAGS:BOOL=OFF^ - -DBUILD_TESTING:BOOL=OFF || exit - cmake --build build || exit - cmake --install build || exit - popd - - echo building leveldb. - pushd deps\leveldb - cmake . %deps_cmake_flags%^ - -DCMAKE_CXX_FLAGS:STRING="-Wno-error=deprecated-declarations"^ - -DLEVELDB_BUILD_BENCHMARKS:BOOL=OFF^ - -DLEVELDB_BUILD_TESTS:BOOL=OFF || exit - cmake --build build || exit - cmake --install build || exit - popd - - echo building yaml-cpp. - pushd deps\yaml-cpp - cmake . %deps_cmake_flags%^ - -DYAML_CPP_BUILD_CONTRIB:BOOL=OFF^ - -DYAML_CPP_BUILD_TESTS:BOOL=OFF^ - -DYAML_CPP_BUILD_TOOLS:BOOL=OFF || exit - cmake --build build || exit - cmake --install build || exit - popd - - echo building gtest. - pushd deps\googletest - cmake . %deps_cmake_flags%^ - -DBUILD_GMOCK:BOOL=OFF || exit - cmake --build build || exit - cmake --install build || exit - popd - - echo building marisa. - pushd deps\marisa-trie - cmake . %deps_cmake_flags% || exit - cmake --build build || exit - cmake --install build || exit - popd - - echo building opencc. - pushd deps\opencc - cmake . %deps_cmake_flags%^ - -DCMAKE_CXX_FLAGS:STRING="-I %RIME_ROOT%\include -L %RIME_ROOT%\lib"^ - -DUSE_SYSTEM_MARISA:BOOL=ON || exit - cmake --build build || exit - cmake --install build || exit - popd -) - -set rime_cmake_flags=%common_cmake_flags%^ - -DBUILD_STATIC:BOOL=ON^ - -DBUILD_SHARED_LIBS:BOOL=ON^ - -DBUILD_TEST:BOOL="%build_test%"^ - -DENABLE_LOGGING:BOOL=ON^ - -DCMAKE_INSTALL_PREFIX:PATH="%RIME_ROOT%\dist" - -if %build_librime% == 1 ( - echo building librime. - cmake . %rime_cmake_flags% || exit - cmake --build build || exit - cmake --install build || exit -) - -if "%build_test%" == "ON" ( - pushd build - ctest --output-on-failure - popd -) diff --git a/build.bat b/build.bat index 80e8e2022..5829e4fa5 100644 --- a/build.bat +++ b/build.bat @@ -1,5 +1,5 @@ @echo off -rem Rime build script for msvc toolchain. +rem Rime build script for Windows platform. rem Maintainer: Chen Gong setlocal @@ -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$<$: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$<$:Debug>" + -DWITH_GFLAGS:BOOL=OFF if errorlevel 1 goto error cmake --build %build_dir% --config %build_config% --target install if errorlevel 1 goto error @@ -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 @@ -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 diff --git a/cmake/cxx_flag_overrides.cmake b/cmake/cxx_flag_overrides.cmake index 73cc9ef95..635489e3d 100644 --- a/cmake/cxx_flag_overrides.cmake +++ b/cmake/cxx_flag_overrides.cmake @@ -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() diff --git a/deps/marisa-trie b/deps/marisa-trie index 5d0014973..0d4e8ab58 160000 --- a/deps/marisa-trie +++ b/deps/marisa-trie @@ -1 +1 @@ -Subproject commit 5d00149732379d3d3c9540ef75b9222a1be0335e +Subproject commit 0d4e8ab58eec355facf8f65ff11ef811b330e373