-
Notifications
You must be signed in to change notification settings - Fork 574
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(build.bat): customize build settings via environment variables #178
Changes from 1 commit
d5aa010
13dcf02
c24ce10
dd17628
93bb6ec
5a57e29
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,52 @@ | ||
@echo off | ||
rem Rime build script for msvc toolchain. | ||
rem 2014-12-30 Chen Gong <[email protected]> | ||
rem Maintainer: Chen Gong <[email protected]> | ||
|
||
setlocal | ||
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. | ||
|
||
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%" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Question: are the quotes required in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since it does not include spaces, no. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK, then I'll change to |
||
) | ||
|
||
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 | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, Windows Server 2003 x64 (including Windows XP x64) should not be ignored. |
||
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% | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should not use
%VisualStudioVersion%
here.The number is platform toolset, not Visual Studio version.
For example
msvc-14.1
for Visual Studio 15 2017.https://stackoverflow.com/questions/42730478/version-numbers-for-visual-studio-2017-boost-and-cmake/42738533#42738533