1
1
@ echo off
2
2
rem Rime build script for msvc toolchain.
3
- rem 2014-12-30 Chen Gong < chen.sst@gmail.com>
3
+ rem Maintainer: Chen Gong < chen.sst@gmail.com>
4
4
5
5
setlocal
6
6
set BACK = %CD%
7
7
8
8
if exist env.bat call env.bat
9
9
10
+ rem for Windows XP compatibility (Visual Studio 2015+)
11
+ set CL = /Zc:threadSafeInit-
12
+
10
13
set OLD_PATH = %PATH%
11
- if defined DEV_PATH set PATH = %OLD_PATH% ;%DEV_PATH %
14
+ if defined DEVTOOLS_PATH set PATH = %OLD_PATH% ;%DEVTOOLS_PATH %
12
15
path
13
16
echo .
14
17
15
18
if not defined RIME_ROOT set RIME_ROOT = %CD%
16
19
echo RIME_ROOT=%RIME_ROOT%
17
20
echo .
18
21
22
+ if defined BOOST_ROOT (
23
+ if exist " %BOOST_ROOT% \boost" goto boost_found
24
+ )
25
+ echo Error: Boost not found! Please set BOOST_ROOT in env.bat.
26
+ exit /b 1
27
+ :boost_found
19
28
echo BOOST_ROOT=%BOOST_ROOT%
20
29
echo .
21
30
22
- if defined CMAKE_INSTALL_PATH set PATH = %PATH% ;%CMAKE_INSTALL_PATH%
31
+ if not defined BJAM_TOOLSET (
32
+ rem the number actually means platform toolset, not %VisualStudioVersion%
33
+ set BJAM_TOOLSET = msvc-14.0
34
+ )
35
+
36
+ if not defined CMAKE_GENERATOR (
37
+ set CMAKE_GENERATOR = " Visual Studio 14 2015"
38
+ )
39
+
40
+ if not defined PLATFORM_TOOLSET (
41
+ set PLATFORM_TOOLSET = v140_xp
42
+ )
23
43
24
- set CMAKE_GENERATOR = " Visual Studio 14 2015 "
25
- set CMAKE_TOOLSET = " v140_xp "
44
+ rem used when building marisa
45
+ set VS_LATEST = vs2015
26
46
27
47
set build = build
28
48
set build_boost = 0
49
+ set build_boost_x64 = 0
29
50
set build_thirdparty = 0
30
51
set build_librime = 0
31
52
set build_shared = ON
@@ -37,6 +58,7 @@ if "%1" == "" set build_librime=1
37
58
:parse_cmdline_options
38
59
if " %1 " == " " goto end_parsing_cmdline_options
39
60
if " %1 " == " boost" set build_boost = 1
61
+ if " %1 " == " boost_x64" set build_boost_x64 = 1
40
62
if " %1 " == " thirdparty" set build_thirdparty = 1
41
63
if " %1 " == " librime" set build_librime = 1
42
64
if " %1 " == " static" (
@@ -66,22 +88,49 @@ set THIRDPARTY="%RIME_ROOT%"\thirdparty
66
88
rem set CURL=%THIRDPARTY%\bin\curl.exe
67
89
rem set DOWNLOAD="%CURL%" --remote-name-all
68
90
91
+ set BOOST_COMPILED_LIBS = --with-date_time^
92
+ --with-filesystem^
93
+ --with-locale^
94
+ --with-regex^
95
+ --with-signals^
96
+ --with-system^
97
+ --with-thread
98
+
99
+ set BJAM_OPTIONS_COMMON = toolset=%BJAM_TOOLSET% ^
100
+ variant=release^
101
+ link=static^
102
+ threading=multi^
103
+ runtime-link=static^
104
+ cxxflags=" /Zc:threadSafeInit- "
105
+
106
+ set BJAM_OPTIONS_X86 = %BJAM_OPTIONS_COMMON% ^
107
+ define=BOOST_USE_WINAPI_VERSION=0x0501
108
+
109
+ set BJAM_OPTIONS_X64 = %BJAM_OPTIONS_COMMON% ^
110
+ define=BOOST_USE_WINAPI_VERSION=0x0502^
111
+ address-model=64^
112
+ --stagedir=stage_x64
113
+
69
114
if %build_boost% == 1 (
70
115
cd /d %BOOST_ROOT%
71
116
if not exist bjam.exe call bootstrap.bat
72
117
if %ERRORLEVEL% NEQ 0 goto ERROR
73
- 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
118
+
119
+ bjam %BJAM_OPTIONS_X86% stage %BOOST_COMPILED_LIBS%
74
120
if %ERRORLEVEL% NEQ 0 goto ERROR
75
- 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
76
- rem if %ERRORLEVEL% NEQ 0 goto ERROR
121
+
122
+ if %build_boost_x64% == 1 (
123
+ bjam %BJAM_OPTIONS_X64% stage %BOOST_COMPILED_LIBS%
124
+ if %ERRORLEVEL% NEQ 0 goto ERROR
125
+ )
77
126
)
78
127
79
128
if %build_thirdparty% == 1 (
80
129
cd /d %THIRDPARTY%
81
130
82
131
echo building glog.
83
132
cd %THIRDPARTY% \src\glog
84
- 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"
133
+ 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"
85
134
if %ERRORLEVEL% NEQ 0 goto ERROR
86
135
cmake --build build --config Release --target glog
87
136
if %ERRORLEVEL% NEQ 0 goto ERROR
@@ -104,7 +153,7 @@ if %build_thirdparty% == 1 (
104
153
105
154
echo building yaml-cpp.
106
155
cd %THIRDPARTY% \src\yaml-cpp
107
- 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"
156
+ 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"
108
157
if %ERRORLEVEL% NEQ 0 goto ERROR
109
158
cmake --build build --config Release --target yaml-cpp
110
159
if %ERRORLEVEL% NEQ 0 goto ERROR
@@ -116,7 +165,7 @@ if %build_thirdparty% == 1 (
116
165
117
166
echo building gtest.
118
167
cd %THIRDPARTY% \src\gtest
119
- 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"
168
+ 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"
120
169
if %ERRORLEVEL% NEQ 0 goto ERROR
121
170
cmake --build build --config Release
122
171
if %ERRORLEVEL% NEQ 0 goto ERROR
@@ -127,8 +176,8 @@ if %build_thirdparty% == 1 (
127
176
if %ERRORLEVEL% NEQ 0 goto ERROR
128
177
129
178
echo building marisa.
130
- cd %THIRDPARTY% \src\marisa-trie\vs2015
131
- msbuild.exe vs2015 .sln /p:Configuration=Release /p:Platform=Win32
179
+ cd %THIRDPARTY% \src\marisa-trie\%VS_LATEST%
180
+ msbuild.exe %VS_LATEST% .sln /p:Configuration=Release /p:Platform=Win32
132
181
if %ERRORLEVEL% NEQ 0 goto ERROR
133
182
echo built. copying artifacts.
134
183
xcopy /S /I /Y ..\lib\marisa %THIRDPARTY% \include\marisa\
@@ -141,7 +190,7 @@ if %build_thirdparty% == 1 (
141
190
142
191
echo building opencc.
143
192
cd %THIRDPARTY% \src\opencc
144
- 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"
193
+ 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"
145
194
if %ERRORLEVEL% NEQ 0 goto ERROR
146
195
cmake --build build --config Release --target libopencc
147
196
if %ERRORLEVEL% NEQ 0 goto ERROR
@@ -168,11 +217,16 @@ if %build_thirdparty% == 1 (
168
217
169
218
if %build_librime% == 0 goto EXIT
170
219
171
- 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"
220
+ set RIME_CMAKE_FLAGS = -DBUILD_STATIC=ON^
221
+ -DBUILD_SHARED_LIBS=%build_shared% ^
222
+ -DBUILD_TEST=%build_test% ^
223
+ -DENABLE_LOGGING=%enable_logging% ^
224
+ -DBOOST_USE_CXX11=ON^
225
+ -DCMAKE_CONFIGURATION_TYPES=" Release"
172
226
173
227
cd /d %RIME_ROOT%
174
- echo cmake %RIME_ROOT% -B%build% -G%CMAKE_GENERATOR% -T%CMAKE_TOOLSET % %RIME_CMAKE_FLAGS%
175
- call cmake %RIME_ROOT% -B%build% -G%CMAKE_GENERATOR% -T%CMAKE_TOOLSET % %RIME_CMAKE_FLAGS%
228
+ echo cmake %RIME_ROOT% -B%build% -G%CMAKE_GENERATOR% -T%PLATFORM_TOOLSET % %RIME_CMAKE_FLAGS%
229
+ call cmake %RIME_ROOT% -B%build% -G%CMAKE_GENERATOR% -T%PLATFORM_TOOLSET % %RIME_CMAKE_FLAGS%
176
230
if %ERRORLEVEL% NEQ 0 goto ERROR
177
231
178
232
echo .
0 commit comments