diff options
-rw-r--r-- | mesonbuild/backend/backends.py | 4 | ||||
-rw-r--r-- | mesonbuild/backend/vs2010backend.py | 10 | ||||
-rw-r--r-- | mesonbuild/build.py | 32 |
3 files changed, 37 insertions, 9 deletions
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py index 4a4f7f4..072c7fb 100644 --- a/mesonbuild/backend/backends.py +++ b/mesonbuild/backend/backends.py @@ -171,6 +171,8 @@ class Backend: mlog.warning('custom_target {!r} has more than one output! ' 'Using the first one.'.format(t.name)) filename = t.get_outputs()[0] + elif isinstance(t, build.CustomTargetIndex): + filename = t.get_outputs()[0] else: assert(isinstance(t, build.BuildTarget)) filename = t.get_filename() @@ -214,7 +216,7 @@ 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): + elif isinstance(target, build.CustomTarget) or isinstance(target, build.CustomTargetIndex): 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()) diff --git a/mesonbuild/backend/vs2010backend.py b/mesonbuild/backend/vs2010backend.py index d1bf1e5..da02f7a 100644 --- a/mesonbuild/backend/vs2010backend.py +++ b/mesonbuild/backend/vs2010backend.py @@ -249,9 +249,15 @@ class Vs2010Backend(backends.Backend): all_deps[d.get_id()] = d elif isinstance(target, build.BuildTarget): for ldep in target.link_targets: - all_deps[ldep.get_id()] = ldep + if isinstance(ldep, build.CustomTargetIndex): + all_deps[ldep.get_id()] = ldep.target + else: + all_deps[ldep.get_id()] = ldep for ldep in target.link_whole_targets: - all_deps[ldep.get_id()] = ldep + if isinstance(ldep, build.CustomTargetIndex): + all_deps[ldep.get_id()] = ldep.target + else: + all_deps[ldep.get_id()] = ldep for obj_id, objdep in self.get_obj_target_deps(target.objects): all_deps[obj_id] = objdep for gendep in target.get_generated_sources(): 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): |