aboutsummaryrefslogtreecommitdiff
path: root/build
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-06-18 11:55:27 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-06-18 11:55:27 +0200
commit5cb5b09b198932a0d3bd985fd52fd9fbcb1c2af5 (patch)
treecd4a22d2edba93c0afc01b638ab092ad4596e100 /build
parent6434d616da5d75577d142e20e0f9fa430bd625df (diff)
Move some utilities from build2 to libbutl
Diffstat (limited to 'build')
-rw-r--r--build/algorithm.cxx3
-rw-r--r--build/cxx/rule.cxx2
-rw-r--r--build/target16
-rw-r--r--build/utility54
4 files changed, 12 insertions, 63 deletions
diff --git a/build/algorithm.cxx b/build/algorithm.cxx
index e52d7f5..fe85c4e 100644
--- a/build/algorithm.cxx
+++ b/build/algorithm.cxx
@@ -9,6 +9,8 @@
#include <utility> // move
#include <cassert>
+#include <butl/utility> // reverse_iterate
+
#include <build/path>
#include <build/scope>
#include <build/target>
@@ -20,6 +22,7 @@
#include <build/diagnostics>
using namespace std;
+using namespace butl;
namespace build
{
diff --git a/build/cxx/rule.cxx b/build/cxx/rule.cxx
index 095c98a..c0e6550 100644
--- a/build/cxx/rule.cxx
+++ b/build/cxx/rule.cxx
@@ -11,6 +11,7 @@
#include <utility> // move()
#include <butl/process>
+#include <butl/utility> // reverse_iterate
#include <butl/fdstream>
#include <butl/optional>
@@ -22,7 +23,6 @@
#include <build/context>
#include <build/bin/target>
-
#include <build/cxx/target>
using namespace std;
diff --git a/build/target b/build/target
index 1770d9c..06aa227 100644
--- a/build/target
+++ b/build/target
@@ -16,6 +16,8 @@
#include <utility> // move()
#include <iterator>
+#include <butl/utility> // compare_c_string
+
#include <build/path>
#include <build/map-key> // map_iterator_adapter
#include <build/timestamp>
@@ -24,7 +26,7 @@
#include <build/operation>
#include <build/target-key>
#include <build/prerequisite>
-#include <build/utility> // compare_*, extension_pool
+#include <build/utility> // extension_pool
namespace build
{
@@ -439,20 +441,18 @@ namespace build
extern target_set targets;
- class target_type_map: public std::map<
+ using target_type_map_base = std::map<
const char*,
std::reference_wrapper<const target_type>,
- compare_c_string>
+ butl::compare_c_string>;
+
+ class target_type_map: public target_type_map_base
{
public:
- typedef std::map<const char*,
- std::reference_wrapper<const target_type>,
- compare_c_string> base;
-
void
insert (const target_type& tt) {emplace (tt.name, tt);}
- using base::find;
+ using target_type_map_base::find;
// Given a name, figure out its type, taking into account extensions,
// special names (e.g., '.' and '..'), or anything else that might be
diff --git a/build/utility b/build/utility
index 87a0e44..717a9ed 100644
--- a/build/utility
+++ b/build/utility
@@ -8,7 +8,6 @@
#include <tuple>
#include <string>
#include <utility>
-#include <cstring> // strcmp()
#include <exception>
#include <unordered_set>
@@ -22,59 +21,6 @@ namespace build
extern const path empty_path;
extern const dir_path empty_dir_path;
- // Comparators.
- //
- struct compare_c_string
- {
- bool operator() (const char* x, const char* y) const
- {
- return std::strcmp (x, y) < 0;
- }
- };
-
- struct compare_pointer_target
- {
- template <typename P>
- bool operator() (const P& x, const P& y) const {return *x < *y;}
- };
-
- // Support for reverse iteration using range-based for-loop:
- //
- // for (... : reverse_iterate (x)) ...
- //
- template <typename T>
- class reverse_range
- {
- T& x_;
-
- public:
- reverse_range (T& x): x_ (x) {}
-
- auto begin () -> decltype (this->x_.rbegin ())
- {
- return x_.rbegin ();
- }
-
- auto end () -> decltype (this->x_.rend ())
- {
- return x_.rend ();
- }
- };
-
- template <typename T>
- inline reverse_range<T>
- reverse_iterate (T& x)
- {
- return reverse_range<T> (x);
- }
-
- template <typename T>
- inline reverse_range<const T>
- reverse_iterate (const T& x)
- {
- return reverse_range<const T> (x);
- }
-
// Call a function if there is an exception.
//