aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2018-05-25 11:48:37 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2018-05-25 11:48:37 +0200
commitd69e09acb570030a56566739569867139f5d1f4b (patch)
tree94f21ae804595ce134a107c8f185d89747d48967
parent5e2c26176cf48b65103251186a2bf321eda069a9 (diff)
Change default install filter to only accept prerequisites from amalgamation
-rw-r--r--build2/cc/install-rule.cxx2
-rw-r--r--build2/cc/pkgconfig.cxx19
-rw-r--r--build2/install/rule.cxx36
-rw-r--r--build2/install/rule.hxx3
-rw-r--r--build2/install/utility.hxx10
5 files changed, 47 insertions, 23 deletions
diff --git a/build2/cc/install-rule.cxx b/build2/cc/install-rule.cxx
index eda6ba0..a7e05b0 100644
--- a/build2/cc/install-rule.cxx
+++ b/build2/cc/install-rule.cxx
@@ -57,6 +57,8 @@ namespace build2
if (const libx* l = pt->is_a<libx> ())
pt = &link_member (*l, a, link_info (t.base_scope (), ot));
+ // Note: not redundant since we are returning a member.
+ //
if ((st && pt->is_a<libs> ()) || (at && pt->is_a<liba> ()))
return pt->in (t.weak_scope ()) ? pt : nullptr;
diff --git a/build2/cc/pkgconfig.cxx b/build2/cc/pkgconfig.cxx
index ce73efd..5ace6ec 100644
--- a/build2/cc/pkgconfig.cxx
+++ b/build2/cc/pkgconfig.cxx
@@ -1125,6 +1125,14 @@ namespace build2
assert (t != nullptr);
const path& p (t->path ());
+ auto_rmfile arm (p);
+
+ // By default we assume things go into install.{include, lib}.
+ //
+ using install::resolve_dir;
+
+ dir_path idir (resolve_dir (l, cast<dir_path> (l["install.include"])));
+ dir_path ldir (resolve_dir (l, cast<dir_path> (l["install.lib"])));
if (verb >= 2)
text << "cat >" << p;
@@ -1132,7 +1140,6 @@ namespace build2
try
{
ofdstream os (p);
- auto_rmfile arm (p);
{
const string& n (cast<string> (rs.vars[var_project]));
@@ -1225,19 +1232,13 @@ namespace build2
os << " -l" << n;
};
- // By default we assume things go into install.{include, lib}.
- //
// @@ TODO: support whole archive?
//
- using install::resolve_dir;
-
- dir_path id (resolve_dir (l, cast<dir_path> (l["install.include"])));
- dir_path ld (resolve_dir (l, cast<dir_path> (l["install.lib"])));
// Cflags.
//
os << "Cflags:";
- os << " -I" << escape (id.string ());
+ os << " -I" << escape (idir.string ());
save_poptions (c_export_poptions);
save_poptions (x_export_poptions);
os << endl;
@@ -1256,7 +1257,7 @@ namespace build2
// Libs.private split.
//
os << "Libs:";
- os << " -L" << escape (ld.string ());
+ os << " -L" << escape (ldir.string ());
// Now process ourselves as if we were being linked to something (so
// pretty similar to link_rule::append_libraries()).
diff --git a/build2/install/rule.cxx b/build2/install/rule.cxx
index 5184399..df25021 100644
--- a/build2/install/rule.cxx
+++ b/build2/install/rule.cxx
@@ -62,7 +62,8 @@ namespace build2
const target* alias_rule::
filter (action, const target& t, const prerequisite& p) const
{
- return &search (t, p);
+ const target& pt (search (t, p));
+ return pt.in (t.weak_scope ()) ? &pt : nullptr;
}
recipe alias_rule::
@@ -420,6 +421,7 @@ namespace build2
resolve (const scope& s,
const target* t,
dir_path d,
+ bool fail_unknown = true,
const string* var = nullptr)
{
install_dirs rs;
@@ -443,13 +445,25 @@ namespace build2
fail << "empty installation directory for name " << sn <<
info << "did you specified empty config." << var << "?";
- rs = resolve (s, t, *dn, &var);
+ rs = resolve (s, t, *dn, fail_unknown, &var);
+
+ if (rs.empty ())
+ {
+ assert (!fail_unknown);
+ return rs; // Empty.
+ }
+
d = rs.back ().dir / dir_path (++d.begin (), d.end ());
rs.emplace_back (move (d.normalize ()), rs.back ());
}
else
- fail << "unknown installation directory name '" << sn << "'" <<
- info << "did you forget to specify config." << var << "?";
+ {
+ if (fail_unknown)
+ fail << "unknown installation directory name '" << sn << "'" <<
+ info << "did you forget to specify config." << var << "?";
+
+ return rs; // Empty.
+ }
}
install_dir* r (&rs.back ());
@@ -495,21 +509,23 @@ namespace build2
}
static inline install_dirs
- resolve (const target& t, dir_path d, const string* var = nullptr)
+ resolve (const target& t, dir_path d, bool fail_unknown = true)
{
- return resolve (t.base_scope (), &t, d, var);
+ return resolve (t.base_scope (), &t, d, fail_unknown);
}
dir_path
- resolve_dir (const target& t, dir_path d)
+ resolve_dir (const target& t, dir_path d, bool fail_unknown)
{
- return move (resolve (t, move (d)).back ().dir);
+ install_dirs r (resolve (t, move (d), fail_unknown));
+ return r.empty () ? dir_path () : move (r.back ().dir);
}
dir_path
- resolve_dir (const scope& s, dir_path d)
+ resolve_dir (const scope& s, dir_path d, bool fail_unknown)
{
- return move (resolve (s, nullptr, move (d)).back ().dir);
+ install_dirs r (resolve (s, nullptr, move (d), fail_unknown));
+ return r.empty () ? dir_path () : move (r.back ().dir);
}
path
diff --git a/build2/install/rule.hxx b/build2/install/rule.hxx
index 914ffdc..32c6889 100644
--- a/build2/install/rule.hxx
+++ b/build2/install/rule.hxx
@@ -24,7 +24,8 @@ namespace build2
match (action, target&, const string&) const override;
// Return NULL if this prerequisite should be ignored and pointer to its
- // target otherwise. The default implementation accepts all prerequsites.
+ // target otherwise. The default implementation accepts prerequsites
+ // from the target's (weak) amalgamation.
//
// The prerequisite it passed as an iterator allowing the filter to
// "see" inside groups.
diff --git a/build2/install/utility.hxx b/build2/install/utility.hxx
index 61ac6a7..cb0ae7c 100644
--- a/build2/install/utility.hxx
+++ b/build2/install/utility.hxx
@@ -54,13 +54,17 @@ namespace build2
}
// Resolve relative installation directory path (e.g., include/libfoo) to
- // its absolute directory path (e.g., /usr/include/libfoo).
+ // its absolute directory path (e.g., /usr/include/libfoo). If the
+ // resolution encountered an unknown directory, issue diagnostics and fail
+ // unless fail_unknown is false, in which case return empty directory.
+ //
+ // Note: implemented in rule.cxx.
//
dir_path
- resolve_dir (const target&, dir_path); // rule.cxx
+ resolve_dir (const target&, dir_path, bool fail_unknown = true);
dir_path
- resolve_dir (const scope&, dir_path); // rule.cxx
+ resolve_dir (const scope&, dir_path, bool fail_unknown = true);
// Resolve file installation path returning empty path if not installable.
//