2020-09-05 10:26:12 +00:00
|
|
|
example_args = []
|
2022-02-14 17:41:52 +00:00
|
|
|
example_args += universal_args
|
2022-02-12 13:25:20 +00:00
|
|
|
example_args += devel_args
|
2021-11-25 18:20:22 +00:00
|
|
|
example_overrides = []
|
|
|
|
example_overrides += overrides
|
2020-09-05 10:26:12 +00:00
|
|
|
if is_gcc or is_clang
|
|
|
|
example_args += [ '-Wno-switch', '-Wno-switch-default', '-Wno-switch-enum' ]
|
2020-04-14 05:45:24 +00:00
|
|
|
endif
|
2022-02-26 12:42:09 +00:00
|
|
|
if is_clang and (get_option('asan_examples') or get_option('ubsan_examples'))
|
2021-11-25 18:20:22 +00:00
|
|
|
example_args += [ '-g3' ]
|
2022-02-26 12:42:09 +00:00
|
|
|
if get_option('asan_examples') and get_option('ubsan_examples')
|
|
|
|
example_overrides += 'b_sanitize=address,undefined'
|
|
|
|
elif get_option('asan_examples')
|
|
|
|
example_overrides += 'b_sanitize=address'
|
|
|
|
else
|
|
|
|
example_overrides += 'b_sanitize=undefined'
|
|
|
|
endif
|
2021-11-25 18:20:22 +00:00
|
|
|
endif
|
2020-04-14 05:45:24 +00:00
|
|
|
|
2020-09-05 10:26:12 +00:00
|
|
|
examples = [
|
2020-04-14 05:25:03 +00:00
|
|
|
'simple_parser',
|
2020-01-06 18:21:16 +00:00
|
|
|
'toml_to_json_transcoder',
|
2020-04-14 05:25:03 +00:00
|
|
|
'toml_generator',
|
2021-11-04 09:56:03 +00:00
|
|
|
'error_printer',
|
|
|
|
'parse_benchmark',
|
2020-09-05 10:26:12 +00:00
|
|
|
]
|
2020-04-14 09:45:32 +00:00
|
|
|
|
2021-11-25 18:20:22 +00:00
|
|
|
example_executables = []
|
2020-09-05 10:26:12 +00:00
|
|
|
foreach example : examples
|
2021-11-25 18:20:22 +00:00
|
|
|
example_executables += [[
|
2020-09-05 10:26:12 +00:00
|
|
|
example,
|
2021-11-25 18:20:22 +00:00
|
|
|
executable(
|
|
|
|
example,
|
|
|
|
[ example+'.cpp' ],
|
|
|
|
cpp_args: example_args,
|
2022-02-12 13:25:20 +00:00
|
|
|
dependencies: tomlplusplus_dep,
|
2021-11-25 18:20:22 +00:00
|
|
|
override_options: example_overrides
|
|
|
|
)
|
|
|
|
]]
|
2020-09-05 10:26:12 +00:00
|
|
|
endforeach
|
2021-11-25 18:20:22 +00:00
|
|
|
|
|
|
|
if is_clang and get_option('asan_examples')
|
|
|
|
foreach executable : example_executables
|
2022-01-02 11:30:32 +00:00
|
|
|
|
|
|
|
# skip the transcoder (it waits on stdin) and the benchmark (might be slow and cause CI to fail)
|
|
|
|
if executable[0].contains('transcoder') or executable[0].contains('benchmark')
|
2021-11-25 18:20:22 +00:00
|
|
|
continue
|
|
|
|
endif
|
2022-01-02 11:30:32 +00:00
|
|
|
|
2021-11-25 18:20:22 +00:00
|
|
|
test(
|
|
|
|
executable[0], # name
|
|
|
|
executable[1], # executable object
|
|
|
|
workdir: meson.source_root()/'examples'
|
|
|
|
)
|
2022-01-02 11:30:32 +00:00
|
|
|
|
2021-11-25 18:20:22 +00:00
|
|
|
endforeach
|
|
|
|
endif
|