aboutsummaryrefslogtreecommitdiff
path: root/build/cli/rule.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-07-01 16:45:34 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-07-01 16:45:34 +0200
commite4c4fec8c9097722ee5ee94f2ce5ad0313ed8d7b (patch)
treee8de68957fc5cd00bb7b0b3199ca8a9abba4f678 /build/cli/rule.cxx
parentf7e9830c0c413f05737002dcc8d06e73cb379980 (diff)
Clean up group state, mtime design
Diffstat (limited to 'build/cli/rule.cxx')
-rw-r--r--build/cli/rule.cxx106
1 files changed, 44 insertions, 62 deletions
diff --git a/build/cli/rule.cxx b/build/cli/rule.cxx
index 6377b29..3bcd074 100644
--- a/build/cli/rule.cxx
+++ b/build/cli/rule.cxx
@@ -210,78 +210,65 @@ namespace build
// Execute our prerequsites and check if we are out of date.
//
- cli* s (execute_prerequisites<cli> (a, t, t.h ()->mtime ()));
-
- target_state ts;
+ cli* s (execute_prerequisites<cli> (a, t, t.mtime ()));
if (s == nullptr)
- ts = target_state::unchanged;
- else
- {
- // Translate source path to relative (to working directory). This
- // results in easier to read diagnostics.
- //
- path relo (relative (t.dir));
- path rels (relative (s->path ()));
+ return target_state::unchanged;
- scope& rs (t.root_scope ());
- const string& cli (rs["config.cli"].as<const string&> ());
-
- vector<const char*> args {cli.c_str ()};
+ // Translate source path to relative (to working directory). This
+ // results in easier to read diagnostics.
+ //
+ path relo (relative (t.dir));
+ path rels (relative (s->path ()));
- // See if we need to pass any --?xx-suffix options.
- //
- append_extension (args, *t.h (), "--hxx-suffix", "hxx");
- append_extension (args, *t.c (), "--cxx-suffix", "cxx");
- if (t.i () != nullptr)
- append_extension (args, *t.i (), "--ixx-suffix", "ixx");
+ scope& rs (t.root_scope ());
+ const string& cli (rs["config.cli"].as<const string&> ());
- append_options (args, t, "cli.options");
+ vector<const char*> args {cli.c_str ()};
- if (!relo.empty ())
- {
- args.push_back ("-o");
- args.push_back (relo.string ().c_str ());
- }
+ // See if we need to pass any --?xx-suffix options.
+ //
+ append_extension (args, *t.h (), "--hxx-suffix", "hxx");
+ append_extension (args, *t.c (), "--cxx-suffix", "cxx");
+ if (t.i () != nullptr)
+ append_extension (args, *t.i (), "--ixx-suffix", "ixx");
- args.push_back (rels.string ().c_str ());
- args.push_back (nullptr);
+ append_options (args, t, "cli.options");
- if (verb)
- print_process (args);
- else
- text << "cli " << *s;
+ if (!relo.empty ())
+ {
+ args.push_back ("-o");
+ args.push_back (relo.string ().c_str ());
+ }
- try
- {
- process pr (args.data ());
+ args.push_back (rels.string ().c_str ());
+ args.push_back (nullptr);
- if (!pr.wait ())
- throw failed ();
+ if (verb)
+ print_process (args);
+ else
+ text << "cli " << *s;
- timestamp s (system_clock::now ());
+ try
+ {
+ process pr (args.data ());
- // Update member timestamps.
- //
- t.h ()->mtime (s);
- t.c ()->mtime (s);
- if (t.i () != nullptr)
- t.i ()->mtime (s);
+ if (!pr.wait ())
+ throw failed ();
- ts = target_state::changed;
- }
- catch (const process_error& e)
- {
- error << "unable to execute " << args[0] << ": " << e.what ();
+ t.mtime (system_clock::now ());
+ }
+ catch (const process_error& e)
+ {
+ error << "unable to execute " << args[0] << ": " << e.what ();
- if (e.child ())
- exit (1);
+ if (e.child ())
+ exit (1);
- throw failed ();
- }
+ throw failed ();
}
- return ts;
+ return target_state::changed;
}
target_state compile::
@@ -297,16 +284,11 @@ namespace build
bool r (false);
if (t.i () != nullptr)
- {
r = rmfile (t.i ()->path (), *t.i ()) || r;
- t.i ()->mtime (timestamp_nonexistent);
- }
-
r = rmfile (t.c ()->path (), *t.c ()) || r;
- t.c ()->mtime (timestamp_nonexistent);
-
r = rmfile (t.h ()->path (), *t.h ()) || r;
- t.h ()->mtime (timestamp_nonexistent);
+
+ t.mtime (timestamp_nonexistent);
// Clean prerequisites.
//