Debian Codegraph @

test cases/nasm/2 asm language/meson.build

raw
1 project('test', 'c')
2
3 if not host_machine.cpu_family().startswith('x86')
4 assert(not add_languages('nasm', required: false))
5 error('MESON_SKIP_TEST: nasm only supported for x86 and x86_64')
6 endif
7
8 if host_machine.system() != 'linux'
9 error('MESON_SKIP_TEST: this test asm is made for Linux')
10 endif
11
12 if meson.backend().startswith('vs')
13 error('MESON_SKIP_TEST: VS backend does not recognise NASM yet')
14 endif
15
16 if not add_languages('nasm', required: false)
17 nasm = find_program('nasm', 'yasm', required: false)
18 assert(not nasm.found())
19 error('MESON_SKIP_TEST: nasm not found')
20 endif
21
22 nasm = meson.get_compiler('nasm')
23
24 code = '''
25 SECTION .text
26 global main
27 main:
28 mov foo,bar ; error: symbol `foo' not defined
29 '''
30 assert(not nasm.compiles(code, name: 'Invalid NASM code'))
31
32 code = '''
33 SECTION .text
34 global main
35 main:
36 mov eax,1
37 '''
38 assert(nasm.compiles(code, name: 'Valid NASM code'))
39
40 config_file = configure_file(
41 output: 'config.asm',
42 configuration: {'HELLO': 0},
43 output_format: 'nasm',
44 )
45
46 cc = meson.get_compiler('c')
47 link_args = cc.get_supported_link_arguments(['-no-pie'])
48
49 exe = executable('hello', 'hello-' + host_machine.cpu_family() + '.asm',
50 nasm_args: '-DFOO',
51 link_args: link_args,
52 )
53 test('hello', exe)
54
55 #Test whether pthread dependency gets filtered out
56 threads = dependency('threads')
57
58 exe2 = executable('hello_w_threads', 'hello-' + host_machine.cpu_family() + '.asm',
59 config_file,
60 nasm_args: '-DFOO',
61 link_args: link_args,
62 dependencies: [threads]
63 )
64
65 test('hello_w_threads', exe2)