1 #!/usr/bin/env bash
2 #
3 # Creates build.ninja. Crawls dynamic dependencies.
4 #
5 # Usage:
6 # ./NINJA-config.sh
7
8 set -o nounset
9 set -o pipefail
10 set -o errexit
11
12 source build/dev-shell.sh # python2 in $PATH
13 source build/dynamic-deps.sh # py-tool, etc
14
15 asdl-main() { py-tool asdl.asdl_main; }
16
17 optview-gen() { py-tool core.optview_gen; }
18 consts-gen() { py-tool frontend.consts_gen; }
19 flag-gen() { py-tool frontend.flag_gen; }
20 lexer-gen() { py-tool frontend.lexer_gen; }
21 option-gen() { py-tool frontend.option_gen; }
22 grammar-gen() { py-tool ysh.grammar_gen; }
23 arith-parse-gen() { py-tool osh.arith_parse_gen; }
24 signal-gen() { py-tool frontend.signal_gen; }
25 embedded-file-gen() { py-tool cpp.embedded_file_gen; }
26
27 osh-eval() {
28 ### Old binary
29
30 local dir=$DIR/bin.osh_eval
31 mkdir -p $dir
32
33 PYTHONPATH=$PY_PATH /usr/bin/env python2 \
34 build/dynamic_deps.py py-manifest bin.osh_eval \
35 > $dir/all.txt
36
37 set +o errexit
38 cat $dir/all.txt | repo-filter | exclude-filter typecheck | mysort \
39 > $dir/typecheck.txt
40
41 cat $dir/typecheck.txt | exclude-filter translate | mysort \
42 > $dir/translate.txt
43
44 echo DEPS $dir/*
45 }
46
47 oils-for-unix() {
48 ### The main binary
49
50 local dir=$DIR/bin.oils_for_unix
51 mkdir -p $dir
52
53 PYTHONPATH=$PY_PATH /usr/bin/env python2 \
54 build/dynamic_deps.py py-manifest bin.oils_for_unix \
55 > $dir/all.txt
56
57 set +o errexit
58 cat $dir/all.txt | repo-filter | exclude-filter typecheck | mysort \
59 > $dir/typecheck.txt
60
61 cat $dir/typecheck.txt | exclude-filter translate | mysort \
62 > $dir/translate.txt
63
64 echo DEPS $dir/*
65 }
66
67
68 main() {
69 # _build/NINJA/ # Part of the Ninja graph
70 # asdl.asdl_main/
71 # all-pairs.txt
72 # deps.txt
73 # osh_eval/
74 # typecheck.txt
75 # translate.txt
76
77 mkdir -p _build/NINJA
78
79 # Implicit dependencies for tools
80 asdl-main
81
82 optview-gen
83 consts-gen
84 flag-gen
85 lexer-gen
86 option-gen
87 grammar-gen
88 arith-parse-gen
89 signal-gen
90 embedded-file-gen
91
92 # Explicit dependencies for translating and type checking
93 # Baked into mycpp/NINJA.
94 osh-eval
95 oils-for-unix
96
97 echo DEPS prebuilt/ninja/*/deps.txt
98
99 echo
100 # Special _OIL_DEV for -D GC_TIMING
101 _OIL_DEV=1 ./configure
102
103 # Reads the deps.txt files above
104 PYTHONPATH=. build/ninja_main.py
105 }
106
107 main "$@"