| 1 |
project('nasm config file', 'c') |
| 2 |
|
| 3 |
if not host_machine.cpu_family().startswith('x86') |
| 4 |
error('MESON_SKIP_TEST: nasm only supported for x86 and x86_64') |
| 5 |
endif |
| 6 |
|
| 7 |
if host_machine.system() != 'linux' |
| 8 |
error('MESON_SKIP_TEST: this test asm is made for Linux') |
| 9 |
endif |
| 10 |
|
| 11 |
if host_machine.cpu_family() == 'x86' |
| 12 |
asm_format = 'elf32' |
| 13 |
elif host_machine.cpu() == 'x32' |
| 14 |
asm_format = 'elfx32' |
| 15 |
else |
| 16 |
asm_format = 'elf64' |
| 17 |
endif |
| 18 |
|
| 19 |
nasm = find_program('nasm', required: false) |
| 20 |
|
| 21 |
if not nasm.found() |
| 22 |
error('MESON_SKIP_TEST: nasm not available') |
| 23 |
endif |
| 24 |
|
| 25 |
conf = configuration_data() |
| 26 |
|
| 27 |
conf.set('HELLO', 0) |
| 28 |
|
| 29 |
debug_nasm = [] |
| 30 |
if get_option('debug') |
| 31 |
debug_nasm = ['-g'] |
| 32 |
endif |
| 33 |
|
| 34 |
asm_gen = generator(nasm, |
| 35 |
output : '@[email protected]', |
| 36 |
arguments : [ |
| 37 |
'-f', asm_format, |
| 38 |
debug_nasm, |
| 39 |
'-i', meson.current_source_dir() + '/', |
| 40 |
'-i', join_paths(meson.current_source_dir(), ''), |
| 41 |
'-P', join_paths(meson.current_build_dir(), 'config.asm'), |
| 42 |
'@INPUT@', |
| 43 |
'-o', '@OUTPUT@']) |
| 44 |
|
| 45 |
|
| 46 |
config_file = configure_file( |
| 47 |
output: 'config.asm', |
| 48 |
configuration: conf, |
| 49 |
output_format: 'nasm', |
| 50 |
) |
| 51 |
|
| 52 |
cc = meson.get_compiler('c') |
| 53 |
link_args = cc.get_supported_link_arguments(['-no-pie']) |
| 54 |
|
| 55 |
exe = executable('hello', asm_gen.process('hello-' + host_machine.cpu_family() + '.asm'), |
| 56 |
link_args: link_args, |
| 57 |
) |
| 58 |
|
| 59 |
test('test-nasm-configure-file', exe) |
| 60 |
|
| 61 |
exe2 = executable('hello2', objects : exe.extract_all_objects(), |
| 62 |
link_args: link_args, |
| 63 |
) |
| 64 |
|
| 65 |
test('test-nasm-extract-all-objects', exe2) |