Cleaning up the wren dependency
This commit is contained in:
parent
40c362f6da
commit
ebca413c0a
8 changed files with 42 additions and 37 deletions
17
subprojects/packagefiles/wren/find_scripts.py
Executable file
17
subprojects/packagefiles/wren/find_scripts.py
Executable file
|
@ -0,0 +1,17 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
from pathlib import Path
|
||||
import sys
|
||||
import os
|
||||
|
||||
if len(sys.argv) < 3:
|
||||
sys.stderr.write("Usage: {0} <prefix> <paths>...\n".format(sys.argv[0]))
|
||||
exit(2)
|
||||
|
||||
prefix = sys.argv[1]
|
||||
search_paths = sys.argv[2:]
|
||||
|
||||
for search_path in search_paths:
|
||||
curr_path = os.path.join(prefix, search_path)
|
||||
for path in Path(curr_path).rglob('*.wren'):
|
||||
sys.stdout.write(str(path) + "\n")
|
20
subprojects/packagefiles/wren/guess_test_outcome.py
Executable file
20
subprojects/packagefiles/wren/guess_test_outcome.py
Executable file
|
@ -0,0 +1,20 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
import re
|
||||
|
||||
if len(sys.argv) != 2:
|
||||
sys.stderr.write("Please specify a file path\n")
|
||||
exit(2)
|
||||
|
||||
try:
|
||||
my_file = open(sys.argv[1], mode='r')
|
||||
text = my_file.read()
|
||||
my_file.close()
|
||||
except UnicodeDecodeError:
|
||||
exit(0)
|
||||
|
||||
if re.search(r"expect\s+(?:runtime\s+)?\berror", text):
|
||||
exit(0)
|
||||
else:
|
||||
exit(1)
|
141
subprojects/packagefiles/wren/meson.build
Normal file
141
subprojects/packagefiles/wren/meson.build
Normal file
|
@ -0,0 +1,141 @@
|
|||
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
|
3
subprojects/packagefiles/wren/meson_options.txt
Normal file
3
subprojects/packagefiles/wren/meson_options.txt
Normal file
|
@ -0,0 +1,3 @@
|
|||
option('build_testing', type: 'boolean', value: false, yield: true)
|
||||
option('wren_with_rand', type: 'boolean', value: false, yield: true)
|
||||
option('wren_with_meta', type: 'boolean', value: false, yield: true)
|
Loading…
Add table
Add a link
Reference in a new issue