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

#include <build2/dist/rule>

#include <build2/scope>
#include <build2/target>
#include <build2/algorithm>
#include <build2/diagnostics>

using namespace std;

namespace build2
{
  namespace dist
  {
    match_result rule::
    match (action, target&, const string&) const
    {
      return true; // We always match.
    }

    recipe rule::
    apply (action a, target& t) const
    {
      const dir_path& out_root (t.root_scope ().out_path ());

      auto r (group_prerequisite_members (a, t, false));
      for (auto i (r.begin ()); i != r.end (); ++i)
      {
        prerequisite_member p (*i);

        // Skip prerequisites imported from other projects.
        //
        if (p.proj ())
          continue;

        // If we can, go inside see-through groups. Note that here we are
        // not going into ad hoc groups but maybe we should (which would
        // have to be done after match()).
        //
        if (p.type ().see_through && i.enter_group ())
          continue;

        const target& pt (p.search ());

        // Don't match targets that are outside of our project.
        //
        if (pt.dir.sub (out_root))
          build2::match (a, pt);
      }

      return noop_recipe; // We will never be executed.
    }
  }
}