]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/leaf/meson.build
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / libs / leaf / meson.build
1 # Copyright (c) 2018-2020 Emil Dotchevski and Reverge Studios, Inc.
2
3 # Distributed under the Boost Software License, Version 1.0. (See accompanying
4 # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5
6 project('leaf', 'cpp', default_options : ['cpp_std=c++17', 'b_pch=false'], license : 'boost')
7
8 option_leaf_hpp = get_option('leaf_hpp')
9 option_boost = get_option('leaf_boost_examples')
10 option_lua = get_option('leaf_lua_examples')
11 option_diagnostics = get_option('leaf_diagnostics')
12 option_suppress_warnings = get_option('leaf_suppress_warnings')
13 option_exceptions = (get_option('cpp_eh')!='none')
14 option_enable_unit_tests = get_option('leaf_enable_unit_tests')
15 option_enable_examples = get_option('leaf_enable_examples')
16 option_enable_benchmarks = get_option('leaf_enable_benchmarks')
17
18 if not option_enable_examples
19 if option_boost
20 error('The option leaf_boost_examples requires leaf_enable_examples. Aborting.')
21 endif
22 if option_lua
23 error('The option leaf_lua_examples requires leaf_enable_examples. Aborting.')
24 endif
25 endif
26
27 compiler = meson.get_compiler('cpp')
28 compiler_id = compiler.get_id()
29 if not meson.is_subproject()
30 if compiler_id=='clang'
31 if get_option('buildtype')!='debug'
32 add_global_arguments(
33 '-Wno-unused-variable',
34 language:'cpp' )
35 endif
36 add_global_arguments(
37 '-fdiagnostics-absolute-paths',
38 '-Wno-dangling-else',
39 '-Wno-non-virtual-dtor',
40 '-Wno-delete-non-abstract-non-virtual-dtor',
41 language:'cpp' )
42 elif compiler_id=='gcc'
43 if get_option('buildtype')!='debug'
44 add_global_arguments(
45 '-Wno-unused-variable',
46 language:'cpp' )
47 endif
48 add_global_arguments(
49 '-Wno-dangling-else',
50 '-Wno-non-virtual-dtor',
51 '-Wno-misleading-indentation',
52 language:'cpp' )
53 elif host_machine.system()=='emscripten'
54 add_global_arguments(
55 '-s', 'WASM=1',
56 '-s', 'USE_PTHREADS=1',
57 '-s', 'EXIT_RUNTIME=1',
58 '-s', 'PROXY_TO_PTHREAD=1',
59 '-s', 'DISABLE_EXCEPTION_CATCHING=0',
60 language:'cpp' )
61 add_global_link_arguments(
62 '-s', 'EXPORT_ALL=1',
63 '-s', 'WASM=1',
64 '-s', 'USE_PTHREADS=1',
65 '-s', 'EXIT_RUNTIME=1',
66 '-s', 'PROXY_TO_PTHREAD=1',
67 '-s', 'DISABLE_EXCEPTION_CATCHING=0',
68 '-s', 'INITIAL_MEMORY=268435456',
69 language:'cpp' )
70 endif
71 endif
72
73 if option_leaf_hpp
74 prog_python = import('python').find_installation('python3')
75 custom_target(
76 'leaf_hpp',
77 command:
78 [
79 prog_python,
80 files('gen/generate_single_header.py'),
81 '-i', files('include/boost/leaf/detail/all.hpp'),
82 '-p', join_paths(meson.source_root(),'include'),
83 '-o', join_paths(meson.source_root(),'include/boost/leaf.hpp'),
84 'boost/leaf'
85 ],
86 output: 'leaf.hpp',
87 build_always_stale: true,
88 build_by_default: true)
89 endif
90
91 dep_boost = [ ]
92 if option_boost # Requires that LEAF resides under boost_root/libs/leaf.
93 dep_boost = declare_dependency(include_directories: '../..')
94 endif
95
96 dep_lua = [ ]
97 if option_lua
98 dep_lua = subproject('lua').get_variable('all')
99 endif
100
101 defines = [ '-DBOOST_LEAF_DIAGNOSTICS=' + option_diagnostics.to_string() ]
102
103 if not option_suppress_warnings
104 defines += '-DBOOST_LEAF_ENABLE_WARNINGS'
105 endif
106
107 dep_thread = dependency('threads')
108
109 includes = [ include_directories('include') ]
110
111 leaf = declare_dependency( include_directories: includes, compile_args: defines )
112
113 #################################
114
115 if option_enable_unit_tests
116
117 tests = [
118 'accumulate_basic_test',
119 'accumulate_nested_error_exception_test',
120 'accumulate_nested_error_result_test',
121 'accumulate_nested_new_error_exception_test',
122 'accumulate_nested_new_error_result_test',
123 'accumulate_nested_success_exception_test',
124 'accumulate_nested_success_result_test',
125 'BOOST_LEAF_AUTO_test',
126 'BOOST_LEAF_ASSIGN_test',
127 'capture_exception_async_test',
128 'capture_exception_result_async_test',
129 'capture_exception_state_test',
130 'capture_exception_unload_test',
131 'capture_result_async_test',
132 'capture_result_state_test',
133 'context_activator_test',
134 'context_deduction_test',
135 'capture_result_unload_test',
136 'ctx_handle_all_test',
137 'ctx_handle_some_test',
138 'ctx_remote_handle_all_test',
139 'ctx_remote_handle_some_test',
140 'defer_basic_test',
141 'defer_nested_error_exception_test',
142 'defer_nested_error_result_test',
143 'defer_nested_new_error_exception_test',
144 'defer_nested_new_error_result_test',
145 'defer_nested_success_exception_test',
146 'defer_nested_success_result_test',
147 'diagnostic_info_test',
148 'error_code_test',
149 'error_id_test',
150 'exception_test',
151 'exception_to_result_test',
152 'function_traits_test',
153 'handle_all_other_result_test',
154 'handle_all_test',
155 'handle_basic_test',
156 'handle_some_other_result_test',
157 'handle_some_test',
158 'match_test',
159 'match_member_test',
160 'match_value_test',
161 'multiple_errors_test',
162 'optional_test',
163 'preload_basic_test',
164 'preload_exception_test',
165 'preload_nested_error_exception_test',
166 'preload_nested_error_result_test',
167 'preload_nested_new_error_exception_test',
168 'preload_nested_new_error_result_test',
169 'preload_nested_success_exception_test',
170 'preload_nested_success_result_test',
171 'print_test',
172 'result_bad_result_test',
173 'result_load_test',
174 'result_ref_test',
175 'result_state_test',
176 'try_catch_error_id_test',
177 'try_catch_system_error_test',
178 'try_catch_test',
179 'try_exception_and_result_test',
180 '_hpp_capture_test',
181 '_hpp_common_test',
182 '_hpp_context_test',
183 '_hpp_error_test',
184 '_hpp_exception_test',
185 '_hpp_handle_errors_test',
186 '_hpp_leaf_test',
187 '_hpp_on_error_test',
188 '_hpp_pred_test',
189 '_hpp_result_test',
190 ]
191 if option_boost and option_exceptions
192 tests += [
193 'boost_exception_test'
194 ]
195 endif
196
197 foreach t : tests
198 test(t, executable(t, 'test/'+t+'.cpp', dependencies: [leaf, dep_thread, dep_boost]) )
199 endforeach
200
201 endif
202
203 #################################
204
205 if option_enable_examples
206
207 print_file_examples = [
208 'print_file_result',
209 'print_file_result_error_tags',
210 ]
211 if option_exceptions
212 print_file_examples += [
213 'print_file_eh',
214 'print_file_eh_error_tags'
215 ]
216 endif
217 if option_boost
218 print_file_examples += [
219 'print_file_outcome_result'
220 ]
221 endif
222
223 foreach e : print_file_examples
224 executable(e, 'examples/print_file/'+e+'.cpp', dependencies: [leaf, dep_thread, dep_boost] )
225 endforeach
226
227 endif
228
229 #################################
230
231 if option_enable_examples
232
233 examples = [
234 'capture_in_result',
235 'error_log',
236 'error_trace',
237 'print_half'
238 ]
239 if option_exceptions
240 examples += [
241 'capture_in_exception',
242 'exception_to_result'
243 ]
244 if option_lua
245 examples += [
246 'lua_callback_eh'
247 ]
248 endif
249 if option_boost
250 examples += [
251 # 'asio_beast_leaf_rpc' #FIXME
252 ]
253 endif
254 endif
255 if option_lua
256 examples += [
257 'lua_callback_result'
258 ]
259 endif
260
261 foreach e : examples
262 executable(e, 'examples/'+e+'.cpp', dependencies: [leaf, dep_thread, dep_boost, dep_lua] )
263 endforeach
264
265 endif
266
267 #################################
268
269 if option_enable_benchmarks
270
271 if option_exceptions
272 error('The option leaf_enable_benchmarks requires the built-in option cpp_eh set to none. Aborting.')
273 else
274 dep_tl_expected = subproject('tl_expected').get_variable('headers')
275 executable('deep_stack_tl', 'benchmark/deep_stack_other.cpp', override_options: ['cpp_std=c++17'], cpp_args: '-DBENCHMARK_WHAT=0', dependencies: [dep_tl_expected] )
276 executable('deep_stack_leaf', 'benchmark/deep_stack_leaf.cpp', dependencies: [leaf], override_options: ['cpp_std=c++17'], cpp_args: '-DBOOST_LEAF_DIAGNOSTICS=0')
277 if option_boost
278 executable('deep_stack_result', 'benchmark/deep_stack_other.cpp', dependencies: [dep_boost], override_options: ['cpp_std=c++17'], cpp_args: '-DBENCHMARK_WHAT=1' )
279 executable('deep_stack_outcome', 'benchmark/deep_stack_other.cpp', dependencies: [dep_boost], override_options: ['cpp_std=c++17'], cpp_args: '-DBENCHMARK_WHAT=2' )
280 endif
281 endif
282
283 endif