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

111 lines, 45 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)
34
35# These special cases should go away
36SPECIAL_BIN=(
37 yaks.yaks_main # Experimental IR to C++ translator
38 bin.osh_parse
39 bin.osh_eval
40)
41
42# Create a dir structure htat looks like this:
43
44# _build/NINJA/ # Part of the Ninja graph
45# asdl.asdl_main/
46# all-pairs.txt
47# deps.txt
48# bin.hello/
49# all-pairs.txt
50# deps.txt
51# bin.oils_for_unix/
52# all-pairs.txt
53# typecheck.txt # special case
54# deps.txt
55#
56# Related:
57# prebuilt/
58# ninja/
59# mycpp.mycpp_main/
60# dynamic-deps/
61# filter-py-tool
62# mycpp/
63# examples/
64# parse.translate.txt
65# parse.typecheck.txt
66#
67# Should be parse.typecheck.txt and parse.deps.txt
68#
69# New structure
70# bin/
71# oils_for_unix.py
72# oils_for_unix_preamble.h
73# oils_for_unix.typecheck-filter.txt
74# oils_for_unix.deps-filter.txt
75# mycpp/
76# examples/
77# parse.py
78# parse_preamble.h
79# parse.deps-filter.txt
80#
81# All of these are optional, except deps-filter?
82# The default deps-filter can be in prebuilt/ perhaps
83
84main() {
85 mkdir -p _build/NINJA
86
87 # Implicit dependencies for tools
88 for mod in "${PY_TOOL[@]}"; do
89 py-tool $mod
90 done
91
92 # These use
93 for mod in "${BIN[@]}"; do
94 typecheck-translate $mod
95 done
96
97 # These override it
98 for mod in "${SPECIAL_BIN[@]}"; do
99 typecheck-translate $mod \
100 bin/oils_for_unix.typecheck-filter.txt \
101 bin/oils_for_unix.translate-filter.txt
102 done
103
104 echo DEPS prebuilt/ninja/*/deps.txt
105 echo
106
107 # Reads the deps.txt files above
108 PYTHONPATH=. build/ninja_main.py
109}
110
111main "$@"