From d5aa01071903819f6d9b1c3cd41c5f38de3b0f68 Mon Sep 17 00:00:00 2001 From: Chen Gong Date: Sun, 18 Feb 2018 21:55:09 +0800 Subject: [PATCH 1/6] feat(build.bat): customize build settings via environment variables --- README-windows.md | 13 ++-- build.bat | 71 ++++++++++++++++--- env.bat.template | 18 +++-- shell.bat | 71 ------------------- .../src/leveldb-windows/leveldb.vcxproj | 8 +-- .../vs2015/base-test/base-test.vcxproj | 4 +- .../vs2015/io-test/io-test.vcxproj | 4 +- .../vs2015/libmarisa/libmarisa.vcxproj | 4 +- .../marisa-benchmark/marisa-benchmark.vcxproj | 4 +- .../vs2015/marisa-build/marisa-build.vcxproj | 4 +- .../marisa-common-prefix-search.vcxproj | 4 +- .../vs2015/marisa-dump/marisa-dump.vcxproj | 4 +- .../marisa-lookup/marisa-lookup.vcxproj | 4 +- .../marisa-predictive-search.vcxproj | 4 +- .../marisa-reverse-lookup.vcxproj | 4 +- .../vs2015/marisa-test/marisa-test.vcxproj | 4 +- .../vs2015/trie-test/trie-test.vcxproj | 4 +- .../vs2015/vector-test/vector-test.vcxproj | 4 +- 18 files changed, 111 insertions(+), 122 deletions(-) delete mode 100644 shell.bat diff --git a/README-windows.md b/README-windows.md index 99186a8f8..4a6f2d930 100644 --- a/README-windows.md +++ b/README-windows.md @@ -7,10 +7,12 @@ librime is tested to work on Windows with the following build tools and librarie - Visual Studio 2015 - [Boost](http://www.boost.org/)>=1.60 - [cmake](http://www.cmake.org/)>=2.8 + +[Python](https://python.org)>=2.7 is needed to build opencc dictionaries. You may need to update Boost when using a higher version of VS. -You can also build third-party libraries manually without them, by following instructions in the build script. +You can also build third-party libraries manually, by following instructions in the build script. Get the code --- @@ -21,11 +23,12 @@ or [download from GitHub](https://github.com/rime/librime). Setup a build environment --- -Copy `env.bat` from `env.bat.template` and edit the script according to your setup. -Specifically, make sure `BOOST_ROOT` is set to the path where you extracted Boost source; -modify `*_INSTALL_PATH` if you've installed build tools in a custom location. +Copy `env.bat.template` to `env.bat` and edit the script according to your setup. +Specifically, make sure `BOOST_ROOT` is set to the path to Boost source directory; +modify `CMAKE_GENERATOR` and `PLATFORM_TOOLSET` if using a different version of Visual Studio; +set `DEVTOOLS_PATH` for build tools installed to a custom location. -When finished, run `shell.bat` to complete the following steps in a prepared command prompt. +When prepared, run the following commands in a Developer Command Prompt window. Build Boost --- diff --git a/build.bat b/build.bat index bb3712336..5183efd24 100644 --- a/build.bat +++ b/build.bat @@ -1,6 +1,6 @@ @echo off rem Rime build script for msvc toolchain. -rem 2014-12-30 Chen Gong +rem Maintainer: Chen Gong setlocal set BACK=%CD% @@ -8,7 +8,7 @@ set BACK=%CD% if exist env.bat call env.bat set OLD_PATH=%PATH% -if defined DEV_PATH set PATH=%OLD_PATH%;%DEV_PATH% +if defined DEVTOOLS_PATH set PATH=%OLD_PATH%;%DEVTOOLS_PATH% path echo. @@ -16,16 +16,37 @@ if not defined RIME_ROOT set RIME_ROOT=%CD% echo RIME_ROOT=%RIME_ROOT% echo. +if defined BOOST_ROOT ( + if exist "%BOOST_ROOT%\boost" goto boost_found +) +echo Error: Boost not found! Please set BOOST_ROOT in env.bat. +exit /b 1 +:boost_found echo BOOST_ROOT=%BOOST_ROOT% echo. -if defined CMAKE_INSTALL_PATH set PATH=%PATH%;%CMAKE_INSTALL_PATH% +if not defined BJAM_TOOLSET ( + set BJAM_TOOLSET=msvc-%VisualStudioVersion% +) + +if not defined CMAKE_GENERATOR ( + set CMAKE_GENERATOR="Visual Studio 14 2015" +) -set CMAKE_GENERATOR="Visual Studio 14 2015" -set CMAKE_TOOLSET="v140_xp" +if not defined PLATFORM_TOOLSET ( + set PLATFORM_TOOLSET=v140_xp +) + +if not defined CMAKE_TOOLSET ( + set CMAKE_TOOLSET="%PLATFORM_TOOLSET%" +) + +rem used when building merisa +set VS_LATEST=vs2015 set build=build set build_boost=0 +set build_boost_x64=0 set build_thirdparty=0 set build_librime=0 set build_shared=ON @@ -37,6 +58,7 @@ if "%1" == "" set build_librime=1 :parse_cmdline_options if "%1" == "" goto end_parsing_cmdline_options if "%1" == "boost" set build_boost=1 +if "%1" == "boost_x64" set build_boost_x64=1 if "%1" == "thirdparty" set build_thirdparty=1 if "%1" == "librime" set build_librime=1 if "%1" == "static" ( @@ -66,14 +88,36 @@ set THIRDPARTY="%RIME_ROOT%"\thirdparty rem set CURL=%THIRDPARTY%\bin\curl.exe rem set DOWNLOAD="%CURL%" --remote-name-all +set BOOST_COMPILED_LIBS=--with-date_time^ + --with-filesystem^ + --with-locale^ + --with-regex^ + --with-signals^ + --with-system^ + --with-thread + +set BJAM_OPTIONS=toolset=%BJAM_TOOLSET%^ + variant=release^ + link=static^ + threading=multi^ + runtime-link=static + +set BJAM_OPTIONS_X64=%BJAM_OPTIONS%^ + address-model=64^ + --stagedir=stage_x64 + if %build_boost% == 1 ( cd /d %BOOST_ROOT% if not exist bjam.exe call bootstrap.bat if %ERRORLEVEL% NEQ 0 goto ERROR - bjam toolset=msvc-14.0 variant=release link=static threading=multi runtime-link=static stage --with-date_time --with-filesystem --with-locale --with-regex --with-signals --with-system --with-thread + + bjam %BJAM_OPTIONS% stage %BOOST_COMPILED_LIBS% if %ERRORLEVEL% NEQ 0 goto ERROR - rem bjam toolset=msvc-14.0 variant=release link=static threading=multi runtime-link=static address-model=64 --stagedir=stage_x64 stage --with-date_time --with-filesystem --with-locale --with-regex --with-signals --with-system --with-thread - rem if %ERRORLEVEL% NEQ 0 goto ERROR + + if %build_boost_x64% == 1 ( + bjam %BJAM_OPTIONS_X64% stage %BOOST_COMPILED_LIBS% + if %ERRORLEVEL% NEQ 0 goto ERROR + ) ) if %build_thirdparty% == 1 ( @@ -127,8 +171,8 @@ if %build_thirdparty% == 1 ( if %ERRORLEVEL% NEQ 0 goto ERROR echo building marisa. - cd %THIRDPARTY%\src\marisa-trie\vs2015 - msbuild.exe vs2015.sln /p:Configuration=Release /p:Platform=Win32 + cd %THIRDPARTY%\src\marisa-trie\%VS_LATEST% + msbuild.exe %VS_LATEST%.sln /p:Configuration=Release /p:Platform=Win32 if %ERRORLEVEL% NEQ 0 goto ERROR echo built. copying artifacts. xcopy /S /I /Y ..\lib\marisa %THIRDPARTY%\include\marisa\ @@ -168,7 +212,12 @@ if %build_thirdparty% == 1 ( if %build_librime% == 0 goto EXIT -set RIME_CMAKE_FLAGS=-DBUILD_STATIC=ON -DBUILD_SHARED_LIBS=%build_shared% -DBUILD_TEST=%build_test% -DENABLE_LOGGING=%enable_logging% -DBOOST_USE_CXX11=ON -DCMAKE_CONFIGURATION_TYPES="Release" +set RIME_CMAKE_FLAGS=-DBUILD_STATIC=ON^ + -DBUILD_SHARED_LIBS=%build_shared%^ + -DBUILD_TEST=%build_test%^ + -DENABLE_LOGGING=%enable_logging%^ + -DBOOST_USE_CXX11=ON^ + -DCMAKE_CONFIGURATION_TYPES="Release" cd /d %RIME_ROOT% echo cmake %RIME_ROOT% -B%build% -G%CMAKE_GENERATOR% -T%CMAKE_TOOLSET% %RIME_CMAKE_FLAGS% diff --git a/env.bat.template b/env.bat.template index 6bd984dde..2a9397721 100644 --- a/env.bat.template +++ b/env.bat.template @@ -1,6 +1,14 @@ -rem environment settings +rem Customize your build environment and save the modified copy to env.bat + set RIME_ROOT=%CD% -set BOOST_ROOT=\code\boost_1_60_0 -set CMAKE_INSTALL_PATH=C:\Program Files (x86)\CMake -set GIT_INSTALL_PATH=C:\Program Files (x86)\Git -set VS_INSTALL_PATH=%VS140COMNTOOLS%\..\.. + +rem REQUIRED: path to Boost source directory +set BOOST_ROOT=%USERPROFILE%\source\vendor\boost_1_60_0 + +rem OPTIONAL: Visual Studio version and platform toolset +rem set BJAM_TOOLSET=msvc-14.0 +rem set CMAKE_GENERATOR="Visual Studio 14 2015" +rem set PLATFORM_TOOLSET=v140_xp + +rem OPTIONAL: path to additional build tools +rem set DEVTOOLS_PATH=%ProgramFiles%\Git\cmd;%ProgramFiles%\CMake\bin;C:\Python27; diff --git a/shell.bat b/shell.bat deleted file mode 100644 index 34a8a0f06..000000000 --- a/shell.bat +++ /dev/null @@ -1,71 +0,0 @@ -@echo off -setlocal -if exist env.bat call env.bat - -if defined BOOST_ROOT ( - if exist "%BOOST_ROOT%\boost" goto boost_found -) -echo Boost not found! please set BOOST_ROOT in env.bat. -exit /b 1 -:boost_found - -if defined CMAKE_INSTALL_PATH ( - if exist "%CMAKE_INSTALL_PATH%\bin" goto cmake_found -) -echo Detecting CMake install path. -set CMAKE_INSTALL_PATH=%ProgramFiles(x86)%\CMake -if exist "%CMAKE_INSTALL_PATH%\bin" goto cmake_found -set CMAKE_INSTALL_PATH=%ProgramFiles%\CMake -if exist "%CMAKE_INSTALL_PATH%\bin" goto cmake_found -set CMAKE_INSTALL_PATH= -echo CMake not found! please set CMAKE_INSTALL_PATH in env.bat. -exit /b 1 -:cmake_found - -if defined GIT_INSTALL_PATH ( - if exist "%GIT_INSTALL_PATH%\bin" goto git_found -) -echo Detecting Git install path. -set GIT_INSTALL_PATH=%ProgramFiles(x86)%\Git -if exist "%GIT_INSTALL_PATH%\bin" goto git_found -set GIT_INSTALL_PATH=%ProgramFiles%\Git -if exist "%GIT_INSTALL_PATH%\bin" goto git_found -set GIT_INSTALL_PATH= -echo Git not found! please set GIT_INSTALL_PATH in env.bat. -exit /b 1 -:git_found - -if defined VS_INSTALL_PATH ( - if exist "%VS_INSTALL_PATH%\VC" goto vs_found -) -echo Detecting Visual Studio install path. -set VS_INSTALL_PATH=%ProgramFiles(x86)%\Microsoft Visual Studio 12.0 -if exist "%VS_INSTALL_PATH%\VC" goto vs_found -set VS_INSTALL_PATH=%ProgramFiles%\Microsoft Visual Studio 12.0 -if exist "%VS_INSTALL_PATH%\VC" goto vs_found -set VS_INSTALL_PATH= -echo Visual Studio not found! please set VS_INSTALL_PATH in env.bat. -exit /b 1 -:vs_found - -:start -set OLD_PATH=%PATH% -if defined DEV_PATH set PATH=%OLD_PATH%;%DEV_PATH% - -rem add cmake executable to PATH -set PATH=%PATH%;%CMAKE_INSTALL_PATH%\bin - -rem git start -@rem Get the abolute path to the current directory, which is assumed to be the -@rem Git installation root. -@for /F "delims=" %%I in ("%GIT_INSTALL_PATH%") do @set git_install_root=%%~fI -@set PATH=%git_install_root%\bin;%git_install_root%\mingw\bin;%git_install_root%\cmd;%PATH% -@if not exist "%HOME%" @set HOME=%HOMEDRIVE%%HOMEPATH% -@if not exist "%HOME%" @set HOME=%USERPROFILE% -@set PLINK_PROTOCOL=ssh -@cd %HOME% -rem git end - -rem start command prompt with Visual C++ tools -rem %comspec% -%comspec% /k ""%VS_INSTALL_PATH%\VC\vcvarsall.bat"" x86 diff --git a/thirdparty/src/leveldb-windows/leveldb.vcxproj b/thirdparty/src/leveldb-windows/leveldb.vcxproj index 66f871a5d..de46fb5c0 100644 --- a/thirdparty/src/leveldb-windows/leveldb.vcxproj +++ b/thirdparty/src/leveldb-windows/leveldb.vcxproj @@ -1,4 +1,4 @@ - + @@ -18,12 +18,12 @@ StaticLibrary true - v140_xp + $(PLATFORM_TOOLSET) StaticLibrary false - v140_xp + $(PLATFORM_TOOLSET) @@ -171,4 +171,4 @@ - \ No newline at end of file + diff --git a/thirdparty/src/marisa-trie/vs2015/base-test/base-test.vcxproj b/thirdparty/src/marisa-trie/vs2015/base-test/base-test.vcxproj index c842d6a8a..89733b14f 100644 --- a/thirdparty/src/marisa-trie/vs2015/base-test/base-test.vcxproj +++ b/thirdparty/src/marisa-trie/vs2015/base-test/base-test.vcxproj @@ -18,13 +18,13 @@ Application - v140_xp + $(PLATFORM_TOOLSET) Unicode true Application - v140_xp + $(PLATFORM_TOOLSET) Unicode diff --git a/thirdparty/src/marisa-trie/vs2015/io-test/io-test.vcxproj b/thirdparty/src/marisa-trie/vs2015/io-test/io-test.vcxproj index 544bbfa66..3bc1ef061 100644 --- a/thirdparty/src/marisa-trie/vs2015/io-test/io-test.vcxproj +++ b/thirdparty/src/marisa-trie/vs2015/io-test/io-test.vcxproj @@ -18,13 +18,13 @@ Application - v140_xp + $(PLATFORM_TOOLSET) Unicode true Application - v140_xp + $(PLATFORM_TOOLSET) Unicode diff --git a/thirdparty/src/marisa-trie/vs2015/libmarisa/libmarisa.vcxproj b/thirdparty/src/marisa-trie/vs2015/libmarisa/libmarisa.vcxproj index 8d7a6631e..88e52e0c9 100644 --- a/thirdparty/src/marisa-trie/vs2015/libmarisa/libmarisa.vcxproj +++ b/thirdparty/src/marisa-trie/vs2015/libmarisa/libmarisa.vcxproj @@ -18,13 +18,13 @@ StaticLibrary - v140_xp + $(PLATFORM_TOOLSET) Unicode true StaticLibrary - v140_xp + $(PLATFORM_TOOLSET) Unicode diff --git a/thirdparty/src/marisa-trie/vs2015/marisa-benchmark/marisa-benchmark.vcxproj b/thirdparty/src/marisa-trie/vs2015/marisa-benchmark/marisa-benchmark.vcxproj index a31ff192b..b1b4151e2 100644 --- a/thirdparty/src/marisa-trie/vs2015/marisa-benchmark/marisa-benchmark.vcxproj +++ b/thirdparty/src/marisa-trie/vs2015/marisa-benchmark/marisa-benchmark.vcxproj @@ -18,13 +18,13 @@ Application - v140_xp + $(PLATFORM_TOOLSET) Unicode true Application - v140_xp + $(PLATFORM_TOOLSET) Unicode diff --git a/thirdparty/src/marisa-trie/vs2015/marisa-build/marisa-build.vcxproj b/thirdparty/src/marisa-trie/vs2015/marisa-build/marisa-build.vcxproj index 67db88288..515855a77 100644 --- a/thirdparty/src/marisa-trie/vs2015/marisa-build/marisa-build.vcxproj +++ b/thirdparty/src/marisa-trie/vs2015/marisa-build/marisa-build.vcxproj @@ -18,13 +18,13 @@ Application - v140_xp + $(PLATFORM_TOOLSET) Unicode true Application - v140_xp + $(PLATFORM_TOOLSET) Unicode diff --git a/thirdparty/src/marisa-trie/vs2015/marisa-common-prefix-search/marisa-common-prefix-search.vcxproj b/thirdparty/src/marisa-trie/vs2015/marisa-common-prefix-search/marisa-common-prefix-search.vcxproj index 291377bc4..de5a5f648 100644 --- a/thirdparty/src/marisa-trie/vs2015/marisa-common-prefix-search/marisa-common-prefix-search.vcxproj +++ b/thirdparty/src/marisa-trie/vs2015/marisa-common-prefix-search/marisa-common-prefix-search.vcxproj @@ -18,13 +18,13 @@ Application - v140_xp + $(PLATFORM_TOOLSET) Unicode true Application - v140_xp + $(PLATFORM_TOOLSET) Unicode diff --git a/thirdparty/src/marisa-trie/vs2015/marisa-dump/marisa-dump.vcxproj b/thirdparty/src/marisa-trie/vs2015/marisa-dump/marisa-dump.vcxproj index e846646eb..694308250 100644 --- a/thirdparty/src/marisa-trie/vs2015/marisa-dump/marisa-dump.vcxproj +++ b/thirdparty/src/marisa-trie/vs2015/marisa-dump/marisa-dump.vcxproj @@ -18,13 +18,13 @@ Application - v140_xp + $(PLATFORM_TOOLSET) Unicode true Application - v140_xp + $(PLATFORM_TOOLSET) Unicode diff --git a/thirdparty/src/marisa-trie/vs2015/marisa-lookup/marisa-lookup.vcxproj b/thirdparty/src/marisa-trie/vs2015/marisa-lookup/marisa-lookup.vcxproj index 0d3d999d4..5f0942286 100644 --- a/thirdparty/src/marisa-trie/vs2015/marisa-lookup/marisa-lookup.vcxproj +++ b/thirdparty/src/marisa-trie/vs2015/marisa-lookup/marisa-lookup.vcxproj @@ -18,13 +18,13 @@ Application - v140_xp + $(PLATFORM_TOOLSET) Unicode true Application - v140_xp + $(PLATFORM_TOOLSET) Unicode diff --git a/thirdparty/src/marisa-trie/vs2015/marisa-predictive-search/marisa-predictive-search.vcxproj b/thirdparty/src/marisa-trie/vs2015/marisa-predictive-search/marisa-predictive-search.vcxproj index bfd13722c..1a2acc594 100644 --- a/thirdparty/src/marisa-trie/vs2015/marisa-predictive-search/marisa-predictive-search.vcxproj +++ b/thirdparty/src/marisa-trie/vs2015/marisa-predictive-search/marisa-predictive-search.vcxproj @@ -18,13 +18,13 @@ Application - v140_xp + $(PLATFORM_TOOLSET) Unicode true Application - v140_xp + $(PLATFORM_TOOLSET) Unicode diff --git a/thirdparty/src/marisa-trie/vs2015/marisa-reverse-lookup/marisa-reverse-lookup.vcxproj b/thirdparty/src/marisa-trie/vs2015/marisa-reverse-lookup/marisa-reverse-lookup.vcxproj index a6bfe5cab..bc27ccff6 100644 --- a/thirdparty/src/marisa-trie/vs2015/marisa-reverse-lookup/marisa-reverse-lookup.vcxproj +++ b/thirdparty/src/marisa-trie/vs2015/marisa-reverse-lookup/marisa-reverse-lookup.vcxproj @@ -18,13 +18,13 @@ Application - v140_xp + $(PLATFORM_TOOLSET) Unicode true Application - v140_xp + $(PLATFORM_TOOLSET) Unicode diff --git a/thirdparty/src/marisa-trie/vs2015/marisa-test/marisa-test.vcxproj b/thirdparty/src/marisa-trie/vs2015/marisa-test/marisa-test.vcxproj index 295da141a..a7f941146 100644 --- a/thirdparty/src/marisa-trie/vs2015/marisa-test/marisa-test.vcxproj +++ b/thirdparty/src/marisa-trie/vs2015/marisa-test/marisa-test.vcxproj @@ -18,13 +18,13 @@ Application - v140_xp + $(PLATFORM_TOOLSET) Unicode true Application - v140_xp + $(PLATFORM_TOOLSET) Unicode diff --git a/thirdparty/src/marisa-trie/vs2015/trie-test/trie-test.vcxproj b/thirdparty/src/marisa-trie/vs2015/trie-test/trie-test.vcxproj index efe70ccad..c13e1ef47 100644 --- a/thirdparty/src/marisa-trie/vs2015/trie-test/trie-test.vcxproj +++ b/thirdparty/src/marisa-trie/vs2015/trie-test/trie-test.vcxproj @@ -18,13 +18,13 @@ Application - v140_xp + $(PLATFORM_TOOLSET) Unicode true Application - v140_xp + $(PLATFORM_TOOLSET) Unicode diff --git a/thirdparty/src/marisa-trie/vs2015/vector-test/vector-test.vcxproj b/thirdparty/src/marisa-trie/vs2015/vector-test/vector-test.vcxproj index 5d4b3f613..3c7ba27d7 100644 --- a/thirdparty/src/marisa-trie/vs2015/vector-test/vector-test.vcxproj +++ b/thirdparty/src/marisa-trie/vs2015/vector-test/vector-test.vcxproj @@ -18,13 +18,13 @@ Application - v140_xp + $(PLATFORM_TOOLSET) Unicode true Application - v140_xp + $(PLATFORM_TOOLSET) Unicode From 13dcf02b5594430c501f41a43c9d1ff1ac3ff126 Mon Sep 17 00:00:00 2001 From: Chen Gong Date: Wed, 21 Feb 2018 00:09:52 +0800 Subject: [PATCH 2/6] chore(build.bat): delete variable `CMAKE_TOOLSET` --- build.bat | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/build.bat b/build.bat index 5183efd24..9660b84e9 100644 --- a/build.bat +++ b/build.bat @@ -37,10 +37,6 @@ if not defined PLATFORM_TOOLSET ( set PLATFORM_TOOLSET=v140_xp ) -if not defined CMAKE_TOOLSET ( - set CMAKE_TOOLSET="%PLATFORM_TOOLSET%" -) - rem used when building merisa set VS_LATEST=vs2015 @@ -125,7 +121,7 @@ if %build_thirdparty% == 1 ( echo building glog. cd %THIRDPARTY%\src\glog - cmake . -Bbuild -G%CMAKE_GENERATOR% -T%CMAKE_TOOLSET% -DWITH_GFLAGS=OFF -DCMAKE_CONFIGURATION_TYPES="Release" -DCMAKE_CXX_FLAGS_RELEASE="/MT /O2 /Ob2 /D NDEBUG" -DCMAKE_C_FLAGS_RELEASE="/MT /O2 /Ob2 /D NDEBUG" + cmake . -Bbuild -G%CMAKE_GENERATOR% -T%PLATFORM_TOOLSET% -DWITH_GFLAGS=OFF -DCMAKE_CONFIGURATION_TYPES="Release" -DCMAKE_CXX_FLAGS_RELEASE="/MT /O2 /Ob2 /D NDEBUG" -DCMAKE_C_FLAGS_RELEASE="/MT /O2 /Ob2 /D NDEBUG" if %ERRORLEVEL% NEQ 0 goto ERROR cmake --build build --config Release --target glog if %ERRORLEVEL% NEQ 0 goto ERROR @@ -148,7 +144,7 @@ if %build_thirdparty% == 1 ( echo building yaml-cpp. cd %THIRDPARTY%\src\yaml-cpp - cmake . -Bbuild -G%CMAKE_GENERATOR% -T%CMAKE_TOOLSET% -DMSVC_SHARED_RT=OFF -DYAML_CPP_BUILD_TOOLS=OFF -DCMAKE_CONFIGURATION_TYPES="Release" -DCMAKE_CXX_FLAGS_RELEASE="/MT /O2 /Ob2 /D NDEBUG" -DCMAKE_C_FLAGS_RELEASE="/MT /O2 /Ob2 /D NDEBUG" + cmake . -Bbuild -G%CMAKE_GENERATOR% -T%PLATFORM_TOOLSET% -DMSVC_SHARED_RT=OFF -DYAML_CPP_BUILD_TOOLS=OFF -DCMAKE_CONFIGURATION_TYPES="Release" -DCMAKE_CXX_FLAGS_RELEASE="/MT /O2 /Ob2 /D NDEBUG" -DCMAKE_C_FLAGS_RELEASE="/MT /O2 /Ob2 /D NDEBUG" if %ERRORLEVEL% NEQ 0 goto ERROR cmake --build build --config Release --target yaml-cpp if %ERRORLEVEL% NEQ 0 goto ERROR @@ -160,7 +156,7 @@ if %build_thirdparty% == 1 ( echo building gtest. cd %THIRDPARTY%\src\gtest - cmake . -Bbuild -G%CMAKE_GENERATOR% -T%CMAKE_TOOLSET% -DCMAKE_CONFIGURATION_TYPES="Release" -DCMAKE_CXX_FLAGS_RELEASE="/MT /O2 /Ob2 /D NDEBUG" -DCMAKE_C_FLAGS_RELEASE="/MT /O2 /Ob2 /D NDEBUG" + cmake . -Bbuild -G%CMAKE_GENERATOR% -T%PLATFORM_TOOLSET% -DCMAKE_CONFIGURATION_TYPES="Release" -DCMAKE_CXX_FLAGS_RELEASE="/MT /O2 /Ob2 /D NDEBUG" -DCMAKE_C_FLAGS_RELEASE="/MT /O2 /Ob2 /D NDEBUG" if %ERRORLEVEL% NEQ 0 goto ERROR cmake --build build --config Release if %ERRORLEVEL% NEQ 0 goto ERROR @@ -185,7 +181,7 @@ if %build_thirdparty% == 1 ( echo building opencc. cd %THIRDPARTY%\src\opencc - cmake . -Bbuild -G%CMAKE_GENERATOR% -T%CMAKE_TOOLSET% -DCMAKE_INSTALL_PREFIX="" -DBUILD_SHARED_LIBS=OFF -DBUILD_TESTING=OFF -DCMAKE_CONFIGURATION_TYPES="Release" -DCMAKE_CXX_FLAGS_RELEASE="/MT /O2 /Ob2 /D NDEBUG" + cmake . -Bbuild -G%CMAKE_GENERATOR% -T%PLATFORM_TOOLSET% -DCMAKE_INSTALL_PREFIX="" -DBUILD_SHARED_LIBS=OFF -DBUILD_TESTING=OFF -DCMAKE_CONFIGURATION_TYPES="Release" -DCMAKE_CXX_FLAGS_RELEASE="/MT /O2 /Ob2 /D NDEBUG" if %ERRORLEVEL% NEQ 0 goto ERROR cmake --build build --config Release --target libopencc if %ERRORLEVEL% NEQ 0 goto ERROR @@ -220,8 +216,8 @@ set RIME_CMAKE_FLAGS=-DBUILD_STATIC=ON^ -DCMAKE_CONFIGURATION_TYPES="Release" cd /d %RIME_ROOT% -echo cmake %RIME_ROOT% -B%build% -G%CMAKE_GENERATOR% -T%CMAKE_TOOLSET% %RIME_CMAKE_FLAGS% -call cmake %RIME_ROOT% -B%build% -G%CMAKE_GENERATOR% -T%CMAKE_TOOLSET% %RIME_CMAKE_FLAGS% +echo cmake %RIME_ROOT% -B%build% -G%CMAKE_GENERATOR% -T%PLATFORM_TOOLSET% %RIME_CMAKE_FLAGS% +call cmake %RIME_ROOT% -B%build% -G%CMAKE_GENERATOR% -T%PLATFORM_TOOLSET% %RIME_CMAKE_FLAGS% if %ERRORLEVEL% NEQ 0 goto ERROR echo. From c24ce10f76079cacf65f079ef88188cc9cd4408d Mon Sep 17 00:00:00 2001 From: Prcuvu Date: Wed, 21 Feb 2018 09:33:06 +0800 Subject: [PATCH 3/6] fix(build.bat): Windows XP compatibility --- appveyor.yml | 1 - build.bat | 13 ++++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index b04f7d482..9beb42b74 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -21,7 +21,6 @@ cache: init: - git --version - cmake --version - - msbuild /version - git config --global core.autocrlf true install: diff --git a/build.bat b/build.bat index 9660b84e9..56f1ab40f 100644 --- a/build.bat +++ b/build.bat @@ -7,6 +7,9 @@ set BACK=%CD% if exist env.bat call env.bat +rem for Windows XP compatibility (Visual Studio 2015+) +set CL=/Zc:threadSafeInit- + set OLD_PATH=%PATH% if defined DEVTOOLS_PATH set PATH=%OLD_PATH%;%DEVTOOLS_PATH% path @@ -37,7 +40,7 @@ if not defined PLATFORM_TOOLSET ( set PLATFORM_TOOLSET=v140_xp ) -rem used when building merisa +rem used when building marisa set VS_LATEST=vs2015 set build=build @@ -96,11 +99,15 @@ set BJAM_OPTIONS=toolset=%BJAM_TOOLSET%^ variant=release^ link=static^ threading=multi^ - runtime-link=static + runtime-link=static^ + define=BOOST_USE_WINAPI_VERSION=0x0501^ + cxxflags="/Zc:threadSafeInit- " set BJAM_OPTIONS_X64=%BJAM_OPTIONS%^ address-model=64^ - --stagedir=stage_x64 + --stagedir=stage_x64^ + define=BOOST_USE_WINAPI_VERSION=0x0501^ + cxxflags="/Zc:threadSafeInit- " if %build_boost% == 1 ( cd /d %BOOST_ROOT% From dd17628457b4d84dc7d178ee4a1d6ae61d32c184 Mon Sep 17 00:00:00 2001 From: Chen Gong Date: Wed, 21 Feb 2018 15:15:11 +0800 Subject: [PATCH 4/6] chore(build.bat): remove duplicate bjam options --- build.bat | 2 -- 1 file changed, 2 deletions(-) diff --git a/build.bat b/build.bat index 56f1ab40f..afa672615 100644 --- a/build.bat +++ b/build.bat @@ -106,8 +106,6 @@ set BJAM_OPTIONS=toolset=%BJAM_TOOLSET%^ set BJAM_OPTIONS_X64=%BJAM_OPTIONS%^ address-model=64^ --stagedir=stage_x64^ - define=BOOST_USE_WINAPI_VERSION=0x0501^ - cxxflags="/Zc:threadSafeInit- " if %build_boost% == 1 ( cd /d %BOOST_ROOT% From 93bb6ec1f7facb951ea0c356985f7bd106610547 Mon Sep 17 00:00:00 2001 From: Chen Gong Date: Wed, 21 Feb 2018 15:10:02 +0800 Subject: [PATCH 5/6] fix(build.bat): BJAM_TOOLSET means platform toolset, not %VisualStudioVersion% --- build.bat | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build.bat b/build.bat index afa672615..a316c14e4 100644 --- a/build.bat +++ b/build.bat @@ -29,7 +29,8 @@ echo BOOST_ROOT=%BOOST_ROOT% echo. if not defined BJAM_TOOLSET ( - set BJAM_TOOLSET=msvc-%VisualStudioVersion% + rem the number actually means platform toolset, not %VisualStudioVersion% + set BJAM_TOOLSET=msvc-14.0 ) if not defined CMAKE_GENERATOR ( From 5a57e29a035140d35d3e7a38f5d269142d297289 Mon Sep 17 00:00:00 2001 From: Chen Gong Date: Wed, 21 Feb 2018 15:45:24 +0800 Subject: [PATCH 6/6] fix(build.bat): set WINAPI_VERSION for x64 --- build.bat | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/build.bat b/build.bat index a316c14e4..0407e849b 100644 --- a/build.bat +++ b/build.bat @@ -96,24 +96,27 @@ set BOOST_COMPILED_LIBS=--with-date_time^ --with-system^ --with-thread -set BJAM_OPTIONS=toolset=%BJAM_TOOLSET%^ +set BJAM_OPTIONS_COMMON=toolset=%BJAM_TOOLSET%^ variant=release^ link=static^ threading=multi^ runtime-link=static^ - define=BOOST_USE_WINAPI_VERSION=0x0501^ cxxflags="/Zc:threadSafeInit- " -set BJAM_OPTIONS_X64=%BJAM_OPTIONS%^ +set BJAM_OPTIONS_X86=%BJAM_OPTIONS_COMMON%^ + define=BOOST_USE_WINAPI_VERSION=0x0501 + +set BJAM_OPTIONS_X64=%BJAM_OPTIONS_COMMON%^ + define=BOOST_USE_WINAPI_VERSION=0x0502^ address-model=64^ - --stagedir=stage_x64^ + --stagedir=stage_x64 if %build_boost% == 1 ( cd /d %BOOST_ROOT% if not exist bjam.exe call bootstrap.bat if %ERRORLEVEL% NEQ 0 goto ERROR - bjam %BJAM_OPTIONS% stage %BOOST_COMPILED_LIBS% + bjam %BJAM_OPTIONS_X86% stage %BOOST_COMPILED_LIBS% if %ERRORLEVEL% NEQ 0 goto ERROR if %build_boost_x64% == 1 (