| 1 |
project('D Features', 'd', meson_version: '>=1.6', default_options : ['debug=false']) |
| 2 |
|
| 3 |
dc = meson.get_compiler('d') |
| 4 |
|
| 5 |
# See: https://dlang.org/changelog/2.111.0.html#dmd.deprecation-version-debug-number |
| 6 |
# GDC fails even before that: https://github.com/mesonbuild/meson/pull/11996 |
| 7 |
if dc.get_id() == 'gcc' |
| 8 |
number_options_supported = dc.version().version_compare('<13') |
| 9 |
elif dc.get_id() == 'dmd' |
| 10 |
number_options_supported = dc.version().version_compare('<2.111') |
| 11 |
elif dc.get_id() == 'llvm' |
| 12 |
number_options_supported = dc.version().version_compare('<1.41') |
| 13 |
else |
| 14 |
error(f'Unknown D compiler id') |
| 15 |
endif |
| 16 |
|
| 17 |
# ONLY FOR BACKWARDS COMPATIBILITY. |
| 18 |
# DO NOT DO THIS IN NEW CODE! |
| 19 |
# USE include_directories() INSTEAD OF BUILDING |
| 20 |
# STRINGS TO PATHS MANUALLY! |
| 21 |
data_dir = join_paths(meson.current_source_dir(), 'data') |
| 22 |
|
| 23 |
test_src = ['app.d', 'extra.d'] |
| 24 |
|
| 25 |
e_plain_bcompat = executable('dapp_menu_bcompat', |
| 26 |
test_src, |
| 27 |
d_import_dirs: [data_dir] |
| 28 |
) |
| 29 |
test('dapp_menu_t_fail_bcompat', e_plain_bcompat, should_fail: true) |
| 30 |
test('dapp_menu_t_bcompat', e_plain_bcompat, args: ['menu']) |
| 31 |
|
| 32 |
# directory for data |
| 33 |
# This is the correct way to do this. |
| 34 |
data_dir = include_directories('data') |
| 35 |
|
| 36 |
e_plain = executable('dapp_menu', |
| 37 |
test_src, |
| 38 |
d_import_dirs: [data_dir] |
| 39 |
) |
| 40 |
test('dapp_menu_t_fail', e_plain, should_fail: true) |
| 41 |
test('dapp_menu_t', e_plain, args: ['menu']) |
| 42 |
|
| 43 |
|
| 44 |
# test feature versions and string imports |
| 45 |
e_versions = executable('dapp_versions', |
| 46 |
test_src, |
| 47 |
d_import_dirs: [data_dir], |
| 48 |
d_module_versions: ['No_Menu', 'With_People'] |
| 49 |
) |
| 50 |
test('dapp_versions_t_fail', e_versions, args: ['menu'], should_fail: true) |
| 51 |
test('dapp_versions_t', e_versions, args: ['people']) |
| 52 |
|
| 53 |
# test everything and unittests |
| 54 |
e_test = executable('dapp_test', |
| 55 |
test_src, |
| 56 |
d_import_dirs: [data_dir], |
| 57 |
d_module_versions: ['No_Menu', 'With_People'], |
| 58 |
d_unittest: true |
| 59 |
) |
| 60 |
test('dapp_test', e_test) |
| 61 |
|
| 62 |
# test version level |
| 63 |
if number_options_supported |
| 64 |
e_version_int = executable('dapp_version_int', |
| 65 |
test_src, |
| 66 |
d_import_dirs: [data_dir], |
| 67 |
d_module_versions: ['With_VersionInteger', 3], |
| 68 |
) |
| 69 |
test('dapp_version_int_t', e_version_int, args: ['debug']) |
| 70 |
|
| 71 |
# test version level failure |
| 72 |
e_version_int_fail = executable('dapp_version_int_fail', |
| 73 |
test_src, |
| 74 |
d_import_dirs: [data_dir], |
| 75 |
d_module_versions: ['With_VersionInteger', 2], |
| 76 |
) |
| 77 |
test('dapp_version_int_t_fail', e_version_int_fail, args: ['debug'], should_fail: true) |
| 78 |
endif |
| 79 |
|
| 80 |
# test debug conditions: disabled |
| 81 |
e_no_debug = executable('dapp_no_debug', |
| 82 |
test_src, |
| 83 |
d_import_dirs: [data_dir], |
| 84 |
d_module_versions: ['With_Debug'], |
| 85 |
) |
| 86 |
test('dapp_no_debug_t_fail', e_no_debug, args: ['debug'], should_fail: true) |
| 87 |
|
| 88 |
if number_options_supported |
| 89 |
# test debug conditions: enabled |
| 90 |
e_debug = executable('dapp_debug', |
| 91 |
test_src, |
| 92 |
d_import_dirs: [data_dir], |
| 93 |
d_module_versions: ['With_Debug'], |
| 94 |
d_debug: 1, |
| 95 |
) |
| 96 |
test('dapp_debug_t', e_debug, args: ['debug']) |
| 97 |
|
| 98 |
# test debug conditions: integer |
| 99 |
e_debug_int = executable('dapp_debug_int', |
| 100 |
test_src, |
| 101 |
d_import_dirs: [data_dir], |
| 102 |
d_module_versions: ['With_DebugInteger'], |
| 103 |
d_debug: 3, |
| 104 |
) |
| 105 |
test('dapp_debug_int_t', e_debug_int, args: ['debug']) |
| 106 |
|
| 107 |
# test with all debug conditions at once, and with redundant values |
| 108 |
e_debug_all = executable('dapp_debug_all', |
| 109 |
test_src, |
| 110 |
d_import_dirs: [data_dir], |
| 111 |
d_module_versions: ['With_DebugAll'], |
| 112 |
d_debug: ['4', 'DebugIdentifier', 2, 'DebugIdentifierUnused'], |
| 113 |
) |
| 114 |
test('dapp_debug_all_t', e_debug_all, args: ['debug']) |
| 115 |
endif |
| 116 |
|
| 117 |
# test debug conditions: identifier |
| 118 |
e_debug_ident = executable('dapp_debug_ident', |
| 119 |
test_src, |
| 120 |
d_import_dirs: [data_dir], |
| 121 |
d_module_versions: ['With_DebugIdentifier'], |
| 122 |
d_debug: 'DebugIdentifier', |
| 123 |
) |
| 124 |
test('dapp_debug_ident_t', e_debug_ident, args: ['debug']) |