diff options
Diffstat (limited to 'mesonbuild')
-rw-r--r-- | mesonbuild/backend/backends.py | 4 | ||||
-rw-r--r-- | mesonbuild/build.py | 19 |
2 files changed, 22 insertions, 1 deletions
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py index be181a8..b62438e 100644 --- a/mesonbuild/backend/backends.py +++ b/mesonbuild/backend/backends.py @@ -211,6 +211,10 @@ 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()) + elif isinstance(target, build.CustomTarget): + if not target.is_linkable_target(): + raise MesonException('Tried to link against custom target "%s", which is not linkable.' % target.name) + return os.path.join(self.get_target_dir(target), target.get_filename()) elif isinstance(target, build.Executable): if target.import_filename: return os.path.join(self.get_target_dir(target), target.get_import_filename()) 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" |