aboutsummaryrefslogtreecommitdiff
path: root/build2/target.txx
blob: ea7bca7395865d7d9012ca972b525af6732bbf09 (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
// file      : build2/target.txx -*- C++ -*-
// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd
// license   : MIT; see accompanying LICENSE file

#include <build2/scope>
#include <build2/diagnostics>
#include <build2/prerequisite>

namespace build2
{
  // prerequisite_members_range
  //
  template <typename T>
  void prerequisite_members_range<T>::iterator::
  switch_mode ()
  {
    // A group could be empty, so we may have to iterate.
    //
    do
    {
      g_ = resolve_group_members (r_->l_, r_->a_, search (*i_));
      assert (g_.members != nullptr); // Group could not be resolved.

      if (g_.count != 0) // Skip empty see through groups.
      {
        j_ = 1; // Start from the first group member.
        break;
      }
    }
    while (++i_ != r_->e_ && i_->type.see_through);
  }

  //
  //
  template <const char* ext>
  optional<string>
  target_extension_fix (const target_key&, const scope&, bool)
  {
    return string (ext);
  }

  template <const char* var, const char* def>
  optional<string>
  target_extension_var (const target_key& tk, const scope& s, bool)
  {
    // Include target type/pattern-specific variables.
    //
    if (auto l = s.find (var_pool[var], tk))
    {
      // Help the user here and strip leading '.' from the extension.
      //
      const string& e (cast<string> (l));
      return !e.empty () && e.front () == '.' ? string (e, 1) : e;
    }

    return def != nullptr ? optional<string> (def) : nullopt;
  }
}