From e81f48db1600056942e30e2567af73d6d7678188 Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Sun, 17 Mar 2019 22:34:19 +0200 Subject: Can link against custom targets. Closes #4908. --- mesonbuild/build.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'mesonbuild/build.py') diff --git a/mesonbuild/build.py b/mesonbuild/build.py index 20f0cdb..eb8e60c 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -567,6 +567,8 @@ 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): + continue # We can't know anything about these. for name, compiler in t.compilers.items(): if name in clink_langs: extra.add((name, compiler)) @@ -1062,7 +1064,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 self.is_cross != t.is_cross: + if not isinstance(t, CustomTarget) 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) @@ -1149,6 +1151,8 @@ 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): + continue for language in link_target.compilers: if language not in langs: langs.append(language) @@ -2090,6 +2094,19 @@ class CustomTarget(Target): raise InvalidArguments('Substitution in depfile for custom_target that does not have an input file.') return self.depfile + def is_linkable_target(self): + if len(self.outputs) != 1: + return False + suf = os.path.splitext(self.outputs[0])[-1] + if suf == '.a' or suf == '.dll' or suf == '.lib' or suf == '.so': + return True + + def get_link_dep_subdirs(self): + return OrderedSet() + + def get_all_link_deps(self): + return [] + def type_suffix(self): return "@cus" -- cgit v1.1