| 1 |
project('test-d-run-checks', 'd') |
| 2 |
|
| 3 |
dc = meson.get_compiler('d') |
| 4 |
|
| 5 |
run_sizeof = dc.run('int main() { return (void*).sizeof; }') |
| 6 |
if run_sizeof.returncode() == 8 |
| 7 |
run_versions = ['Is64bits'] |
| 8 |
elif run_sizeof.returncode() == 4 |
| 9 |
run_versions = ['Is32bits'] |
| 10 |
endif |
| 11 |
run_sizeof_exe = executable('run_sizeof', 'test_sizeof.d', |
| 12 |
d_module_versions: run_versions, |
| 13 |
) |
| 14 |
test('test D compiler run', run_sizeof_exe) |
| 15 |
|
| 16 |
sizeof_sizeof = dc.sizeof('void*') |
| 17 |
if sizeof_sizeof == 8 |
| 18 |
run_versions = ['Is64bits'] |
| 19 |
elif sizeof_sizeof == 4 |
| 20 |
run_versions = ['Is32bits'] |
| 21 |
endif |
| 22 |
sizeof_sizeof_exe = executable('sizeof_sizeof', 'test_sizeof.d', |
| 23 |
d_module_versions: run_versions, |
| 24 |
) |
| 25 |
test('test D compiler sizeof', sizeof_sizeof_exe) |
| 26 |
|
| 27 |
if not dc.has_header('std.stdio') |
| 28 |
error('Could not find std.stdio import') |
| 29 |
endif |
| 30 |
|
| 31 |
if dc.has_header('not_a_d_module') |
| 32 |
error('has_header inconsistent result') |
| 33 |
endif |
| 34 |
|
| 35 |
# same checks as C/C++ alignments (D has same alignment requirements as C) |
| 36 |
|
| 37 |
# These tests should return the same value on all |
| 38 |
# platforms. If (and when) they don't, fix 'em up. |
| 39 |
if dc.alignment('char') != 1 |
| 40 |
error('Alignment of char misdetected.') |
| 41 |
endif |
| 42 |
|
| 43 |
dbl_alignment = dc.alignment('double') |
| 44 |
|
| 45 |
if dbl_alignment == 8 or dbl_alignment == 4 |
| 46 |
message('Alignment of double ok.') |
| 47 |
else |
| 48 |
error('Alignment of double misdetected.') |
| 49 |
endif |
| 50 |
|