aboutsummaryrefslogtreecommitdiff
path: root/build/bd.cxx
blob: 918434add8a3d7aef6215b665d598719b36832fd (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
// file      : build/bd.cxx
// copyright : Copyright (c) 2014-2015 Code Synthesis Tools CC
// license   : MIT; see accompanying LICENSE file

#include <vector>
#include <iostream>

#include <build/target>

using namespace std;

namespace build
{
  bool
  update (target& t)
  {
    const targets& ps (t.prerequisites ());

    for (target& p: ps)
      if (!update (p))
        return false;

    //@@ TODO: check for existance, compare timestamps.

    auto r (t.rule ());
    return r != 0 ? r (t, t.prerequisites ()) : true;
  }
}

using namespace build;

bool
cxx_compile_rule (target& t, const targets& p)
{
  //@@ TODO: actually execute

  cerr << "c++ " << t.name () << endl;
  return true;
}

bool
cxx_link_rule (target& t, const targets& p)
{
  cerr << "ld " << t.name () << endl;
  return true;
}

int
main (int argc, char* argv[])
{
  exe bd ("bd");
  obj bd_o ("bd.o");
  bd.prerequisite (bd_o);
  bd.rule (&cxx_link_rule);

  cxx bd_cxx ("bd.cxx");
  hxx target ("target");
  bd_o.prerequisite (bd_cxx);
  bd_o.prerequisite (target);
  bd_o.rule (&cxx_compile_rule);

  update (bd);
}