Skip to content

Commit

Permalink
Use designated build directory for glog (rime#739)
Browse files Browse the repository at this point in the history
  • Loading branch information
groverlynn authored and WhiredPlanck committed Oct 18, 2023
1 parent bede844 commit f8dce39
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 161 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
134 changes: 0 additions & 134 deletions build-clang.bat

This file was deleted.

38 changes: 20 additions & 18 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 @@ -81,7 +81,7 @@ if %build_deps% == 0 (

if %clean% == 1 (
rmdir /s /q build
rmdir /s /q deps\glog\cmake-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
Expand All @@ -100,31 +100,34 @@ 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 . -Bcmake-%build_dir% %deps_cmake_flags%^
-DBUILD_SHARED_LIBS:BOOL=OFF^
cmake . -B%build_dir% %deps_cmake_flags%^
-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 cmake-%build_dir% --config %build_config% --target install
cmake --build %build_dir% --config %build_config% --target install
if errorlevel 1 goto error
popd

echo building leveldb.
pushd deps\leveldb
cmake . -B%build_dir% %deps_cmake_flags%^
-Wno-error=deprecated^
-DLEVELDB_BUILD_BENCHMARKS:BOOL=OFF^
-DLEVELDB_BUILD_TESTS:BOOL=OFF
if errorlevel 1 goto error
Expand Down Expand Up @@ -165,8 +168,9 @@ if %build_deps% == 1 (
echo building opencc.
pushd deps\opencc
cmake . -B%build_dir% %deps_cmake_flags%^
-DBUILD_SHARED_LIBS=OFF^
-DBUILD_TESTING=OFF
-DCMAKE_LIBRARY_PATH="%RIME_ROOT%\lib"^
-DBUILD_TESTING=OFF^
-DUSE_SYSTEM_MARISA=ON
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: 1 addition & 2 deletions deps.mk
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ ifndef NOPARALLEL
export MAKEFLAGS+=" -j$(( $(nproc) + 1)) "
endif

glog: build ?= cmake-build
build ?= build

rime_deps = glog gtest leveldb marisa opencc yaml-cpp
Expand All @@ -18,7 +17,7 @@ all: $(rime_deps)

# note: this won't clean output files under include/, lib/ and bin/.
clean-src:
rm -r $(src_dir)/glog/cmake-build || true
rm -r $(src_dir)/glog/build || true
rm -r $(src_dir)/googletest/build || true
rm -r $(src_dir)/leveldb/build || true
rm -r $(src_dir)/marisa-trie/build || true
Expand Down

0 comments on commit f8dce39

Please sign in to comment.