From c51ccc69ed4039fac8ebfbd7c2fcaf0abb8341d0 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Fri, 19 May 2017 19:39:21 +0300 Subject: Allow to enforce rebuild for building state --- libbrep/build.cxx | 26 +++++++++++++++++++++++++- libbrep/build.hxx | 28 ++++++++++++++++++++++++---- libbrep/build.xml | 2 +- 3 files changed, 50 insertions(+), 6 deletions(-) (limited to 'libbrep') diff --git a/libbrep/build.cxx b/libbrep/build.cxx index ece2fd7..2391165 100644 --- a/libbrep/build.cxx +++ b/libbrep/build.cxx @@ -30,6 +30,30 @@ namespace brep else throw invalid_argument ("invalid build state '" + s + "'"); } + // force_state + // + string + to_string (force_state s) + { + switch (s) + { + case force_state::unforced: return "unforced"; + case force_state::forcing: return "forcing"; + case force_state::forced: return "forced"; + } + + return string (); // Should never reach. + } + + force_state + to_force_state (const string& s) + { + if (s == "unforced") return force_state::unforced; + else if (s == "forcing") return force_state::forcing; + else if (s == "forced") return force_state::forced; + else throw invalid_argument ("invalid force state '" + s + "'"); + } + // build // build:: @@ -46,7 +70,7 @@ namespace brep toolchain_version (move (tvr)), state (build_state::building), timestamp (timestamp_type::clock::now ()), - forced (false), + force (force_state::unforced), machine (move (mnm)), machine_summary (move (msm)), target (move (trg)) diff --git a/libbrep/build.hxx b/libbrep/build.hxx index 9258bb3..afa96ed 100644 --- a/libbrep/build.hxx +++ b/libbrep/build.hxx @@ -82,6 +82,28 @@ namespace brep to(to_string (?)) \ from(brep::to_build_state (?)) + // force_state + // + enum class force_state: std::uint8_t + { + unforced, + forcing, // Rebuild is forced while being in the building state. + forced // Rebuild is forced while being in the built state. + }; + + string + to_string (force_state); + + force_state + to_force_state (const string&); // May throw invalid_argument. + + inline ostream& + operator<< (ostream& os, force_state s) {return os << to_string (s);} + + #pragma db map type(force_state) as(string) \ + to(to_string (?)) \ + from(brep::to_force_state (?)) + // result_status // using bbot::result_status; @@ -118,7 +140,7 @@ namespace brep using timestamp_type = brep::timestamp; // Create the build object with the building state, non-existent status, - // the timestamp set to now and the forced flag set to false. + // the timestamp set to now and the force state set to unforced. // build (string package_name, version package_version, string configuration, @@ -140,9 +162,7 @@ namespace brep // timestamp_type timestamp; - // True if the package rebuild has been forced. - // - bool forced; + force_state force; // Must present for the built state, may present for the building state. // diff --git a/libbrep/build.xml b/libbrep/build.xml index 72cbd5f..7466c97 100644 --- a/libbrep/build.xml +++ b/libbrep/build.xml @@ -18,7 +18,7 @@ - + -- cgit v1.1