aboutsummaryrefslogtreecommitdiff
path: root/build/target.ixx
blob: b6bf5094e010f4ffda5e0e421d2af144ede93bcf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// file      : build/target.ixx -*- C++ -*-
// copyright : Copyright (c) 2014-2015 Code Synthesis Ltd
// license   : MIT; see accompanying LICENSE file

#include <build/scope>

namespace build
{
  // prerequisite_ref
  //
  inline bool prerequisite_ref::
  belongs (const target& t) const
  {
    const auto& p (t.prerequisites);
    return !(p.empty () || this < &p.front () || this > &p.back ());
  }

  // prerequisite_member
  //
  inline prerequisite& prerequisite_member::
  as_prerequisite (tracer& trace) const
  {
    if (target == nullptr)
      return prerequisite;

    // The use of the group's prerequisite scope is debatable.
    //
    scope& s (prerequisite.get ().scope);
    return s.prerequisites.insert (key ().tk, s, trace).first;
  }

  // prerequisite_members
  //
  group_view
  resolve_group_members (action, target_group&); // <build/algorithm>

  template <typename T>
  inline auto prerequisite_members_range<T>::iterator::
  operator++ () -> iterator&
  {
    if (g_.count != 0)
    {
      // Member iteration.
      //
      if (++j_ == g_.count)
      {
        // Switch back to prerequisite iteration.
        //
        g_.count = 0;
        ++i_;
      }
    }
    else
    {
      // Prerequisite iteration.
      //
      if (i_->get ().template is_a<target_group> ())
      {
        // Switch to member iteration.
        //
        target_group& g (static_cast<target_group&> (search (*i_)));
        j_ = 0;
        g_ = resolve_group_members (a_, g);

        if (g_.count == 0)
          ++i_; // Empty group.
      }
      else
        ++i_;
    }

    return *this;
  }
}