summaryrefslogtreecommitdiffstats
path: root/test cases/nasm/2 asm language/meson.build
blob: 390ffed3f841e7dc32fe1bce5023f80f8b2d56c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
project('test', 'c')

if not host_machine.cpu_family().startswith('x86')
  assert(not add_languages('nasm', required: false))
  error('MESON_SKIP_TEST: nasm only supported for x86 and x86_64')
endif

if not add_languages('nasm', required: false)
  nasm = find_program('nasm', 'yasm', required: false)
  assert(not nasm.found())
  error('MESON_SKIP_TEST: nasm not found')
endif

nasm = meson.get_compiler('nasm')

code = '''
SECTION .text
global main
main:
  mov foo,bar ; error: symbol `foo' not defined
'''
assert(not nasm.compiles(code, name: 'Invalid NASM code'))

code = '''
SECTION .text
global main
main:
  mov eax,1
'''
assert(nasm.compiles(code, name: 'Valid NASM code'))

config_file = configure_file(
  output: 'config.asm',
  configuration: {'HELLO': 0},
  output_format: 'nasm',
)

cc = meson.get_compiler('c')
link_args = cc.get_supported_link_arguments(['-no-pie'])

exe = executable('hello', 'hello.asm',
  nasm_args: '-DFOO',
  link_args: link_args,
)
test('hello', exe)

#Test whether pthread dependency gets filtered out
threads = dependency('threads')

exe2 = executable('hello_w_threads', 'hello.asm',
  config_file,
  nasm_args: '-DFOO',
  link_args: link_args,
  dependencies: [threads]
)

test('hello_w_threads', exe2)