diff options
Diffstat (limited to 'mesonbuild')
-rw-r--r-- | mesonbuild/build.py | 35 | ||||
-rw-r--r-- | mesonbuild/mtest.py | 20 |
2 files changed, 42 insertions, 13 deletions
diff --git a/mesonbuild/build.py b/mesonbuild/build.py index 8d2a22f..bc1f54a 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -1130,10 +1130,16 @@ You probably should put it in link_with instead.''') def link(self, target): for t in unholder(listify(target)): - if isinstance(self, StaticLibrary) and self.need_install and t.is_internal(): - # When we're a static library and we link_with to an - # internal/convenience library, promote to link_whole. - return self.link_whole(t) + if isinstance(self, StaticLibrary) and self.need_install: + if isinstance(t, (CustomTarget, CustomTargetIndex)): + if not t.should_install(): + mlog.warning('Try to link an installed static library target {} with a custom target ' + 'that is not installed, this might cause problems when you try to use ' + 'this static library'.format(self.name)) + elif t.is_internal(): + # When we're a static library and we link_with to an + # internal/convenience library, promote to link_whole. + return self.link_whole(t) if not isinstance(t, (Target, CustomTargetIndex)): raise InvalidArguments('{!r} is not a target.'.format(t)) if not t.is_linkable_target(): @@ -2274,6 +2280,18 @@ class CustomTarget(Target): def get_all_link_deps(self): return [] + def is_internal(self) -> bool: + if not self.should_install(): + return True + for out in self.get_outputs(): + # Can't check if this is a static library, so try to guess + if not out.endswith(('.a', '.lib')): + return False + return True + + def extract_all_objects_recurse(self): + return self.get_outputs() + def type_suffix(self): return "@cus" @@ -2419,6 +2437,15 @@ class CustomTargetIndex: if suf == '.a' or suf == '.dll' or suf == '.lib' or suf == '.so': return True + def should_install(self) -> bool: + return self.target.should_install() + + def is_internal(self) -> bool: + return self.target.is_internal() + + def extract_all_objects_recurse(self): + return self.target.extract_all_objects_recurse() + class ConfigureFile: def __init__(self, subdir, sourcename, targetname, configuration_data): diff --git a/mesonbuild/mtest.py b/mesonbuild/mtest.py index ee1d412..caf4039 100644 --- a/mesonbuild/mtest.py +++ b/mesonbuild/mtest.py @@ -917,15 +917,17 @@ class TestHarness: if result.res is TestResult.FAIL: result_str += ' ' + returncode_to_status(result.returncode) if not self.options.quiet or result.res not in ok_statuses: - if result.res not in ok_statuses and mlog.colorize_console(): - if result.res in bad_statuses: - self.collected_failures.append(result_str) - decorator = mlog.red - elif result.res is TestResult.SKIP: - decorator = mlog.yellow - else: - sys.exit('Unreachable code was ... well ... reached.') - print(decorator(result_str).get_text(True)) + if result.res not in ok_statuses: + self.collected_failures.append(result_str) + if mlog.colorize_console(): + if result.res in bad_statuses: + self.collected_failures.append(result_str) + decorator = mlog.red + elif result.res is TestResult.SKIP: + decorator = mlog.yellow + else: + sys.exit('Unreachable code was ... well ... reached.') + print(decorator(result_str).get_text(True)) else: print(result_str) result_str += "\n\n" + result.get_log() |