aboutsummaryrefslogtreecommitdiff
path: root/build/target.ixx
blob: 3ae9660600789bac13d1adc29864a16e83e8e37b (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
// file      : build/target.ixx -*- C++ -*-
// copyright : Copyright (c) 2014-2015 Code Synthesis Ltd
// license   : MIT; see accompanying LICENSE file

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 (nullptr, key ().tk, s, trace).first;
  }

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

  template <typename T>
  inline auto prerequisite_members_range<T>::iterator::
  operator++ () -> iterator&
  {
    if (g_.count != 0)
    {
      if (++j_ <= g_.count)
        return *this;

      // Switch back to prerequisite iteration mode.
      //
      g_.count = 0;
    }

    ++i_;

    // Switch to member iteration mode.
    //
    if (i_ != r_->e_ && i_->get ().type.see_through)
      switch_members ();

    return *this;
  }

  template <typename T>
  inline void prerequisite_members_range<T>::iterator::
  switch_members ()
  {
    j_ = 1;

    do
    {
      g_ = resolve_group_members (r_->a_, search (*i_));
    }
    while (g_.count == 0  && // Skip empty groups.
           ++i_ != r_->e_ &&
           i_->get ().type.see_through);
  }
}