aboutsummaryrefslogtreecommitdiff
path: root/build/cli
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
parentf7e9830c0c413f05737002dcc8d06e73cb379980 (diff)
Clean up group state, mtime design
Diffstat (limited to 'build/cli')
-rw-r--r--build/cli/rule.cxx106
-rw-r--r--build/cli/target7
-rw-r--r--build/cli/target.cxx14
3 files changed, 62 insertions, 65 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.
//
diff --git a/build/cli/target b/build/cli/target
index e72d4e0..d733668 100644
--- a/build/cli/target
+++ b/build/cli/target
@@ -23,10 +23,10 @@ namespace build
static const target_type static_type;
};
- class cli_cxx: public target
+ class cli_cxx: public mtime_target
{
public:
- using target::target;
+ using mtime_target::mtime_target;
target* m[3] {nullptr, nullptr, nullptr};
@@ -41,6 +41,9 @@ namespace build
virtual group_view
group_members (action) const;
+ virtual timestamp
+ load_mtime () const;
+
public:
virtual const target_type& type () const {return static_type;}
static const target_type static_type;
diff --git a/build/cli/target.cxx b/build/cli/target.cxx
index aded1ff..2f8b54c 100644
--- a/build/cli/target.cxx
+++ b/build/cli/target.cxx
@@ -4,7 +4,10 @@
#include <build/cli/target>
+#include <butl/filesystem>
+
using namespace std;
+using namespace butl;
namespace build
{
@@ -34,11 +37,20 @@ namespace build
: group_view {nullptr, 0};
}
+ timestamp cli_cxx::
+ load_mtime () const
+ {
+ // The rule has been matched which means the members should
+ // be resolved and paths assigned.
+ //
+ return file_mtime (h ()->path ());
+ }
+
const target_type cli_cxx::static_type
{
typeid (cli_cxx),
"cli.cxx",
- &target::static_type,
+ &mtime_target::static_type,
&target_factory<cli_cxx>,
nullptr,
&search_target,