aboutsummaryrefslogtreecommitdiff
path: root/build2/install
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 /build2/install
parent5e2c26176cf48b65103251186a2bf321eda069a9 (diff)
Change default install filter to only accept prerequisites from amalgamation
Diffstat (limited to 'build2/install')
-rw-r--r--build2/install/rule.cxx36
-rw-r--r--build2/install/rule.hxx3
-rw-r--r--build2/install/utility.hxx10
3 files changed, 35 insertions, 14 deletions
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.
//