summaryrefslogtreecommitdiffstats
path: root/test cases/linuxlike/3 linker script/meson.build
blob: 5901bf7cf716a1e60e5c179f0f536db86f3a1241 (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
project('linker script', 'c')

# Solaris 11.4 ld supports --version-script only when you also specify
# -z gnu-version-script-compat
if meson.get_compiler('c').get_linker_id() == 'ld.solaris'
  add_project_link_arguments('-Wl,-z,gnu-version-script-compat', language: 'C')
endif

# Static map file
mapfile = 'bob.map'
vflag = '-Wl,--version-script,@0@/@1@'.format(meson.current_source_dir(), mapfile)

l = shared_library('bob', 'bob.c', link_args : vflag, link_depends : mapfile)
e = executable('prog', 'prog.c', link_with : l)
test('core', e)

# configure_file
conf = configuration_data()
conf.set('in', 'bobMcBob')
m = configure_file(
  input : 'bob.map.in',
  output : 'bob-conf.map',
  configuration : conf,
)
vflag = '-Wl,--version-script,@0@'.format(m)

l = shared_library('bob-conf', 'bob.c', link_args : vflag, link_depends : m)
e = executable('prog-conf', 'prog.c', link_with : l)
test('core', e)

# custom_target
python = find_program('python3')
m = custom_target(
  'bob-ct.map',
  command : [python, '@INPUT0@', '@INPUT1@', 'bob-ct.map'],
  input : ['copy.py', 'bob.map'],
  output : 'bob-ct.map',
  depend_files : 'bob.map',
)
vflag = '-Wl,--version-script,@0@'.format(m.full_path())

l = shared_library('bob-ct', ['bob.c', m], link_args : vflag, link_depends : m)
e = executable('prog-ct', 'prog.c', link_with : l)
test('core', e)

# File
mapfile = files('bob.map')
vflag = '-Wl,--version-script,@0@/@1@'.format(meson.current_source_dir(), mapfile[0])

l = shared_library('bob-files', 'bob.c', link_args : vflag, link_depends : mapfile)
e = executable('prog-files', 'prog.c', link_with : l)
test('core', e)

subdir('sub')

# With map file in subdir
mapfile = 'sub/foo.map'
vflag = '-Wl,--version-script,@0@/@1@'.format(meson.current_source_dir(), mapfile)

l = shared_library('bar', 'bob.c', link_args : vflag, link_depends : mapfile)
e = executable('prog-bar', 'prog.c', link_with : l)
test('core', e)