aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/cc
diff options
context:
space:
mode:
Diffstat (limited to 'libbuild2/cc')
-rw-r--r--libbuild2/cc/common.cxx7
-rw-r--r--libbuild2/cc/common.hxx2
-rw-r--r--libbuild2/cc/compile-rule.cxx1
-rw-r--r--libbuild2/cc/functions.cxx2
-rw-r--r--libbuild2/cc/install-rule.cxx5
-rw-r--r--libbuild2/cc/link-rule.cxx26
-rw-r--r--libbuild2/cc/link-rule.hxx2
-rw-r--r--libbuild2/cc/pkgconfig.cxx1
-rw-r--r--libbuild2/cc/windows-rpath.cxx2
9 files changed, 38 insertions, 10 deletions
diff --git a/libbuild2/cc/common.cxx b/libbuild2/cc/common.cxx
index b3a5724..09a1752 100644
--- a/libbuild2/cc/common.cxx
+++ b/libbuild2/cc/common.cxx
@@ -92,6 +92,7 @@ namespace build2
const small_vector<reference_wrapper<
const string>, 2>&, // Library "name".
lflags, // Link flags.
+ const string* type, // cc.type
bool sys)>& proc_lib, // System library?
const function<bool (const target&,
const string& type, // cc.type
@@ -272,7 +273,7 @@ namespace build2
: !p.empty () && sys (top_sysd, p.string ()));
proc_lib_name = {p.string ()};
- if (!proc_lib (&chain->back (), proc_lib_name, lf, s))
+ if (!proc_lib (&chain->back (), proc_lib_name, lf, t, s))
break;
}
@@ -459,7 +460,7 @@ namespace build2
proc_lib_name.push_back (i->value);
}
- proc_lib (nullptr, proc_lib_name, 0, r.second);
+ proc_lib (nullptr, proc_lib_name, 0, nullptr, r.second);
continue;
}
}
@@ -552,7 +553,7 @@ namespace build2
proc_lib_name.push_back (*i);
}
- proc_lib (nullptr, proc_lib_name, 0, r.second);
+ proc_lib (nullptr, proc_lib_name, 0, nullptr, r.second);
}
};
diff --git a/libbuild2/cc/common.hxx b/libbuild2/cc/common.hxx
index 7d8424f..78442f8 100644
--- a/libbuild2/cc/common.hxx
+++ b/libbuild2/cc/common.hxx
@@ -316,7 +316,7 @@ namespace build2
const function<bool (const target&, bool)>&,
const function<bool (const target* const*,
const small_vector<reference_wrapper<const string>, 2>&,
- lflags, bool)>&,
+ lflags, const string*, bool)>&,
const function<bool (const target&, const string&, bool, bool)>&,
bool = false,
library_cache* = nullptr,
diff --git a/libbuild2/cc/compile-rule.cxx b/libbuild2/cc/compile-rule.cxx
index 053cca6..93f05f1 100644
--- a/libbuild2/cc/compile-rule.cxx
+++ b/libbuild2/cc/compile-rule.cxx
@@ -6459,6 +6459,7 @@ namespace build2
const target* const* lc,
const small_vector<reference_wrapper<const string>, 2>&,
lflags,
+ const string*,
bool)
{
// Prune any further traversal if we already found it.
diff --git a/libbuild2/cc/functions.cxx b/libbuild2/cc/functions.cxx
index 6d54c49..cafb7f0 100644
--- a/libbuild2/cc/functions.cxx
+++ b/libbuild2/cc/functions.cxx
@@ -326,7 +326,7 @@ namespace build2
m.append_libraries (
*static_cast<appended_libraries*> (ls), r,
nullptr /* sha256 */, nullptr /* update */, timestamp_unknown,
- bs, a, l, la, lf, li, self, rel);
+ bs, a, l, la, lf, li, nullopt /* for_install */, self, rel);
}});
// $<module>.lib_rpaths(<lib-targets>, <otype> [, <link> [, <self>]])
diff --git a/libbuild2/cc/install-rule.cxx b/libbuild2/cc/install-rule.cxx
index 59acaf7..560b8a7 100644
--- a/libbuild2/cc/install-rule.cxx
+++ b/libbuild2/cc/install-rule.cxx
@@ -179,8 +179,11 @@ namespace build2
if (md.for_install)
{
+ // Note: see also append_libraries() for the other half.
+ //
if (!*md.for_install)
- fail << "target " << t << " already updated but not for install";
+ fail << "incompatible " << t << " build" <<
+ info << "target already built not for install";
}
else
md.for_install = true;
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<bool> 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<bool> 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<reference_wrapper<const string>, 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<libux> ())
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<link_rule::match_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<reference_wrapper<const string>, 2>& ns,
lflags,
+ const string*,
bool sys)
{
const file* l (lc != nullptr ? &(*lc)->as<file> () : 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
diff --git a/libbuild2/cc/link-rule.hxx b/libbuild2/cc/link-rule.hxx
index 655d36a..c6d06d2 100644
--- a/libbuild2/cc/link-rule.hxx
+++ b/libbuild2/cc/link-rule.hxx
@@ -194,7 +194,7 @@ namespace build2
sha256*, bool*, timestamp,
const scope&, action,
const file&, bool, lflags, linfo,
- bool = true, bool = true,
+ optional<bool>, bool = true, bool = true,
library_cache* = nullptr) const;
using rpathed_libraries = small_vector<const file*, 256>;
diff --git a/libbuild2/cc/pkgconfig.cxx b/libbuild2/cc/pkgconfig.cxx
index 7b4f86d..3e74452 100644
--- a/libbuild2/cc/pkgconfig.cxx
+++ b/libbuild2/cc/pkgconfig.cxx
@@ -1666,6 +1666,7 @@ namespace build2
const target* const* lc,
const small_vector<reference_wrapper<const string>, 2>& ns,
lflags,
+ const string*,
bool)
{
const file* l (lc != nullptr ? &(*lc)->as<file> () : nullptr);
diff --git a/libbuild2/cc/windows-rpath.cxx b/libbuild2/cc/windows-rpath.cxx
index 0fbc775..2d90ace 100644
--- a/libbuild2/cc/windows-rpath.cxx
+++ b/libbuild2/cc/windows-rpath.cxx
@@ -66,6 +66,7 @@ namespace build2
const target* const* lc,
const small_vector<reference_wrapper<const string>, 2>& ns,
lflags,
+ const string*,
bool sys)
{
const file* l (lc != nullptr ? &(*lc)->as<file> () : nullptr);
@@ -172,6 +173,7 @@ namespace build2
const target* const* lc,
const small_vector<reference_wrapper<const string>, 2>& ns,
lflags,
+ const string*,
bool sys)
{
const file* l (lc != nullptr ? &(*lc)->as<file> () : nullptr);