OILS / NINJA-config.sh View on Github | oilshell.org

137 lines, 75 significant
1#!/usr/bin/env bash
2#
3# Creates build.ninja. Crawls dynamic dependencies.
4#
5# Usage:
6# ./NINJA-config.sh
7
8set -o nounset
9set -o pipefail
10set -o errexit
11
12source build/dev-shell.sh # python2 in $PATH
13source build/dynamic-deps.sh # py-tool, etc
14
15asdl-main() { py-tool asdl.asdl_main; }
16
17optview-gen() { py-tool core.optview_gen; }
18consts-gen() { py-tool frontend.consts_gen; }
19flag-gen() { py-tool frontend.flag_gen; }
20lexer-gen() { py-tool frontend.lexer_gen; }
21option-gen() { py-tool frontend.option_gen; }
22grammar-gen() { py-tool ysh.grammar_gen; }
23arith-parse-gen() { py-tool osh.arith_parse_gen; }
24signal-gen() { py-tool frontend.signal_gen; }
25embedded-file-gen() { py-tool cpp.embedded_file_gen; }
26
27osh-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
47oils-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# TODO: Prune deps
68# j8.py depends on vm.HeapValueId() for cycle detection
69# But that's in the JSON8 PRINTER, which yaks doesn't need
70# vm.py depends on cmd_eval.py and a whole bunch of other stuff
71#
72# Well I guess you can create a cycle in nil8, especially if we have <- and so
73# forth.
74#
75# So that function should go in another file.
76
77yaks() {
78 ### Experimental IR to C++ translator
79
80 local dir=$DIR/yaks.yaks_main
81 mkdir -p $dir
82
83 PYTHONPATH=$PY_PATH /usr/bin/env python2 \
84 build/dynamic_deps.py py-manifest yaks.yaks_main \
85 > $dir/all.txt
86
87 set +o errexit
88 cat $dir/all.txt | repo-filter | exclude-filter typecheck | mysort \
89 > $dir/typecheck.txt
90
91 cat $dir/typecheck.txt | exclude-filter translate | mysort \
92 > $dir/translate.txt
93
94 echo DEPS $dir/*
95}
96
97main() {
98 # _build/NINJA/ # Part of the Ninja graph
99 # asdl.asdl_main/
100 # all-pairs.txt
101 # deps.txt
102 # osh_eval/
103 # typecheck.txt
104 # translate.txt
105
106 mkdir -p _build/NINJA
107
108 # Implicit dependencies for tools
109 asdl-main
110
111 optview-gen
112 consts-gen
113 flag-gen
114 lexer-gen
115 option-gen
116 grammar-gen
117 arith-parse-gen
118 signal-gen
119 embedded-file-gen
120
121 # Explicit dependencies for translating and type checking
122 # Baked into mycpp/NINJA.
123 osh-eval
124 oils-for-unix
125 yaks
126
127 echo DEPS prebuilt/ninja/*/deps.txt
128
129 echo
130 # Special _OIL_DEV for -D GC_TIMING
131 _OIL_DEV=1 ./configure
132
133 # Reads the deps.txt files above
134 PYTHONPATH=. build/ninja_main.py
135}
136
137main "$@"