Skip to content

Commit 4a39a0d

Browse files
committed
Toolset
1 parent 56d9a27 commit 4a39a0d

File tree

2 files changed

+80
-17
lines changed

2 files changed

+80
-17
lines changed

.github/workflows/ci.yml

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,47 +25,56 @@ jobs:
2525
- name: Install dependencies
2626
run: choco install openssl
2727

28-
- name: Set up a running Redis server
29-
run: docker run -d --name redis -p 6379:6379 redis:alpine
30-
3128
- name: Setup Boost
3229
run: ./tools/ci.py setup-boost --source-dir=$(pwd)
3330

3431
- name: Build a Boost distribution using B2
3532
run: |
3633
./tools/ci.py build-b2-distro \
37-
--generator "${{ matrix.generator }}"
34+
--generator "${{ matrix.generator }}" \
35+
--toolset ${{ matrix.toolset }}
3836
3937
- name: Build a Boost distribution using CMake
4038
run: |
4139
./tools/ci.py build-cmake-distro \
4240
--build-type ${{ matrix.build-type }} \
4341
--cxxstd ${{ matrix.cxxstd }} \
42+
--toolset ${{ matrix.toolset }} \
4443
--generator "${{ matrix.generator }}"
4544
46-
- name: Run the project's tests
45+
- name: Build the project tests
4746
run: |
48-
./tools/ci.py run-cmake-standalone-tests \
47+
./tools/ci.py build-cmake-standalone-tests \
4948
--build-type ${{ matrix.build-type }} \
5049
--cxxstd ${{ matrix.cxxstd }} \
50+
--toolset ${{ matrix.toolset }} \
5151
--generator "${{ matrix.generator }}"
5252
53+
# # TODO: re-enable this when a Redis server is available for this job
54+
# - name: Run the project tests
55+
# run: |
56+
# ./tools/ci.py run-cmake-standalone-tests \
57+
# --build-type ${{ matrix.build-type }}
58+
5359
- name: Run add_subdirectory tests
5460
run: |
5561
./tools/ci.py run-cmake-add-subdirectory-tests \
5662
--build-type ${{ matrix.build-type }} \
63+
--toolset ${{ matrix.toolset }} \
5764
--generator "${{ matrix.generator }}"
5865
5966
- name: Run find_package tests with the built cmake distribution
6067
run: |
6168
./tools/ci.py run-cmake-find-package-tests \
6269
--build-type ${{ matrix.build-type }} \
70+
--toolset ${{ matrix.toolset }} \
6371
--generator "${{ matrix.generator }}"
6472
6573
- name: Run find_package tests with the built b2 distribution
6674
run: |
6775
./tools/ci.py run-cmake-b2-find-package-tests \
6876
--build-type ${{ matrix.build-type }} \
77+
--toolset ${{ matrix.toolset }} \
6978
--generator "${{ matrix.generator }}"
7079
7180
posix:
@@ -101,31 +110,42 @@ jobs:
101110
run: ./tools/ci.py setup-boost --source-dir=$(pwd)
102111

103112
- name: Build a Boost distribution using B2
104-
run: ./tools/ci.py build-b2-distro
113+
run: ./tools/ci.py build-b2-distro \
114+
--toolset ${{ matrix.toolset }}
105115

106116
- name: Build a Boost distribution using CMake
107117
run: |
108118
./tools/ci.py build-cmake-distro \
119+
--toolset ${{ matrix.toolset }} \
109120
--build-type ${{ matrix.build-type }} \
110121
--cxxstd ${{ matrix.cxxstd }}
111122
112-
- name: Run the project's tests
123+
- name: Build the project tests
113124
run: |
114-
./tools/ci.py run-cmake-standalone-tests \
125+
./tools/ci.py build-cmake-standalone-tests \
115126
--build-type ${{ matrix.build-type }} \
116-
--cxxstd ${{ matrix.cxxstd }}
127+
--cxxstd ${{ matrix.cxxstd }} \
128+
--toolset ${{ matrix.toolset }}
129+
130+
- name: Run the project tests
131+
run: |
132+
./tools/ci.py run-cmake-standalone-tests \
133+
--build-type ${{ matrix.build-type }}
117134
118135
- name: Run add_subdirectory tests
119136
run: |
120137
./tools/ci.py run-cmake-add-subdirectory-tests \
121-
--build-type ${{ matrix.build-type }}
138+
--build-type ${{ matrix.build-type }} \
139+
--toolset ${{ matrix.toolset }}
122140
123141
- name: Run find_package tests with the built cmake distribution
124142
run: |
125143
./tools/ci.py run-cmake-find-package-tests \
126-
--build-type ${{ matrix.build-type }}
144+
--build-type ${{ matrix.build-type }} \
145+
--toolset ${{ matrix.toolset }}
127146
128147
- name: Run find_package tests with the built b2 distribution
129148
run: |
130149
./tools/ci.py run-cmake-b2-find-package-tests \
131-
--build-type ${{ matrix.build-type }}
150+
--build-type ${{ matrix.build-type }} \
151+
--toolset ${{ matrix.toolset }}

tools/ci.py

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,17 @@ def _str2bool(v: Union[bool, str]) -> bool:
5151
raise argparse.ArgumentTypeError('Boolean value expected.')
5252

5353

54+
def _compiler_from_toolset(toolset: str) -> str:
55+
if toolset.startswith('gcc'):
56+
return toolset.replace('gcc', 'g++')
57+
elif toolset.startswith('clang'):
58+
return toolset.replace('clang', 'clang++')
59+
elif toolset.startswith('msvc'):
60+
return 'cl'
61+
else:
62+
return toolset
63+
64+
5465
def _deduce_boost_branch() -> str:
5566
# Are we in GitHub Actions?
5667
if os.environ.get('GITHUB_ACTIONS') is not None:
@@ -111,12 +122,15 @@ def _setup_boost(
111122

112123
# Builds a Boost distribution using ./b2 install, and places it into _b2_distro.
113124
# This emulates a regular Boost distribution, like the ones in releases
114-
def _build_b2_distro():
125+
def _build_b2_distro(
126+
toolset: str
127+
):
115128
os.chdir(str(_boost_root))
116129
_run([
117130
_b2_command,
118131
'--prefix={}'.format(_b2_distro),
119132
'--with-system',
133+
'toolset={}'.format(toolset),
120134
'-d0',
121135
'install'
122136
])
@@ -128,6 +142,7 @@ def _build_cmake_distro(
128142
generator: str,
129143
build_type: str,
130144
cxxstd: str,
145+
toolset: str,
131146
build_shared_libs: bool = False
132147
):
133148
_mkdir_and_cd(_boost_root.joinpath('__build_cmake_test__'))
@@ -136,6 +151,7 @@ def _build_cmake_distro(
136151
'-G',
137152
generator,
138153
'-DBUILD_TESTING=ON',
154+
'-DCMAKE_CXX_COMPILER={}'.format(_compiler_from_toolset(toolset)),
139155
'-DCMAKE_BUILD_TYPE={}'.format(build_type),
140156
'-DCMAKE_CXX_STANDARD={}'.format(cxxstd),
141157
'-DBOOST_INCLUDE_LIBRARIES=redis',
@@ -151,19 +167,21 @@ def _build_cmake_distro(
151167
_run(['cmake', '--build', '.', '--target', 'install', '--config', build_type])
152168

153169

154-
# Builds and runs our CMake tests as a standalone project
170+
# Builds our CMake tests as a standalone project
155171
# (BOOST_REDIS_MAIN_PROJECT is ON) and we find_package Boost.
156172
# This ensures that all our test suite is run.
157-
def _run_cmake_standalone_tests(
173+
def _build_cmake_standalone_tests(
158174
generator: str,
159175
build_type: str,
160176
cxxstd: str,
177+
toolset: str,
161178
build_shared_libs: bool = False
162179
):
163180
_mkdir_and_cd(_boost_root.joinpath('libs', 'redis', '__build_standalone__'))
164181
_run([
165182
'cmake',
166183
'-DBUILD_TESTING=ON',
184+
'-DCMAKE_CXX_COMPILER={}'.format(_compiler_from_toolset(toolset)),
167185
'-DCMAKE_PREFIX_PATH={}'.format(_build_prefix_path(_b2_distro)),
168186
'-DCMAKE_BUILD_TYPE={}'.format(build_type),
169187
'-DBUILD_SHARED_LIBS={}'.format(_cmake_bool(build_shared_libs)),
@@ -173,13 +191,21 @@ def _run_cmake_standalone_tests(
173191
'..'
174192
])
175193
_run(['cmake', '--build', '.'])
194+
195+
196+
# Runs the tests built in the previous step
197+
def _run_cmake_standalone_tests(
198+
build_type: str
199+
):
200+
os.chdir(str(_boost_root.joinpath('libs', 'redis', '__build_standalone__')))
176201
_run(['ctest', '--output-on-failure', '--build-config', build_type, '--no-tests=error'])
177202

178203

179204
# Tests that the library can be consumed using add_subdirectory()
180205
def _run_cmake_add_subdirectory_tests(
181206
generator: str,
182207
build_type: str,
208+
toolset: str,
183209
build_shared_libs: bool = False
184210
):
185211
test_folder = _boost_root.joinpath('libs', 'redis', 'test', 'cmake_test', '__build_cmake_subdir_test__')
@@ -188,6 +214,7 @@ def _run_cmake_add_subdirectory_tests(
188214
'cmake',
189215
'-G',
190216
generator,
217+
'-DCMAKE_CXX_COMPILER={}'.format(_compiler_from_toolset(toolset)),
191218
'-DBUILD_TESTING=ON',
192219
'-DBOOST_CI_INSTALL_TEST=OFF',
193220
'-DCMAKE_BUILD_TYPE={}'.format(build_type),
@@ -202,13 +229,15 @@ def _run_cmake_add_subdirectory_tests(
202229
def _run_cmake_find_package_tests(
203230
generator: str,
204231
build_type: str,
232+
toolset: str,
205233
build_shared_libs: bool = False
206234
):
207235
_mkdir_and_cd(_boost_root.joinpath('libs', 'redis', 'test', 'cmake_test', '__build_cmake_install_test__'))
208236
_run([
209237
'cmake',
210238
'-G',
211239
generator,
240+
'-DCMAKE_CXX_COMPILER={}'.format(_compiler_from_toolset(toolset)),
212241
'-DBUILD_TESTING=ON',
213242
'-DBOOST_CI_INSTALL_TEST=ON',
214243
'-DCMAKE_BUILD_TYPE={}'.format(build_type),
@@ -224,13 +253,15 @@ def _run_cmake_find_package_tests(
224253
def _run_cmake_b2_find_package_tests(
225254
generator: str,
226255
build_type: str,
256+
toolset: str,
227257
build_shared_libs: bool = False
228258
):
229259
_mkdir_and_cd(_boost_root.joinpath('libs', 'redis', 'test', 'cmake_b2_test', '__build_cmake_b2_test__'))
230260
_run([
231261
'cmake',
232262
'-G',
233263
generator,
264+
'-DCMAKE_CXX_COMPILER={}'.format(_compiler_from_toolset(toolset)),
234265
'-DBUILD_TESTING=ON',
235266
'-DCMAKE_PREFIX_PATH={}'.format(_build_prefix_path(_b2_distro)),
236267
'-DCMAKE_BUILD_TYPE={}'.format(build_type),
@@ -242,6 +273,8 @@ def _run_cmake_b2_find_package_tests(
242273
_run(['ctest', '--output-on-failure', '--build-config', build_type, '--no-tests=error'])
243274

244275

276+
277+
245278
def main():
246279
parser = argparse.ArgumentParser()
247280
subparsers = parser.add_subparsers()
@@ -251,37 +284,47 @@ def main():
251284
subp.set_defaults(func=_setup_boost)
252285

253286
subp = subparsers.add_parser('build-b2-distro')
287+
subp.add_argument('--toolset', default='gcc')
254288
subp.set_defaults(func=_build_b2_distro)
255289

256290
subp = subparsers.add_parser('build-cmake-distro')
257291
subp.add_argument('--generator', default='Unix Makefiles')
258292
subp.add_argument('--build-type', default='Debug')
259293
subp.add_argument('--cxxstd', default='20')
294+
subp.add_argument('--toolset', default='gcc')
260295
subp.add_argument('--build-shared-libs', type=_str2bool, default=False)
261296
subp.set_defaults(func=_build_cmake_distro)
262297

263-
subp = subparsers.add_parser('run-cmake-standalone-tests')
298+
subp = subparsers.add_parser('build-cmake-standalone-tests')
264299
subp.add_argument('--generator', default='Unix Makefiles')
265300
subp.add_argument('--build-type', default='Debug')
266301
subp.add_argument('--cxxstd', default='20')
302+
subp.add_argument('--toolset', default='gcc')
267303
subp.add_argument('--build-shared-libs', type=_str2bool, default=False)
304+
subp.set_defaults(func=_build_cmake_standalone_tests)
305+
306+
subp = subparsers.add_parser('run-cmake-standalone-tests')
307+
subp.add_argument('--build-type', default='Debug')
268308
subp.set_defaults(func=_run_cmake_standalone_tests)
269309

270310
subp = subparsers.add_parser('run-cmake-add-subdirectory-tests')
271311
subp.add_argument('--generator', default='Unix Makefiles')
272312
subp.add_argument('--build-type', default='Debug')
313+
subp.add_argument('--toolset', default='gcc')
273314
subp.add_argument('--build-shared-libs', type=_str2bool, default=False)
274315
subp.set_defaults(func=_run_cmake_add_subdirectory_tests)
275316

276317
subp = subparsers.add_parser('run-cmake-find-package-tests')
277318
subp.add_argument('--generator', default='Unix Makefiles')
278319
subp.add_argument('--build-type', default='Debug')
320+
subp.add_argument('--toolset', default='gcc')
279321
subp.add_argument('--build-shared-libs', type=_str2bool, default=False)
280322
subp.set_defaults(func=_run_cmake_find_package_tests)
281323

282324
subp = subparsers.add_parser('run-cmake-b2-find-package-tests')
283325
subp.add_argument('--generator', default='Unix Makefiles')
284326
subp.add_argument('--build-type', default='Debug')
327+
subp.add_argument('--toolset', default='gcc')
285328
subp.add_argument('--build-shared-libs', type=_str2bool, default=False)
286329
subp.set_defaults(func=_run_cmake_b2_find_package_tests)
287330

0 commit comments

Comments
 (0)