wrenpp/subprojects/packagefiles/wren/meson.build

141 lines
3.1 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('src/include', is_system: true)
wren_pvt_incl = include_directories('src/vm', 'src/optional')
test_incl = include_directories('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 = [
'src/optional/wren_opt_random.c',
'src/optional/wren_opt_meta.c',
]
vm_src = [
'src/vm/wren_compiler.c',
'src/vm/wren_core.c',
'src/vm/wren_debug.c',
'src/vm/wren_primitive.c',
'src/vm/wren_utils.c',
'src/vm/wren_value.c',
'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 = [
'test/api/api_tests.c',
'test/api/benchmark.c',
'test/api/call.c',
'test/api/call_calls_foreign.c',
'test/api/call_wren_call_root.c',
'test/api/error.c',
'test/api/foreign_class.c',
'test/api/get_variable.c',
'test/api/handle.c',
'test/api/lists.c',
'test/api/new_vm.c',
'test/api/reset_stack_after_call_abort.c',
'test/api/reset_stack_after_foreign_construct.c',
'test/api/resolution.c',
'test/api/slots.c',
'test/api/user_data.c',
'test/main.c',
'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() / '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(
'src/include/wren.h',
'src/include/wren.hpp',
)
endif