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 | translator=$1
|
31 | local dir=$DIR/bin.osh_eval.$translator
|
32 | mkdir -p $dir
|
33 |
|
34 | PYTHONPATH=$PY_PATH /usr/bin/env python2 \
|
35 | build/dynamic_deps.py py-manifest bin.osh_eval \
|
36 | > $dir/all.txt
|
37 |
|
38 | set +o errexit
|
39 | cat $dir/all.txt | repo-filter | exclude-filter typecheck | mysort \
|
40 | > $dir/typecheck.txt
|
41 |
|
42 | cat $dir/typecheck.txt | exclude-filter translate | mysort \
|
43 | > $dir/translate.txt
|
44 |
|
45 | echo DEPS $dir/*
|
46 | }
|
47 |
|
48 | oils-for-unix() {
|
49 | ### The main binary
|
50 |
|
51 | translator=$1
|
52 | local dir=$DIR/bin.oils_for_unix.$translator
|
53 | mkdir -p $dir
|
54 |
|
55 | PYTHONPATH=$PY_PATH /usr/bin/env python2 \
|
56 | build/dynamic_deps.py py-manifest bin.oils_for_unix \
|
57 | > $dir/all.txt
|
58 |
|
59 | set +o errexit
|
60 | cat $dir/all.txt | repo-filter | exclude-filter typecheck | mysort \
|
61 | > $dir/typecheck.txt
|
62 |
|
63 | cat $dir/typecheck.txt | exclude-filter translate | mysort \
|
64 | > $dir/translate.txt
|
65 |
|
66 | echo DEPS $dir/*
|
67 | }
|
68 |
|
69 | # TODO: Prune deps
|
70 | # j8.py depends on vm.HeapValueId() for cycle detection
|
71 | # But that's in the JSON8 PRINTER, which yaks doesn't need
|
72 | # vm.py depends on cmd_eval.py and a whole bunch of other stuff
|
73 | #
|
74 | # Well I guess you can create a cycle in nil8, especially if we have <- and so
|
75 | # forth.
|
76 | #
|
77 | # So that function should go in another file.
|
78 |
|
79 | yaks() {
|
80 | ### Experimental IR to C++ translator
|
81 |
|
82 | local dir=$DIR/yaks.yaks_main
|
83 | mkdir -p $dir
|
84 |
|
85 | PYTHONPATH=$PY_PATH /usr/bin/env python2 \
|
86 | build/dynamic_deps.py py-manifest yaks.yaks_main \
|
87 | > $dir/all.txt
|
88 |
|
89 | set +o errexit
|
90 | cat $dir/all.txt | repo-filter | exclude-filter typecheck | mysort \
|
91 | > $dir/typecheck.txt
|
92 |
|
93 | cat $dir/typecheck.txt | exclude-filter translate | mysort \
|
94 | > $dir/translate.txt
|
95 |
|
96 | echo DEPS $dir/*
|
97 | }
|
98 |
|
99 | main() {
|
100 | # _build/NINJA/ # Part of the Ninja graph
|
101 | # asdl.asdl_main/
|
102 | # all-pairs.txt
|
103 | # deps.txt
|
104 | # osh_eval/
|
105 | # typecheck.txt
|
106 | # translate.txt
|
107 |
|
108 | mkdir -p _build/NINJA
|
109 |
|
110 | # Implicit dependencies for tools
|
111 | asdl-main
|
112 |
|
113 | optview-gen
|
114 | consts-gen
|
115 | flag-gen
|
116 | lexer-gen
|
117 | option-gen
|
118 | grammar-gen
|
119 | arith-parse-gen
|
120 | signal-gen
|
121 | embedded-file-gen
|
122 |
|
123 | # Explicit dependencies for translating and type checking
|
124 | # Baked into mycpp/NINJA.
|
125 | osh-eval mycpp
|
126 | osh-eval mycpp-souffle
|
127 | oils-for-unix mycpp
|
128 | oils-for-unix mycpp-souffle
|
129 | yaks
|
130 |
|
131 | echo DEPS prebuilt/ninja/*/deps.txt
|
132 |
|
133 | echo
|
134 | # Special _OIL_DEV for -D GC_TIMING
|
135 | _OIL_DEV=1 ./configure
|
136 |
|
137 | # Reads the deps.txt files above
|
138 | PYTHONPATH=. build/ninja_main.py
|
139 | }
|
140 |
|
141 | main "$@"
|