forked from mesonbuild/meson
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow link_depends to take strings, Files or generated objects. Closes …
…mesonbuild#1172 Currently only strings can be passed to the link_depends argument of executable and *library, which solves many cases, but not every one. This patch allows generated sources and Files to be passed as well. On the implementation side, it uses a helper method to keep the more complex logic separated from the __init__ method. This also requires that Targets set their link_depends paths as Files, and the backend is responsible for converting to strings when it wants them. This adds tests for the following cases: - Using a file in a subdir - Using a configure_file as an input - Using a custom_target as an input It does not support using a generator as an input, since currently that would require calling the generator twice, once for the -Wl argument, and once for the link_depends. Also updates the docs.
- Loading branch information
Showing
8 changed files
with
114 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
V1_0_0 { | ||
global: | ||
"@in@"; | ||
local: | ||
*; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import shutil | ||
import sys | ||
|
||
if __name__ == '__main__': | ||
shutil.copy(sys.argv[1], sys.argv[2]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,56 @@ | ||
project('linker script', 'c') | ||
|
||
# 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
V1_0_0 { | ||
global: | ||
"bobMcBob"; | ||
local: | ||
*; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
mapfile = 'foo.map' | ||
vflag = '-Wl,--version-script,@0@/@1@'.format(meson.current_source_dir(), mapfile) | ||
|
||
l = shared_library('foo', '../bob.c', link_args : vflag, link_depends : mapfile) | ||
e = executable('prog-foo', '../prog.c', link_with : l) | ||
test('core', e) |