2020-04-24 23:49:46 +00:00
|
|
|
project('wren', 'c',
|
2021-06-23 15:35:47 +00:00
|
|
|
version: '0.4.0',
|
2021-01-22 10:52:20 +00:00
|
|
|
meson_version: '>=0.54.0',
|
2020-04-30 22:49:52 +00:00
|
|
|
default_options: ['buildtype=release', 'c_std=c99', 'build_testing=true'],
|
2020-04-24 23:49:46 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
c_compiler = meson.get_compiler('c')
|
2020-05-01 17:57:03 +00:00
|
|
|
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
|
2020-04-24 23:49:46 +00:00
|
|
|
|
|
|
|
wren_incl = include_directories('wren/src/include', is_system: true)
|
|
|
|
wren_pvt_incl = include_directories('wren/src/vm', 'wren/src/optional')
|
2021-01-22 10:52:20 +00:00
|
|
|
test_incl = include_directories('wren/test')
|
2020-04-24 23:49:46 +00:00
|
|
|
|
|
|
|
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 = [
|
2021-01-22 10:52:20 +00:00
|
|
|
'wren/src/vm/wren_compiler.c',
|
2020-04-24 23:49:46 +00:00
|
|
|
'wren/src/vm/wren_core.c',
|
2021-01-22 10:52:20 +00:00
|
|
|
'wren/src/vm/wren_debug.c',
|
|
|
|
'wren/src/vm/wren_primitive.c',
|
2020-04-24 23:49:46 +00:00
|
|
|
'wren/src/vm/wren_utils.c',
|
|
|
|
'wren/src/vm/wren_value.c',
|
2021-01-22 10:52:20 +00:00
|
|
|
'wren/src/vm/wren_vm.c',
|
2020-04-24 23:49:46 +00:00
|
|
|
]
|
|
|
|
|
2020-04-30 22:33:51 +00:00
|
|
|
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,
|
2020-05-01 17:57:03 +00:00
|
|
|
c_args: c_opts,
|
2020-04-30 22:33:51 +00:00
|
|
|
)
|
|
|
|
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,
|
2020-05-01 17:57:03 +00:00
|
|
|
c_args: c_opts,
|
2020-04-30 22:33:51 +00:00
|
|
|
)
|
|
|
|
endif
|
2020-04-24 23:49:46 +00:00
|
|
|
wren_dep = declare_dependency(
|
|
|
|
include_directories: [wren_incl],
|
|
|
|
link_with: wren,
|
|
|
|
)
|
|
|
|
|
|
|
|
if get_option('build_testing')
|
2021-01-22 10:52:20 +00:00
|
|
|
fs = import('fs')
|
2021-01-22 12:45:29 +00:00
|
|
|
|
2021-01-22 10:52:20 +00:00
|
|
|
test_src = [
|
|
|
|
'wren/test/api/api_tests.c',
|
|
|
|
'wren/test/api/benchmark.c',
|
2020-04-24 23:49:46 +00:00
|
|
|
'wren/test/api/call.c',
|
2021-01-22 10:52:20 +00:00
|
|
|
'wren/test/api/call_calls_foreign.c',
|
2020-04-24 23:49:46 +00:00
|
|
|
'wren/test/api/call_wren_call_root.c',
|
|
|
|
'wren/test/api/error.c',
|
2021-01-22 10:52:20 +00:00
|
|
|
'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',
|
2020-04-24 23:49:46 +00:00
|
|
|
'wren/test/api/reset_stack_after_call_abort.c',
|
2021-01-22 10:52:20 +00:00
|
|
|
'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',
|
2020-04-24 23:49:46 +00:00
|
|
|
]
|
|
|
|
|
2021-01-22 10:52:20 +00:00
|
|
|
test_script_paths = [
|
|
|
|
'api', 'benchmark', 'core', 'language', 'limit', 'regression', 'unit'
|
2020-04-24 23:49:46 +00:00
|
|
|
]
|
|
|
|
|
2021-01-22 10:52:20 +00:00
|
|
|
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(
|
2021-01-22 12:45:29 +00:00
|
|
|
files('find_scripts.py'),
|
|
|
|
meson.current_source_dir() / 'wren/test',
|
2021-01-22 10:52:20 +00:00
|
|
|
test_script_paths,
|
|
|
|
).stdout().strip().split('\n')
|
|
|
|
|
|
|
|
test_api = executable(meson.project_name() + '_test',
|
|
|
|
test_src,
|
2020-04-24 23:49:46 +00:00
|
|
|
install: false,
|
|
|
|
dependencies: [wren_dep, libuv_dep],
|
2021-01-22 10:52:20 +00:00
|
|
|
include_directories: [],
|
2020-04-24 23:49:46 +00:00
|
|
|
c_args: ['-D_XOPEN_SOURCE=600'],
|
|
|
|
)
|
|
|
|
|
2021-01-22 10:52:20 +00:00
|
|
|
foreach test_script : test_scripts
|
2021-01-22 12:45:29 +00:00
|
|
|
expects_fail = run_command(
|
|
|
|
files('guess_test_outcome.py'),
|
|
|
|
test_script,
|
|
|
|
).returncode() == 0
|
|
|
|
|
2021-01-22 10:52:20 +00:00
|
|
|
name = fs.stem(test_script)
|
2021-01-22 12:45:29 +00:00
|
|
|
test(
|
|
|
|
meson.project_name() + ' test ' + name,
|
|
|
|
test_api,
|
|
|
|
args: test_script,
|
|
|
|
is_parallel: true,
|
|
|
|
should_fail: expects_fail,
|
|
|
|
workdir: meson.current_source_dir() / 'wren',
|
|
|
|
)
|
2021-01-22 10:52:20 +00:00
|
|
|
endforeach
|
2020-04-24 23:49:46 +00:00
|
|
|
endif
|
|
|
|
|
2020-04-30 22:33:51 +00:00
|
|
|
if not force_static
|
2020-04-24 23:49:46 +00:00
|
|
|
install_headers(
|
|
|
|
'wren/src/include/wren.h',
|
|
|
|
'wren/src/include/wren.hpp',
|
|
|
|
)
|
|
|
|
endif
|