From 7ee735c0a99b29979594920262db13b4939b3c2c Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 7 Oct 2021 08:36:29 +0200 Subject: Verify libraries and targets they are linked to a for-install-compatible --- libbuild2/cc/link-rule.cxx | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'libbuild2/cc/link-rule.cxx') diff --git a/libbuild2/cc/link-rule.cxx b/libbuild2/cc/link-rule.cxx index d2ffb04..2d0fc81 100644 --- a/libbuild2/cc/link-rule.cxx +++ b/libbuild2/cc/link-rule.cxx @@ -1770,7 +1770,7 @@ namespace build2 sha256* cs, bool* update, timestamp mt, const scope& bs, action a, const file& l, bool la, lflags lf, linfo li, - bool self, bool rel, + optional for_install, bool self, bool rel, library_cache* lib_cache) const { struct data @@ -1787,12 +1787,13 @@ namespace build2 const file& l; action a; linfo li; + optional for_install; bool rel; compile_target_types tts; } d {ls, args, cs, cs != nullptr ? &bs.root_scope ()->out_path () : nullptr, update, mt, - l, a, li, rel, compile_types (li.type)}; + l, a, li, for_install, rel, compile_types (li.type)}; auto imp = [] (const target&, bool la) { @@ -1803,6 +1804,7 @@ namespace build2 const target* const* lc, const small_vector, 2>& ns, lflags f, + const string* type, // cc.type bool) { // Note: see also make_header_sidebuild(). @@ -1877,6 +1879,22 @@ namespace build2 if (!lc[i]->is_a ()) goto done; } + // If requested, verify the target and the library are both for + // install or both not. We can only do this if the library is build + // by our link_rule. + // + else if (d.for_install && type != nullptr && *type != "cc") + { + auto& md (l->data ()); + assert (md.for_install); // Must have been executed. + + // The user will get the target name from the context info. + // + if (*md.for_install != *d.for_install) + fail << "incompatible " << *l << " build" << + info << "library is built " << (*md.for_install ? "" : "not ") + << "for install"; + } if (d.li.type == otype::a) { @@ -2096,6 +2114,7 @@ namespace build2 const target* const* lc, const small_vector, 2>& ns, lflags, + const string*, bool sys) { const file* l (lc != nullptr ? &(*lc)->as () : nullptr); @@ -2937,7 +2956,8 @@ namespace build2 { append_libraries (als, sargs, &cs, &update, mt, - bs, a, *f, la, p.data, li, true, true, &lc); + bs, a, *f, la, p.data, li, + for_install, true, true, &lc); f = nullptr; // Timestamp checked by hash_libraries(). } else -- cgit v1.1