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

#include <build/test/rule>

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

using namespace std;

namespace build
{
  namespace test
  {
    match_result rule::
    match (action a, target& t, const std::string&) const
    {
      // First determine if this is a test.
      //
      auto v (t.vars["test"]);

      if (!v)
        v.rebind (t.base_scope ()[string("test.") + t.type ().name]);

      if (!v || !v.as<bool> ())
        return match_result (t, false); // "Not a test" result.

      // If this is the update pre-operation, make someone else do
      // the job.
      //
      if (a.operation () != test_id)
        return nullptr;

      return match_result (t, true);
    }

    recipe rule::
    apply (action, target&, const match_result& mr) const
    {
      if (!mr.value) // Not a test.
        return noop_recipe;

      return noop_recipe; //@@ TMP
    }
  }
}