aboutsummaryrefslogtreecommitdiff
path: root/build2/cc/windows-manifest.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2019-04-05 09:41:18 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2019-04-08 12:51:00 +0200
commit01d848149c22a69a62eada5fedc2406c54d95ba8 (patch)
tree66a3b59619f32f7f7244200f810f4d4cc9115ca5 /build2/cc/windows-manifest.cxx
parent3392226a2248b5cd93a899afb986917ce9e7ad74 (diff)
Support for --dry-run|-n mode, perform update part
Diffstat (limited to 'build2/cc/windows-manifest.cxx')
-rw-r--r--build2/cc/windows-manifest.cxx39
1 files changed, 24 insertions, 15 deletions
diff --git a/build2/cc/windows-manifest.cxx b/build2/cc/windows-manifest.cxx
index 268e8c7..f890ad5 100644
--- a/build2/cc/windows-manifest.cxx
+++ b/build2/cc/windows-manifest.cxx
@@ -37,9 +37,9 @@ namespace build2
// Generate a Windows manifest and if necessary create/update the manifest
// file corresponding to the exe{} target. Return the manifest file path
- // as well as whether it was changed.
+ // and its timestamp if unchanged or timestamp_nonexistent otherwise.
//
- pair<path, bool> link_rule::
+ pair<path, timestamp> link_rule::
windows_manifest (const file& t, bool rpath_assembly) const
{
tracer trace (x, "link_rule::windows_manifest");
@@ -100,13 +100,15 @@ namespace build2
//
path mf (t.path () + ".manifest");
- if (exists (mf))
+ timestamp mt (mtime (mf));
+
+ if (mt != timestamp_nonexistent)
{
try
{
- ifdstream ifs (mf);
- if (ifs.read_text () == m)
- return make_pair (move (mf), false);
+ ifdstream is (mf);
+ if (is.read_text () == m)
+ return make_pair (move (mf), mt);
}
catch (const io_error&)
{
@@ -117,18 +119,25 @@ namespace build2
if (verb >= 3)
text << "cat >" << mf;
- try
- {
- ofdstream ofs (mf);
- ofs << m;
- ofs.close ();
- }
- catch (const io_error& e)
+ if (!dry_run)
{
- fail << "unable to write to " << mf << ": " << e;
+ auto_rmfile rm (mf);
+
+ try
+ {
+ ofdstream os (mf);
+ os << m;
+ os.close ();
+ rm.cancel ();
+
+ }
+ catch (const io_error& e)
+ {
+ fail << "unable to write to " << mf << ": " << e;
+ }
}
- return make_pair (move (mf), true);
+ return make_pair (move (mf), timestamp_nonexistent);
}
}
}