-
Notifications
You must be signed in to change notification settings - Fork 540
/
build-clang.bat
155 lines (136 loc) · 3.66 KB
/
build-clang.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
@echo off
if "%BOOST_ROOT%" == "" (
echo Please set BOOST_ROOT environment variable.
exit
)
set RIME_ROOT=%CD%
@REM Build for native architecture
set arch=x86
if "%PROCESSOR_ARCHITECTURE%" == "ARM64" set arch=arm
set clean=0
set build_boost=0
set build_deps=0
set build_librime=0
set build_test=OFF
:parse_cmdline_options
if "%1" == "" goto end_parsing_cmdline_options
if "%1" == "clean" set clean=1
if "%1" == "boost" set build_boost=1
if "%1" == "deps" set build_deps=1
if "%1" == "librime" set build_librime=1
if "%1" == "test" (
set build_librime=1
set build_test=ON
)
shift
goto parse_cmdline_options
:end_parsing_cmdline_options
if %clean% == 0 (
if %build_boost% == 0 (
if %build_deps% == 0 (
set build_librime=1
)))
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
)
if %build_boost% == 1 (
pushd %BOOST_ROOT% || exit
if not exist b2.exe call .\bootstrap.bat || exit
b2 toolset=clang-win^
architecture=%arch%^
address-model=64^
variant=release^
link=static^
runtime-link=static^
stage^
--with-locale^
--with-filesystem^
--with-system^
--with-regex || exit
popd
)
set common_cmake_flags=-B build^
-G Ninja^
-DCMAKE_C_COMPILER=clang^
-DCMAKE_CXX_COMPILER=clang++^
-DCMAKE_BUILD_TYPE:STRING=Release^
-DCMAKE_USER_MAKE_RULES_OVERRIDE:PATH="%RIME_ROOT%\cmake\c_flag_overrides.cmake"^
-DCMAKE_USER_MAKE_RULES_OVERRIDE_CXX:PATH="%RIME_ROOT%\cmake\cxx_flag_overrides.cmake"^
-DCMAKE_EXE_LINKER_FLAGS_INIT:STRING="-llibcmt"^
-DCMAKE_MSVC_RUNTIME_LIBRARY:STRING=MultiThreaded
set deps_cmake_flags=%common_cmake_flags%^
-DBUILD_SHARED_LIBS:BOOL=OFF^
-DCMAKE_INSTALL_PREFIX:PATH="%RIME_ROOT%"
if %build_deps% == 1 (
echo building glog.
pushd deps\glog
cmake . %deps_cmake_flags%^
-DWITH_GFLAGS:BOOL=OFF^
-DBUILD_TESTING:BOOL=OFF || exit
cmake --build build || exit
cmake --install build || exit
popd
echo building leveldb.
pushd deps\leveldb
cmake . %deps_cmake_flags%^
-DCMAKE_CXX_FLAGS:STRING="-Wno-error=deprecated-declarations"^
-DLEVELDB_BUILD_BENCHMARKS:BOOL=OFF^
-DLEVELDB_BUILD_TESTS:BOOL=OFF || exit
cmake --build build || exit
cmake --install build || exit
popd
echo building yaml-cpp.
pushd deps\yaml-cpp
cmake . %deps_cmake_flags%^
-DYAML_CPP_BUILD_CONTRIB:BOOL=OFF^
-DYAML_CPP_BUILD_TESTS:BOOL=OFF^
-DYAML_CPP_BUILD_TOOLS:BOOL=OFF || exit
cmake --build build || exit
cmake --install build || exit
popd
echo building gtest.
pushd deps\googletest
cmake . %deps_cmake_flags%^
-DBUILD_GMOCK:BOOL=OFF || exit
cmake --build build || exit
cmake --install build || exit
popd
echo building marisa.
pushd deps\marisa-trie
cmake . %deps_cmake_flags% || exit
cmake --build build || exit
cmake --install build || exit
popd
echo building opencc.
pushd deps\opencc
cmake . %deps_cmake_flags%^
-DCMAKE_CXX_FLAGS:STRING="-I %RIME_ROOT%\include -L %RIME_ROOT%\lib"^
-DUSE_SYSTEM_MARISA:BOOL=ON || exit
cmake --build build || exit
cmake --install build || exit
popd
)
set rime_cmake_flags=%common_cmake_flags%^
-DBUILD_STATIC:BOOL=ON^
-DBUILD_SHARED_LIBS:BOOL=ON^
-DBUILD_TEST:BOOL="%build_test%"^
-DENABLE_LOGGING:BOOL=ON^
-DCMAKE_INSTALL_PREFIX:PATH="%RIME_ROOT%\dist"
if %build_librime% == 1 (
echo building librime.
cmake . %rime_cmake_flags% || exit
cmake --build build || exit
cmake --install build || exit
)
if "%build_test%" == "ON" (
copy /y dist\lib\rime.dll build\test
pushd build\test
.\rime_test.exe || exit
popd
)