From 37d15f97d608b26388f7c9946e3a3dd9450728ea Mon Sep 17 00:00:00 2001 From: Mergul Date: Sat, 6 Mar 2021 22:00:08 +0100 Subject: [PATCH] -fixed some meson issues on windows (becs and tests compilation works. Demos not yet) -now tests compile proper files -added setjmp bindings for Windows. It doesn't work on LDC build (singal API could works) --- meson.build | 6 +++++- meson_options.txt | 1 + tests/meson.build | 12 ++++++++++-- tests/runner.d | 45 +++++++++++++++++++++++++++++++++++---------- 4 files changed, 51 insertions(+), 13 deletions(-) diff --git a/meson.build b/meson.build index d5cb683..0aff444 100644 --- a/meson.build +++ b/meson.build @@ -3,10 +3,12 @@ project('decs', 'd', version : '0.5.0') # Options betterC_opt = get_option('betterC') BuildDemos_opt = get_option('BuildDemos') +BuildTests_opt = get_option('BuildTests') LTO_otp = get_option('LTO') summary('betterC enabled', betterC_opt) summary('build demos', BuildDemos_opt) +summary('build tests', BuildTests_opt) summary('LTO enabled', LTO_otp) meson_minimum_version = '>=0.57.1' @@ -65,7 +67,9 @@ decs_dep = declare_dependency( ) # Tests -subdir('tests') +if BuildTests_opt + subdir('tests') +endif # Demos if BuildDemos_opt diff --git a/meson_options.txt b/meson_options.txt index 1ab62f0..335f32b 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1,3 +1,4 @@ option('betterC', type: 'boolean', value: false) option('BuildDemos', type: 'boolean', value: false) +option('BuildTests', type: 'boolean', value: false) option('LTO', type: 'boolean', value: false) diff --git a/tests/meson.build b/tests/meson.build index dae8536..cfccaa7 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -1,10 +1,18 @@ tests_src = files( - 'tests.d', + 'access_perf.d', + 'basic.d', + 'bugs.d', + 'id_manager.d', + 'map.d', + 'perf.d', + 'runner.d', + 'time.d', + 'vector.d' ) exe = executable('decs-tests', tests_src, - include_directories : [inc], + include_directories : [inc, include_directories('..')], d_args : args, link_args : link_args, dependencies : decs_dep, diff --git a/tests/runner.d b/tests/runner.d index 83c2288..b779056 100644 --- a/tests/runner.d +++ b/tests/runner.d @@ -3,7 +3,6 @@ module tests.runner; import core.stdc.stdio; import core.stdc.string; -import core.sys.posix.setjmp; import bubel.ecs.vector; import bubel.ecs.simple_vector; @@ -25,11 +24,36 @@ else enum int ASSERTED = 123; enum string OUT_FILE = "test_report.xml"; -static jmp_buf gEnvBuffer; -static AssertInfo gAssertInfo; - version (D_BetterC) { + version(Posix) + { + import core.sys.posix.setjmp; + } + else version(Windows) + { + version(X86) + alias jmp_buf = ubyte[64]; + else version(X86_64) + alias jmp_buf = ubyte[256]; + else version(IA64) + alias jmp_buf = ubyte[512]; + + extern (C) { + int _setjmp(ref jmp_buf); + void longjmp(ref jmp_buf, int); + } + alias setjmp = _setjmp; + } + + static jmp_buf gEnvBuffer; + static AssertInfo gAssertInfo; + + extern (C) void __assert(const char* msg, const char* file, int line) + { + gAssertInfo = AssertInfo(msg, file, line); + longjmp(gEnvBuffer, ASSERTED); + } } else version = notBetterC; @@ -40,12 +64,6 @@ struct AssertInfo int line; } -extern (C) void __assert(const char* msg, const char* file, int line) -{ - gAssertInfo = AssertInfo(msg, file, line); - longjmp(gEnvBuffer, ASSERTED); -} - struct Test { string file; @@ -427,6 +445,13 @@ extern (C) int main(int argc, char** args) } } + static import tests.id_manager; + static import tests.vector; + static import tests.basic; + static import tests.perf; + static import tests.access_perf; + static import tests.bugs; + static import tests.map; TestRunner!(tests.id_manager, tests.vector, tests.basic, tests.perf, tests.access_perf, tests.bugs, tests.map) runner; runner.runTests(include[], exclude[]);