summaryrefslogtreecommitdiffstats
path: root/build.ninja
blob: 614936a74375053e51a6d5b925c3f385d5ae8c21 (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
78
79
80
81
82
83
84
85
86
87
88
# This file is used to build ninja itself.

# NOTE: it is an explicit non-goal of ninja to make it convenient to
# write these files by hand.  For a real project, you'd generate this
# file from higher-level rules.

# I was tempted to generate this file even for ninja itself but I
# figured it'd be easier to bootstrap this way.

builddir = build
cxx = g++
#cxx = /home/evanm/projects/src/llvm/Release+Asserts/bin/clang++
cflags = -g -Wall -Wno-deprecated -fno-exceptions -fvisibility=hidden -pipe
# -rdynamic is needed for backtrace()
ldflags = -g -rdynamic

# bootstrap.sh generates a "config.ninja" file, which contains some
# minor build customization for development purposes.
include config.ninja

rule cxx
  depfile = $out.d
  command = $cxx -MMD -MF $out.d $conf_cflags $cflags -c $in -o $out
  description = CC $out

rule ar
  command = ar crs $out $in
  description = AR $out

rule link
  command = $cxx $conf_ldflags $ldflags -o $out $in
  description = LINK $out

rule inline
  command = src/inline.sh $varname < $in > $out
  description = INLINE $out

build $builddir/browse_py.h: inline src/browse.py
  varname = kBrowsePy

build $builddir/browse.o: cxx src/browse.cc || $builddir/browse_py.h
build $builddir/build.o: cxx src/build.cc
build $builddir/build_log.o: cxx src/build_log.cc
build $builddir/eval_env.o: cxx src/eval_env.cc
build $builddir/graph.o: cxx src/graph.cc
build $builddir/parsers.o: cxx src/parsers.cc
build $builddir/subprocess.o: cxx src/subprocess.cc
build $builddir/util.o: cxx src/util.cc
build $builddir/ninja_jumble.o: cxx src/ninja_jumble.cc
build $builddir/ninja.a: ar $builddir/browse.o $builddir/build.o \
    $builddir/build_log.o $builddir/eval_env.o $builddir/graph.o \
    $builddir/parsers.o $builddir/subprocess.o $builddir/util.o \
    $builddir/ninja_jumble.o

build $builddir/ninja.o: cxx src/ninja.cc
build ninja: link $builddir/ninja.o $builddir/ninja.a

build $builddir/build_test.o: cxx src/build_test.cc
build $builddir/build_log_test.o: cxx src/build_log_test.cc
build $builddir/graph_test.o: cxx src/graph_test.cc
build $builddir/ninja_test.o: cxx src/ninja_test.cc
build $builddir/parsers_test.o: cxx src/parsers_test.cc
build $builddir/subprocess_test.o: cxx src/subprocess_test.cc
build $builddir/test.o: cxx src/test.cc
build ninja_test: link $builddir/build_test.o $builddir/build_log_test.o \
    $builddir/graph_test.o $builddir/ninja_test.o $builddir/parsers_test.o \
    $builddir/subprocess_test.o $builddir/test.o $builddir/ninja.a
  ldflags = -g -rdynamic -lgtest -lgtest_main -lpthread


# Generate a graph using the -g flag.
rule gendot
  command = ./ninja -t graph all > $out
rule gengraph
  command = dot -Tpng $in > $out

build $builddir/graph.dot: gendot ninja build.ninja
build graph.png: gengraph $builddir/graph.dot

# Generate docs.
rule asciidoc
  command = asciidoc -a toc $in
  description = ASCIIDOC $in

build manual.html: asciidoc manual.asciidoc
build doc: phony || manual.html

build all: phony || ninja ninja_test graph.png doc