meson: fix build
parent
bcaa2178cf
commit
466b80b96b
|
@ -0,0 +1,27 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
if (argc < 3) {
|
||||
return 1;
|
||||
}
|
||||
FILE *f = fopen(argv[2], "w");
|
||||
if (!f) {
|
||||
return 1;
|
||||
}
|
||||
fprintf(f,
|
||||
"#define OSTD_BUILD_TESTS libostd_%s\n"
|
||||
"\n"
|
||||
"#include <ostd/unit_test.hh>\n"
|
||||
"#include <ostd/%s.hh>\n"
|
||||
"#include <ostd/io.hh>\n"
|
||||
"\n"
|
||||
"int main() {\n"
|
||||
" auto [ succ, fail ] = ostd::test::run();\n"
|
||||
" ostd::writeln(succ, \" \", fail);\n"
|
||||
" return 0;\n"
|
||||
"}\n",
|
||||
argv[1], argv[1]
|
||||
);
|
||||
fclose(f);
|
||||
return 0;
|
||||
}
|
|
@ -6,15 +6,38 @@ test_runner_exe = executable('test_runner',
|
|||
install: false
|
||||
)
|
||||
|
||||
libostd_tests_src = [
|
||||
'algorithm.cc',
|
||||
'range.cc'
|
||||
libostd_gen_test_exe = executable('gen_test',
|
||||
['gen_test.cc'],
|
||||
install: false,
|
||||
native: true
|
||||
)
|
||||
|
||||
libostd_tests_names = [
|
||||
'algorithm',
|
||||
'range'
|
||||
]
|
||||
|
||||
libostd_tests_indices = [
|
||||
0, 1
|
||||
]
|
||||
|
||||
libostd_tests_src = []
|
||||
|
||||
foreach test_name: libostd_tests_names
|
||||
libostd_tests_src += custom_target('test_' + test_name,
|
||||
output: [test_name + '.cc'],
|
||||
install: false,
|
||||
command: [
|
||||
libostd_gen_test_exe, test_name,
|
||||
join_paths(meson.current_build_dir(), test_name + '.cc')
|
||||
]
|
||||
)
|
||||
endforeach
|
||||
|
||||
test_target = []
|
||||
foreach test_src: libostd_tests_src
|
||||
test_target += executable(test_src.split('.')[0],
|
||||
[test_src],
|
||||
foreach test_idx: libostd_tests_indices
|
||||
test_target += executable(libostd_tests_names[test_idx],
|
||||
[libostd_tests_src[test_idx]],
|
||||
dependencies: libostd,
|
||||
include_directories: libostd_includes,
|
||||
cpp_args: extra_cxxflags,
|
||||
|
|
Loading…
Reference in New Issue