wrenpp/subprojects/wren/meson.build
2021-06-23 17:37:01 +02:00

141 lines
3.3 KiB
Meson

project('wren', 'c',
version: '0.4.0',
meson_version: '>=0.54.0',
default_options: ['buildtype=release', 'c_std=c99', 'build_testing=true'],
)
c_compiler = meson.get_compiler('c')
c_opts = []
if get_option('wren_with_rand')
c_opts += '-DWREN_OPT_RANDOM=1'
else
c_opts += '-DWREN_OPT_RANDOM=0'
endif
if get_option('wren_with_meta')
c_opts += '-DWREN_OPT_META=1'
else
c_opts += '-DWREN_OPT_META=0'
endif
wren_incl = include_directories('wren/src/include', is_system: true)
wren_pvt_incl = include_directories('wren/src/vm', 'wren/src/optional')
test_incl = include_directories('wren/test')
threads_dep = dependency('threads')
libuv_dep = c_compiler.find_library('libuv', required: true)
m_dep = c_compiler.find_library('m', required: true)
opt_src = [
'wren/src/optional/wren_opt_random.c',
'wren/src/optional/wren_opt_meta.c',
]
vm_src = [
'wren/src/vm/wren_compiler.c',
'wren/src/vm/wren_core.c',
'wren/src/vm/wren_debug.c',
'wren/src/vm/wren_primitive.c',
'wren/src/vm/wren_utils.c',
'wren/src/vm/wren_value.c',
'wren/src/vm/wren_vm.c',
]
force_static = meson.is_subproject()
if force_static
wren = static_library(meson.project_name(),
opt_src,
vm_src,
include_directories: [wren_incl, wren_pvt_incl],
dependencies: [threads_dep, m_dep],
install: not force_static,
c_args: c_opts,
)
else
wren = library(meson.project_name(),
opt_src,
vm_src,
include_directories: [wren_incl, wren_pvt_incl],
dependencies: [threads_dep, m_dep],
install: not force_static,
c_args: c_opts,
)
endif
wren_dep = declare_dependency(
include_directories: [wren_incl],
link_with: wren,
)
if get_option('build_testing')
fs = import('fs')
test_src = [
'wren/test/api/api_tests.c',
'wren/test/api/benchmark.c',
'wren/test/api/call.c',
'wren/test/api/call_calls_foreign.c',
'wren/test/api/call_wren_call_root.c',
'wren/test/api/error.c',
'wren/test/api/foreign_class.c',
'wren/test/api/get_variable.c',
'wren/test/api/handle.c',
'wren/test/api/lists.c',
'wren/test/api/new_vm.c',
'wren/test/api/reset_stack_after_call_abort.c',
'wren/test/api/reset_stack_after_foreign_construct.c',
'wren/test/api/resolution.c',
'wren/test/api/slots.c',
'wren/test/api/user_data.c',
'wren/test/main.c',
'wren/test/test.c',
]
test_script_paths = [
'api', 'benchmark', 'core', 'language', 'limit', 'regression', 'unit'
]
if get_option('wren_with_meta')
test_script_paths += ['meta']
endif
if get_option('wren_with_rand')
test_script_paths += ['random']
endif
test_scripts = run_command(
files('find_scripts.py'),
meson.current_source_dir() / 'wren/test',
test_script_paths,
).stdout().strip().split('\n')
test_api = executable(meson.project_name() + '_test',
test_src,
install: false,
dependencies: [wren_dep, libuv_dep],
include_directories: [],
c_args: ['-D_XOPEN_SOURCE=600'],
)
foreach test_script : test_scripts
expects_fail = run_command(
files('guess_test_outcome.py'),
test_script,
).returncode() == 0
name = fs.stem(test_script)
test(
meson.project_name() + ' test ' + name,
test_api,
args: test_script,
is_parallel: true,
should_fail: expects_fail,
workdir: meson.current_source_dir() / 'wren',
)
endforeach
endif
if not force_static
install_headers(
'wren/src/include/wren.h',
'wren/src/include/wren.hpp',
)
endif