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

106 lines, 46 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
15PY_TOOL=(
16 asdl.asdl_main
17 core.optview_gen
18 frontend.consts_gen
19 frontend.flag_gen
20 frontend.lexer_gen
21 frontend.option_gen
22 ysh.grammar_gen
23 osh.arith_parse_gen
24 frontend.signal_gen
25 cpp.embedded_file_gen
26)
27
28BIN=(
29 # translated
30 bin.hello
31 bin.hello_mylib
32 bin.oils_for_unix
33 mycpp.examples.parse
34)
35
36# These special cases should go away
37SPECIAL_BIN=(
38 yaks.yaks_main # Experimental IR to C++ translator
39 bin.osh_parse
40 bin.osh_eval
41)
42
43# A binary looks like this:
44#
45# bin/
46# hello.py # no preamble
47# # uses build/default.{typecheck,translate}-filter.txt
48# oils_for_unix.py
49# oils_for_unix_preamble.h
50# oils_for_unix.typecheck-filter.txt
51# oils_for_unix.translate-filter.txt
52# mycpp/
53# examples/
54# parse.py
55# parse_preamble.h
56# # TODO: {translate,typecheck}-filter
57
58# Supporting files:
59#
60# _build/NINJA/ # Part of the Ninja graph
61# asdl.asdl_main/
62# all-pairs.txt
63# deps.txt
64# bin.hello/
65# all-pairs.txt
66# typecheck.txt
67# translate.txt
68# bin.oils_for_unix/
69# all-pairs.txt
70# typecheck.txt
71# translate.txt
72#
73# Related:
74# prebuilt/
75# ninja/
76# mycpp.mycpp_main/
77# pea.pea_main/
78
79main() {
80 mkdir -p _build/NINJA
81
82 # Implicit dependencies for tools
83 for mod in "${PY_TOOL[@]}"; do
84 py-tool $mod
85 done
86
87 # Use filters next to the binary, or the defaults
88 for mod in "${BIN[@]}"; do
89 typecheck-translate $mod
90 done
91
92 # Legacy: use Oils
93 for mod in "${SPECIAL_BIN[@]}"; do
94 typecheck-translate $mod \
95 bin/oils_for_unix.typecheck-filter.txt \
96 bin/oils_for_unix.translate-filter.txt
97 done
98
99 echo DEPS prebuilt/ninja/*/deps.txt
100 echo
101
102 # Reads the deps.txt files above
103 PYTHONPATH=. build/ninja_main.py
104}
105
106main "$@"