summaryrefslogtreecommitdiffstats
path: root/ninja.cc
blob: 48ae0f63c6c5a621c7bc0c059a365a042467b8e9 (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
#include "ninja.h"

int main(int argc, char** argv) {
  State state;
  ManifestParser parser(&state);
  string err;
  if (!parser.Load("build.ninja", &err)) {
    fprintf(stderr, "error loading: %s\n", err.c_str());
    return 1;
  }

  if (argc < 2) {
    fprintf(stderr, "usage: %s target\n", argv[0]);
    return 1;
  }

  state.stat_cache()->Reload();
  state.stat_cache()->Dump();

  Shell shell;
  Builder builder(&state);
  builder.AddTarget(argv[1]);
  bool success = builder.Build(&shell, &err);
  if (!err.empty()) {
    printf("%s\n", err.c_str());
  }

  return success ? 1 : 0;
}