OILS / NINJA-config.sh View on Github | oils.pub

86 lines, 51 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
15typecheck-translate() {
16 local py_module=$1
17
18 local dir=$DIR/$py_module
19
20 mkdir -p $dir
21
22 PYTHONPATH=$PY_PATH /usr/bin/env python2 \
23 build/dynamic_deps.py py-manifest "$py_module" \
24 > $dir/all.txt
25
26 set +o errexit
27 cat $dir/all.txt | repo-filter | exclude-filter typecheck | mysort \
28 > $dir/typecheck.txt
29
30 cat $dir/typecheck.txt | exclude-filter translate | mysort \
31 > $dir/translate.txt
32
33 echo DEPS $dir/*
34}
35
36PY_TOOL=(
37 asdl.asdl_main
38 core.optview_gen
39 frontend.consts_gen
40 frontend.flag_gen
41 frontend.lexer_gen
42 frontend.option_gen
43 ysh.grammar_gen
44 osh.arith_parse_gen
45 frontend.signal_gen
46 cpp.embedded_file_gen
47)
48
49BIN=(
50 bin.hello
51 bin.osh_parse
52 bin.osh_eval
53 bin.oils_for_unix
54 yaks.yaks_main # Experimental IR to C++ translator
55)
56
57main() {
58 # _build/NINJA/ # Part of the Ninja graph
59 # asdl.asdl_main/
60 # all-pairs.txt
61 # deps.txt
62 # osh_eval/
63 # typecheck.txt
64 # translate.txt
65
66 mkdir -p _build/NINJA
67
68 # Implicit dependencies for tools
69 for mod in "${PY_TOOL[@]}"; do
70 py-tool $mod
71 done
72
73 # Explicit dependencies for translating and type checking
74 # Baked into mycpp/NINJA.
75 for mod in "${BIN[@]}"; do
76 typecheck-translate $mod
77 done
78
79 echo DEPS prebuilt/ninja/*/deps.txt
80 echo
81
82 # Reads the deps.txt files above
83 PYTHONPATH=. build/ninja_main.py
84}
85
86main "$@"