Skip to content

Commit

Permalink
build(build.bat) add envvar build_dir
Browse files Browse the repository at this point in the history
  • Loading branch information
lotem committed Mar 6, 2024
1 parent 102d421 commit 761bc40
Showing 1 changed file with 18 additions and 19 deletions.
37 changes: 18 additions & 19 deletions build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,12 @@ exit /b 1
echo BOOST_ROOT=%BOOST_ROOT%
echo.

set clean=0
set build_dir_base=build
set build_dir_suffix=
set build_config=Release
set build_deps=0
set build_librime=0
set build_shared=ON
set build_test=OFF
set clean=0
set enable_logging=ON

:parse_cmdline_options
Expand All @@ -44,23 +42,21 @@ rem `thirdparty` is deprecated in favor of `deps`
if "%1" == "thirdparty" set build_deps=1
if "%1" == "librime" set build_librime=1
if "%1" == "static" (
set build_dir_suffix=-static
set build_shared=OFF
)
if "%1" == "shared" (
set build_dir_suffix=
set build_shared=ON
)
if "%1" == "test" (
set build_librime=1
set build_test=ON
)
if "%1" == "debug" (
set build_dir_base=debug
if not defined build_dir set build_dir=debug
set build_config=Debug
)
if "%1" == "release" (
set build_dir_base=build
if not defined build_dir set build_dir=build
set build_config=Release
)
if "%1" == "logging" (
Expand All @@ -79,18 +75,20 @@ if %build_deps% == 0 (
set build_librime=1
)))

if not defined build_dir set build_dir=build
if not defined deps_install_prefix set deps_install_prefix=%RIME_ROOT%
if not defined rime_install_prefix set rime_install_prefix=%RIME_ROOT%\dist

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
rmdir /s /q %build_dir%
rmdir /s /q deps\glog\%build_dir%
rmdir /s /q deps\googletest\%build_dir%
rmdir /s /q deps\leveldb\%build_dir%
rmdir /s /q deps\marisa-trie\%build_dir%
rmdir /s /q deps\opencc\%build_dir%
rmdir /s /q deps\yaml-cpp\%build_dir%
)

set build_dir=%build_dir_base%%build_dir_suffix%

if defined CMAKE_GENERATOR (
set common_cmake_flags=%common_cmake_flags% -G%CMAKE_GENERATOR%
)
Expand All @@ -111,7 +109,7 @@ set common_cmake_flags=%common_cmake_flags%^

set deps_cmake_flags=%common_cmake_flags%^
-DBUILD_SHARED_LIBS:BOOL=OFF^
-DCMAKE_INSTALL_PREFIX:PATH="%RIME_ROOT%"
-DCMAKE_INSTALL_PREFIX:PATH="%deps_install_prefix%"

if %build_deps% == 1 (
echo building glog.
Expand Down Expand Up @@ -184,7 +182,8 @@ set rime_cmake_flags=%common_cmake_flags%^
-DBUILD_SHARED_LIBS=%build_shared%^
-DBUILD_TEST=%build_test%^
-DENABLE_LOGGING=%enable_logging%^
-DCMAKE_INSTALL_PREFIX:PATH="%RIME_ROOT%\dist"
-DCMAKE_PREFIX_PATH:PATH="%deps_install_prefix%"^
-DCMAKE_INSTALL_PREFIX:PATH="%rime_install_prefix%"

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

if "%build_test%" == "ON" (
copy /y dist\lib\rime.dll %build_dir%\test
copy /y %rime_install_prefix%\lib\rime.dll %build_dir%\test
ctest --test-dir %build_dir%\test -C %build_config% --output-on-failure
if errorlevel 1 goto error
)
Expand Down

0 comments on commit 761bc40

Please sign in to comment.