forked from rime/librime
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.bat
205 lines (178 loc) · 6.4 KB
/
build.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
@echo off
rem Rime build script for msvc toolchain.
rem 2014-12-30 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%
path
echo.
if not defined RIME_ROOT set RIME_ROOT=%CD%
echo RIME_ROOT=%RIME_ROOT%
echo.
echo BOOST_ROOT=%BOOST_ROOT%
echo.
set build=build
set build_boost=0
set build_thirdparty=0
set build_librime=0
set build_shared=ON
set build_test=OFF
set enable_logging=ON
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" == "thirdparty" set build_thirdparty=1
if "%1" == "librime" set build_librime=1
if "%1" == "static" (
set build=build-static
set build_librime=1
set build_shared=OFF
)
if "%1" == "shared" (
set build=build
set build_librime=1
set build_shared=ON
)
if "%1" == "test" (
set build_librime=1
set build_test=ON
)
if "%1" == "nologging" (
set build_librime=1
set enable_logging=OFF
)
shift
goto parse_cmdline_options
:end_parsing_cmdline_options
set THIRDPARTY="%RIME_ROOT%"\thirdparty
rem set CURL=%THIRDPARTY%\bin\curl.exe
rem set DOWNLOAD="%CURL%" --remote-name-all
set LEVELDB_REPOSITORY=lotem/leveldb
if %build_boost% == 1 (
cd %BOOST_ROOT%
if not exist bjam.exe call bootstrap.bat
if %ERRORLEVEL% NEQ 0 goto ERROR
bjam toolset=msvc-12.0 variant=release link=static threading=multi runtime-link=static stage --with-date_time --with-filesystem --with-system --with-regex --with-signals --with-thread
if %ERRORLEVEL% NEQ 0 goto ERROR
rem bjam toolset=msvc-12.0 variant=release link=static threading=multi runtime-link=static address-model=64 --stagedir=stage_x64 stage --with-date_time --with-filesystem --with-system --with-regex --with-signals --with-thread
rem if %ERRORLEVEL% NEQ 0 goto ERROR
)
if %build_thirdparty% == 1 (
echo building glog.
cd %THIRDPARTY%\src\glog
msbuild.exe google-glog-vc12.sln /p:Configuration=Release
if %ERRORLEVEL% NEQ 0 goto ERROR
echo built. copying artifacts.
xcopy /S /I /Y src\windows\glog %THIRDPARTY%\include\glog\
if %ERRORLEVEL% NEQ 0 goto ERROR
copy /Y Release\libglog.lib %THIRDPARTY%\lib\
if %ERRORLEVEL% NEQ 0 goto ERROR
copy /Y Release\libglog.dll %THIRDPARTY%\bin\
if %ERRORLEVEL% NEQ 0 goto ERROR
echo building leveldb.
cd %THIRDPARTY%\src\
echo "checking out 'windows' branch from %LEVELDB_REPOSITORY%"
git clone -b windows [email protected]:%LEVELDB_REPOSITORY%.git leveldb-windows
if %ERRORLEVEL% NEQ 0 goto ERROR
cd leveldb-windows
echo BOOST_ROOT=%BOOST_ROOT%
msbuild.exe leveldb.sln /p:Configuration=Release
if %ERRORLEVEL% NEQ 0 goto ERROR
echo built. copying artifacts.
xcopy /S /I /Y include\leveldb %THIRDPARTY%\include\leveldb\
if %ERRORLEVEL% NEQ 0 goto ERROR
copy /Y Release\leveldb.lib %THIRDPARTY%\lib\
if %ERRORLEVEL% NEQ 0 goto ERROR
echo building yaml-cpp.
cd %THIRDPARTY%\src\yaml-cpp
if not exist build mkdir build
cd build
cmake -DMSVC_SHARED_RT=OFF ..
if %ERRORLEVEL% NEQ 0 goto ERROR
msbuild.exe YAML_CPP.sln /p:Configuration=Release
if %ERRORLEVEL% NEQ 0 goto ERROR
echo built. copying artifacts.
xcopy /S /I /Y ..\include\yaml-cpp %THIRDPARTY%\include\yaml-cpp\
if %ERRORLEVEL% NEQ 0 goto ERROR
copy /Y Release\libyaml-cppmt.lib %THIRDPARTY%\lib\
if %ERRORLEVEL% NEQ 0 goto ERROR
echo building gtest.
cd %THIRDPARTY%\src\gtest
if not exist build mkdir build
cd build
cmake ..
if %ERRORLEVEL% NEQ 0 goto ERROR
msbuild.exe gtest.sln /p:Configuration=Release
if %ERRORLEVEL% NEQ 0 goto ERROR
echo built. copying artifacts.
xcopy /S /I /Y ..\include\gtest %THIRDPARTY%\include\gtest\
if %ERRORLEVEL% NEQ 0 goto ERROR
copy /Y Release\gtest*.lib %THIRDPARTY%\lib\
if %ERRORLEVEL% NEQ 0 goto ERROR
echo building marisa.
cd %THIRDPARTY%\src\marisa-trie\vs2013
msbuild.exe vs2013.sln /p:Configuration=Release
if %ERRORLEVEL% NEQ 0 goto ERROR
echo built. copying artifacts.
xcopy /S /I /Y ..\lib\marisa %THIRDPARTY%\include\marisa\
xcopy /Y ..\lib\marisa.h %THIRDPARTY%\include\
if %ERRORLEVEL% NEQ 0 goto ERROR
copy /Y Release\libmarisa.lib %THIRDPARTY%\lib\
if %ERRORLEVEL% NEQ 0 goto ERROR
copy /Y Release\marisa-*.exe %THIRDPARTY%\bin\
if %ERRORLEVEL% NEQ 0 goto ERROR
echo building opencc.
cd %THIRDPARTY%\src\opencc
if not exist build mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX="" -DBUILD_SHARED_LIBS=OFF
echo patching src\libopencc.vcxproj for static linking runtime.
sed -i "s/MultiThreadedDLL/MultiThreaded/" src\libopencc.vcxproj
sed -i "s/MultiThreadedDLL/MultiThreaded/" src\tools\opencc.vcxproj
sed -i "s/MultiThreadedDLL/MultiThreaded/" src\tools\opencc_dict.vcxproj
msbuild.exe opencc.sln /t:libopencc;opencc;opencc_dict;Dictionaries /p:Configuration=Release
if %ERRORLEVEL% NEQ 0 goto ERROR
echo built. copying artifacts.
cd ..
if not exist %THIRDPARTY%\include\opencc mkdir %THIRDPARTY%\include\opencc
copy /Y src\*.h* %THIRDPARTY%\include\opencc\
if %ERRORLEVEL% NEQ 0 goto ERROR
copy /Y build\src\Release\opencc.lib %THIRDPARTY%\lib
if %ERRORLEVEL% NEQ 0 goto ERROR
copy /Y build\src\tools\Release\opencc.exe %THIRDPARTY%\bin
copy /Y build\src\tools\Release\opencc_dict.exe %THIRDPARTY%\bin
if %ERRORLEVEL% NEQ 0 goto ERROR
if not exist %THIRDPARTY%\data\opencc mkdir %THIRDPARTY%\data\opencc
copy /Y data\config\*.json %THIRDPARTY%\data\opencc
copy /Y build\data\*.ocd %THIRDPARTY%\data\opencc
if %ERRORLEVEL% NEQ 0 goto ERROR
)
if %build_librime% == 0 goto EXIT
set CMAKE_GENERATOR="Visual Studio 12"
set BUILD_DIR=%RIME_ROOT%\%build%
if not exist %BUILD_DIR% mkdir %BUILD_DIR%
set RIME_CMAKE_FLAGS=-DBUILD_STATIC=ON -DBUILD_SHARED_LIBS=%build_shared% -DBUILD_TEST=%build_test% -DENABLE_LOGGING=%enable_logging% -DBOOST_USE_CXX11=ON
cd %BUILD_DIR%
echo cmake -G %CMAKE_GENERATOR% %RIME_CMAKE_FLAGS% %RIME_ROOT%
call cmake -G %CMAKE_GENERATOR% %RIME_CMAKE_FLAGS% %RIME_ROOT%
if %ERRORLEVEL% NEQ 0 goto ERROR
echo.
echo building librime.
if exist msbuild.log del msbuild.log
msbuild.exe rime.sln /p:Configuration=Release /fl
if %ERRORLEVEL% NEQ 0 goto ERROR
echo.
echo ready.
echo.
goto EXIT
:ERROR
echo.
echo error building la rime.
echo.
:EXIT
set PATH=%OLD_PATH%
cd %RIME_ROOT%
rem pause