aboutsummaryrefslogtreecommitdiff
path: root/build2/install/rule.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2018-05-19 11:16:00 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2018-05-19 12:14:25 +0200
commit4947e501153d457ce25a49d8cc3c82b4be307b1a (patch)
treeeb455b210ca4072e641ba5e46f2ce6fef3f25f67 /build2/install/rule.cxx
parentffaf9794efe344a6af27aaf3d69500bbf857559f (diff)
Add lower-level pre/post installation hooks to install::file_rule
Diffstat (limited to 'build2/install/rule.cxx')
-rw-r--r--build2/install/rule.cxx36
1 files changed, 32 insertions, 4 deletions
diff --git a/build2/install/rule.cxx b/build2/install/rule.cxx
index 18cbeae..7c13188 100644
--- a/build2/install/rule.cxx
+++ b/build2/install/rule.cxx
@@ -341,6 +341,18 @@ namespace build2
return false;
}
+ auto_rmfile file_rule::
+ install_pre (const file& t, const install_dir&) const
+ {
+ return auto_rmfile (t.path (), false /* active */);
+ }
+
+ bool file_rule::
+ install_post (const file& t, const install_dir& id, auto_rmfile&&) const
+ {
+ return install_extra (t, id);
+ }
+
struct install_dir
{
dir_path dir;
@@ -654,9 +666,10 @@ namespace build2
const install_dir& base,
const path& name,
const file& t,
+ const path& f,
bool verbose)
{
- path relf (relative (t.path ()));
+ path relf (relative (f));
dir_path chd (chroot_path (rs, base.dir));
@@ -775,10 +788,25 @@ namespace build2
if (auto l = t["install.mode"])
id.mode = &cast<string> (l);
- // Install the target and extras.
+ // Install the target.
+ //
+ auto_rmfile f (install_pre (t, id));
+
+ // If install_pre() returned a different file name, make sure we
+ // install it as the original.
//
- install_f (rs, id, n ? p.leaf () : path (), t, verbose);
- install_extra (t, id);
+ const path& tp (t.path ());
+ const path& fp (f.path);
+
+ install_f (
+ rs,
+ id,
+ n ? p.leaf () : fp.leaf () != tp.leaf () ? tp.leaf () : path (),
+ t,
+ f.path,
+ verbose);
+
+ install_post (t, id, move (f));
};
// First handle installable prerequisites.