Skip to content

Commit 761bc40

Browse files
committed
build(build.bat) add envvar build_dir
1 parent 102d421 commit 761bc40

File tree

1 file changed

+18
-19
lines changed

1 file changed

+18
-19
lines changed

build.bat

+18-19
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,12 @@ exit /b 1
2626
echo BOOST_ROOT=%BOOST_ROOT%
2727
echo.
2828

29-
set clean=0
30-
set build_dir_base=build
31-
set build_dir_suffix=
3229
set build_config=Release
3330
set build_deps=0
3431
set build_librime=0
3532
set build_shared=ON
3633
set build_test=OFF
34+
set clean=0
3735
set enable_logging=ON
3836

3937
:parse_cmdline_options
@@ -44,23 +42,21 @@ rem `thirdparty` is deprecated in favor of `deps`
4442
if "%1" == "thirdparty" set build_deps=1
4543
if "%1" == "librime" set build_librime=1
4644
if "%1" == "static" (
47-
set build_dir_suffix=-static
4845
set build_shared=OFF
4946
)
5047
if "%1" == "shared" (
51-
set build_dir_suffix=
5248
set build_shared=ON
5349
)
5450
if "%1" == "test" (
5551
set build_librime=1
5652
set build_test=ON
5753
)
5854
if "%1" == "debug" (
59-
set build_dir_base=debug
55+
if not defined build_dir set build_dir=debug
6056
set build_config=Debug
6157
)
6258
if "%1" == "release" (
63-
set build_dir_base=build
59+
if not defined build_dir set build_dir=build
6460
set build_config=Release
6561
)
6662
if "%1" == "logging" (
@@ -79,18 +75,20 @@ if %build_deps% == 0 (
7975
set build_librime=1
8076
)))
8177

78+
if not defined build_dir set build_dir=build
79+
if not defined deps_install_prefix set deps_install_prefix=%RIME_ROOT%
80+
if not defined rime_install_prefix set rime_install_prefix=%RIME_ROOT%\dist
81+
8282
if %clean% == 1 (
83-
rmdir /s /q build
84-
rmdir /s /q deps\glog\build
85-
rmdir /s /q deps\googletest\build
86-
rmdir /s /q deps\leveldb\build
87-
rmdir /s /q deps\marisa-trie\build
88-
rmdir /s /q deps\opencc\build
89-
rmdir /s /q deps\yaml-cpp\build
83+
rmdir /s /q %build_dir%
84+
rmdir /s /q deps\glog\%build_dir%
85+
rmdir /s /q deps\googletest\%build_dir%
86+
rmdir /s /q deps\leveldb\%build_dir%
87+
rmdir /s /q deps\marisa-trie\%build_dir%
88+
rmdir /s /q deps\opencc\%build_dir%
89+
rmdir /s /q deps\yaml-cpp\%build_dir%
9090
)
9191

92-
set build_dir=%build_dir_base%%build_dir_suffix%
93-
9492
if defined CMAKE_GENERATOR (
9593
set common_cmake_flags=%common_cmake_flags% -G%CMAKE_GENERATOR%
9694
)
@@ -111,7 +109,7 @@ set common_cmake_flags=%common_cmake_flags%^
111109

112110
set deps_cmake_flags=%common_cmake_flags%^
113111
-DBUILD_SHARED_LIBS:BOOL=OFF^
114-
-DCMAKE_INSTALL_PREFIX:PATH="%RIME_ROOT%"
112+
-DCMAKE_INSTALL_PREFIX:PATH="%deps_install_prefix%"
115113

116114
if %build_deps% == 1 (
117115
echo building glog.
@@ -184,7 +182,8 @@ set rime_cmake_flags=%common_cmake_flags%^
184182
-DBUILD_SHARED_LIBS=%build_shared%^
185183
-DBUILD_TEST=%build_test%^
186184
-DENABLE_LOGGING=%enable_logging%^
187-
-DCMAKE_INSTALL_PREFIX:PATH="%RIME_ROOT%\dist"
185+
-DCMAKE_PREFIX_PATH:PATH="%deps_install_prefix%"^
186+
-DCMAKE_INSTALL_PREFIX:PATH="%rime_install_prefix%"
188187

189188
echo on
190189
call cmake . -B%build_dir% %rime_cmake_flags%
@@ -200,7 +199,7 @@ cmake --build %build_dir% --config %build_config% --target install
200199
if errorlevel 1 goto error
201200

202201
if "%build_test%" == "ON" (
203-
copy /y dist\lib\rime.dll %build_dir%\test
202+
copy /y %rime_install_prefix%\lib\rime.dll %build_dir%\test
204203
ctest --test-dir %build_dir%\test -C %build_config% --output-on-failure
205204
if errorlevel 1 goto error
206205
)

0 commit comments

Comments
 (0)