meson.build 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. project('linker script', 'c')
  2. # Static map file
  3. mapfile = 'bob.map'
  4. vflag = '-Wl,--version-script,@0@/@1@'.format(meson.current_source_dir(), mapfile)
  5. l = shared_library('bob', 'bob.c', link_args : vflag, link_depends : mapfile)
  6. e = executable('prog', 'prog.c', link_with : l)
  7. test('core', e)
  8. # configure_file
  9. conf = configuration_data()
  10. conf.set('in', 'bobMcBob')
  11. m = configure_file(
  12. input : 'bob.map.in',
  13. output : 'bob-conf.map',
  14. configuration : conf,
  15. )
  16. vflag = '-Wl,--version-script,@0@'.format(m)
  17. l = shared_library('bob-conf', 'bob.c', link_args : vflag, link_depends : m)
  18. e = executable('prog-conf', 'prog.c', link_with : l)
  19. test('core', e)
  20. # custom_target
  21. python = find_program('python3')
  22. m = custom_target(
  23. 'bob-ct.map',
  24. command : [python, '@INPUT0@', '@INPUT1@', 'bob-ct.map'],
  25. input : ['copy.py', 'bob.map'],
  26. output : 'bob-ct.map',
  27. depend_files : 'bob.map',
  28. )
  29. vflag = '-Wl,--version-script,@0@'.format(m.full_path())
  30. l = shared_library('bob-ct', ['bob.c', m], link_args : vflag, link_depends : m)
  31. e = executable('prog-ct', 'prog.c', link_with : l)
  32. test('core', e)
  33. # File
  34. mapfile = files('bob.map')
  35. vflag = '-Wl,--version-script,@0@/@1@'.format(meson.current_source_dir(), mapfile[0])
  36. l = shared_library('bob-files', 'bob.c', link_args : vflag, link_depends : mapfile)
  37. e = executable('prog-files', 'prog.c', link_with : l)
  38. test('core', e)
  39. subdir('sub')
  40. # With map file in subdir
  41. mapfile = 'sub/foo.map'
  42. vflag = '-Wl,--version-script,@0@/@1@'.format(meson.current_source_dir(), mapfile)
  43. l = shared_library('bar', 'bob.c', link_args : vflag, link_depends : mapfile)
  44. e = executable('prog-bar', 'prog.c', link_with : l)
  45. test('core', e)