aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/backend/backends.py
diff options
context:
space:
mode:
authorJon Turney <jon.turney@dronecode.org.uk>2017-04-14 13:58:21 +0100
committerJon Turney <jon.turney@dronecode.org.uk>2017-07-20 21:11:56 +0100
commit3fa3922cea27026d44aef1cdf3ca92d82adc7ced (patch)
tree512b4bed85b53dfd95add859b0724a1ed84d9754 /mesonbuild/backend/backends.py
parentb43f4841ba5de2e8bc956eb9fd1f578f90d7ae15 (diff)
downloadmeson-3fa3922cea27026d44aef1cdf3ca92d82adc7ced.zip
meson-3fa3922cea27026d44aef1cdf3ca92d82adc7ced.tar.gz
meson-3fa3922cea27026d44aef1cdf3ca92d82adc7ced.tar.bz2
Support implibs for executables on Windows
Add a boolean 'implib' kwarg to executable(). If true, it is permitted to use the returned build target object in link_with: On platforms where this makes sense (e.g. Windows), an implib is generated for the executable and used when linking. Otherwise, it has no effect. (Rather than checking if it is a StaticLibrary or SharedLibary, BuildTarget subclasses gain the is_linkable_target method to test if they can appear in link_with:) Also install any executable implib in a similar way to a shared library implib, i.e. placing the implib in the appropriate place Add tests of: - a shared_module containing a reference to a symbol which is known (at link time) to be provided by the executable - trying to link with non-implib executables (should fail) - installing the implib (This last one needs a little enhancement of the installed file checking as this is the first install test we have which needs to work with either MSVC-style or GCC-style implib filenames)
Diffstat (limited to 'mesonbuild/backend/backends.py')
-rw-r--r--mesonbuild/backend/backends.py16
1 files changed, 11 insertions, 5 deletions
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py
index cadb655..f967de0 100644
--- a/mesonbuild/backend/backends.py
+++ b/mesonbuild/backend/backends.py
@@ -140,7 +140,12 @@ class Backend:
return os.path.join(self.get_target_dir(target), link_lib)
elif isinstance(target, build.StaticLibrary):
return os.path.join(self.get_target_dir(target), target.get_filename())
- raise AssertionError('BUG: Tried to link to something that\'s not a library')
+ elif isinstance(target, build.Executable):
+ if target.import_filename:
+ return os.path.join(self.get_target_dir(target), target.get_import_filename())
+ else:
+ return None
+ raise AssertionError('BUG: Tried to link to {!r} which is not linkable'.format(target))
def get_target_dir(self, target):
if self.environment.coredata.get_builtin_option('layout') == 'mirror':
@@ -463,12 +468,13 @@ class Backend:
def build_target_link_arguments(self, compiler, deps):
args = []
for d in deps:
- if not isinstance(d, (build.StaticLibrary, build.SharedLibrary)):
+ if not (d.is_linkable_target()):
raise RuntimeError('Tried to link with a non-library target "%s".' % d.get_basename())
+ d_arg = self.get_target_filename_for_linking(d)
+ if not d_arg:
+ continue
if isinstance(compiler, (compilers.LLVMDCompiler, compilers.DmdDCompiler)):
- d_arg = '-L' + self.get_target_filename_for_linking(d)
- else:
- d_arg = self.get_target_filename_for_linking(d)
+ d_arg = '-L' + d_arg
args.append(d_arg)
return args