diff options
author | TheQwertiest <qwertiest@mail.ru> | 2019-03-27 19:18:39 +0300 |
---|---|---|
committer | TheQwertiest <qwertiest@mail.ru> | 2019-04-29 16:07:50 +0300 |
commit | 8c9a25456d7605bdd8a71c9d7cf1cd71fe308587 (patch) | |
tree | 83091566b34f772d42f58b8afbd29670a0cc8255 /mesonbuild/build.py | |
parent | ccc4ce28cc9077d77a0bc9e72b1177eba1be7186 (diff) | |
download | meson-8c9a25456d7605bdd8a71c9d7cf1cd71fe308587.zip meson-8c9a25456d7605bdd8a71c9d7cf1cd71fe308587.tar.gz meson-8c9a25456d7605bdd8a71c9d7cf1cd71fe308587.tar.bz2 |
Added custom_target[i] support for link_with and link_whole
Diffstat (limited to 'mesonbuild/build.py')
-rw-r--r-- | mesonbuild/build.py | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/mesonbuild/build.py b/mesonbuild/build.py index 5248d97..a0a6d7c 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -576,7 +576,7 @@ class BuildTarget(Target): if self.link_targets or self.link_whole_targets: extra = set() for t in itertools.chain(self.link_targets, self.link_whole_targets): - if isinstance(t, CustomTarget): + if isinstance(t, CustomTarget) or isinstance(t, CustomTargetIndex): continue # We can't know anything about these. for name, compiler in t.compilers.items(): if name in clink_langs: @@ -1066,7 +1066,7 @@ You probably should put it in link_with instead.''') def link(self, target): for t in listify(target, unholder=True): - if not isinstance(t, Target): + if not isinstance(t, Target) and not isinstance(t, CustomTargetIndex): raise InvalidArguments('{!r} is not a target.'.format(t)) if not t.is_linkable_target(): raise InvalidArguments('Link target {!r} is not linkable.'.format(t)) @@ -1074,13 +1074,13 @@ You probably should put it in link_with instead.''') msg = "Can't link non-PIC static library {!r} into shared library {!r}. ".format(t.name, self.name) msg += "Use the 'pic' option to static_library to build with PIC." raise InvalidArguments(msg) - if not isinstance(t, CustomTarget) and self.is_cross != t.is_cross: + if not isinstance(t, CustomTarget) and not isinstance(t, CustomTargetIndex) and self.is_cross != t.is_cross: raise InvalidArguments('Tried to mix cross built and native libraries in target {!r}'.format(self.name)) self.link_targets.append(t) def link_whole(self, target): for t in listify(target, unholder=True): - if isinstance(t, CustomTarget): + if isinstance(t, CustomTarget) or isinstance(t, CustomTargetIndex): if not t.is_linkable_target(): raise InvalidArguments('Custom target {!r} is not linkable.'.format(t)) if not t.get_filename().endswith('.a'): @@ -1091,7 +1091,7 @@ You probably should put it in link_with instead.''') msg = "Can't link non-PIC static library {!r} into shared library {!r}. ".format(t.name, self.name) msg += "Use the 'pic' option to static_library to build with PIC." raise InvalidArguments(msg) - if not isinstance(t, CustomTarget) and self.is_cross != t.is_cross: + if not isinstance(t, CustomTarget) and not isinstance(t, CustomTargetIndex) and self.is_cross != t.is_cross: raise InvalidArguments('Tried to mix cross built and native libraries in target {!r}'.format(self.name)) self.link_whole_targets.append(t) @@ -1168,7 +1168,7 @@ You probably should put it in link_with instead.''') # Check if any of the internal libraries this target links to were # written in this language for link_target in itertools.chain(self.link_targets, self.link_whole_targets): - if isinstance(link_target, CustomTarget): + if isinstance(link_target, CustomTarget) or isinstance(link_target, CustomTargetIndex): continue for language in link_target.compilers: if language not in langs: @@ -2259,6 +2259,26 @@ class CustomTargetIndex: def get_subdir(self): return self.target.get_subdir() + def get_filename(self): + return self.output + + def get_id(self): + return self.target.get_id() + + def get_all_link_deps(self): + return [] + + def get_link_deps_mapping(self, prefix, environment): + return self.target.get_link_deps_mapping(prefix, environment) + + def get_link_dep_subdirs(self): + return self.target.get_link_dep_subdirs() + + def is_linkable_target(self): + suf = os.path.splitext(self.output)[-1] + if suf == '.a' or suf == '.dll' or suf == '.lib' or suf == '.so': + return True + class ConfigureFile: def __init__(self, subdir, sourcename, targetname, configuration_data): |