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

#include <build/cli/target>

#include <butl/filesystem>

using namespace std;
using namespace butl;

namespace build
{
  namespace cli
  {
    // cli
    //
    constexpr const char cli_ext[] = "cli";
    const target_type cli::static_type
    {
      typeid (cli),
      "cli",
      &file::static_type,
      &target_factory<cli>,
      &target_extension_fix<cli_ext>,
      &search_file,
      false
    };

    // cli.cxx
    //
    group_view cli_cxx::
    group_members (action) const
    {
      return h != nullptr
        ? group_view {m, (i != nullptr ? 3U : 2U)}
        : group_view {nullptr, 0};
    }

    timestamp cli_cxx::
    load_mtime () const
    {
      // The rule has been matched which means the members should
      // be resolved and paths assigned.
      //
      return file_mtime (h->path ());
    }

    static target*
    cli_cxx_factory (dir_path d, string n, const string* e)
    {
      tracer trace ("cli::cli_cxx::factory");

      // Pre-enter (potential) members as targets. The main purpose
      // of doing this is to avoid searching for existing files in
      // src_base if the buildfile mentions one of them explicitly
      // as a prerequisite.
      //
      targets.insert<cxx::hxx> (d, n, trace);
      targets.insert<cxx::cxx> (d, n, trace);
      targets.insert<cxx::ixx> (d, n, trace);

      return new cli_cxx (move (d), move (n), e);
    }

    const target_type cli_cxx::static_type
    {
      typeid (cli_cxx),
      "cli.cxx",
      &mtime_target::static_type,
      &cli_cxx_factory,
      nullptr,
      &search_target,
      true // See through default semantics.
    };
  }
}