summaryrefslogtreecommitdiff
path: root/test cases/nasm/1 configure file/meson.build
blob: 46a704ceb633fea881b1392d4c7e95861d7338fc (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
58
59
60
61
62
63
project('nasm config file', 'c')

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

if host_machine.system() != 'linux'
  error('MESON_SKIP_TEST: this test asm is made for Linux')
endif

if host_machine.cpu_family() == 'x86'
  asm_format = 'elf32'
else
  asm_format = 'elf64'
endif

nasm = find_program('nasm', required: false)

if not nasm.found()
  error('MESON_SKIP_TEST: nasm not available')
endif

conf = configuration_data()

conf.set('HELLO', 0)

debug_nasm = []
if get_option('debug')
  debug_nasm = ['-g']
endif

asm_gen = generator(nasm,
  output : '@BASENAME@.o',
  arguments : [
    '-f', asm_format,
    debug_nasm,
    '-i', meson.current_source_dir() + '/',
    '-i', join_paths(meson.current_source_dir(), ''),
    '-P', join_paths(meson.current_build_dir(), 'config.asm'),
    '@INPUT@',
    '-o', '@OUTPUT@'])


config_file = configure_file(
  output: 'config.asm',
  configuration: conf,
  output_format: 'nasm',
)

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

exe = executable('hello', asm_gen.process('hello-' + host_machine.cpu_family() + '.asm'),
  link_args: link_args,
)

test('test-nasm-configure-file', exe)

exe2 = executable('hello2', objects : exe.extract_all_objects(),
  link_args: link_args,
)

test('test-nasm-extract-all-objects', exe2)