| 1 |
project('generated assembly', 'c') |
| 2 |
|
| 3 |
cc = meson.get_compiler('c') |
| 4 |
|
| 5 |
if ['msvc', 'intel-cl'].contains(cc.get_id()) |
| 6 |
error('MESON_SKIP_TEST: assembly files cannot be compiled directly by the compiler') |
| 7 |
endif |
| 8 |
|
| 9 |
if meson.backend() == 'xcode' |
| 10 |
error('MESON_SKIP_TEST: asm not supported with the Xcode backend. Patches welcome.') |
| 11 |
endif |
| 12 |
|
| 13 |
|
| 14 |
crt_workaround = [] |
| 15 |
if cc.get_linker_id() == 'lld-link' |
| 16 |
# It seems that when building without a .c file, lld-link.exe |
| 17 |
# misses the fact that it needs to include the c runtime to |
| 18 |
# make a working .dll. So here we add an empty .c file to easily |
| 19 |
# pull in crt. |
| 20 |
crt_workaround += 'empty.c' |
| 21 |
if host_machine.cpu_family() == 'x86' |
| 22 |
# x86 assembly needs manual annotation to be compatible with |
| 23 |
# Safe Exception Handlers (?) This assembly doesn't have such |
| 24 |
# annotation, so just disable the feature. |
| 25 |
add_project_link_arguments('/SAFESEH:NO', language : 'c') |
| 26 |
endif |
| 27 |
endif |
| 28 |
|
| 29 |
cpu = host_machine.cpu_family() |
| 30 |
supported_cpus = ['arm', 'x86', 'x86_64'] |
| 31 |
|
| 32 |
if not supported_cpus.contains(cpu) |
| 33 |
error('MESON_SKIP_TEST: unsupported cpu family: ' + cpu) |
| 34 |
endif |
| 35 |
|
| 36 |
if cc.get_id() == 'clang-cl' and cc.version().version_compare('< 12.0.0') and cpu == 'arm' |
| 37 |
# https://reviews.llvm.org/D89622 |
| 38 |
error('MESON_SKIP_TEST: arm debug symbols not supported in clang-cl < 12.0.0') |
| 39 |
endif |
| 40 |
|
| 41 |
if cc.symbols_have_underscore_prefix() |
| 42 |
add_project_arguments('-DMESON_TEST__UNDERSCORE_SYMBOL', language : 'c') |
| 43 |
endif |
| 44 |
|
| 45 |
copy = find_program('copyfile.py') |
| 46 |
output = 'square-@[email protected]'.format(cpu) |
| 47 |
input = output + '.in' |
| 48 |
|
| 49 |
copygen = generator(copy, |
| 50 |
arguments : ['@INPUT@', '@OUTPUT@'], |
| 51 |
output : '@BASENAME@') |
| 52 |
|
| 53 |
l = library('square-gen', crt_workaround + [copygen.process(input)], |
| 54 |
vs_module_defs: 'square.def') |
| 55 |
|
| 56 |
test('square-gen-test', executable('square-gen-test', 'main.c', link_with : l)) |
| 57 |
|
| 58 |
copyct = custom_target('square', |
| 59 |
input : input, |
| 60 |
output : output, |
| 61 |
command : [copy, '@INPUT@', '@OUTPUT@']) |
| 62 |
|
| 63 |
l = library('square-ct', crt_workaround + [copyct], |
| 64 |
vs_module_defs: 'square.def') |
| 65 |
|
| 66 |
test('square-ct-test', executable('square-ct-test', 'main.c', link_with : l)) |