OILS / bin / NINJA_subgraph.py View on Github | oils.pub

150 lines, 101 significant
1"""
2bin/NINJA_subgraph.py
3"""
4from __future__ import print_function
5
6from glob import glob
7from fnmatch import fnmatch
8
9from build import ninja_lib
10from build.ninja_lib import mycpp_binary, log
11
12_ = log
13
14
15def NinjaGraph(ru):
16 n = ru.n
17
18 ru.comment('Generated by %s' % __name__)
19
20 #
21 # Files embedded in binary
22 #
23
24 n.rule('embedded-file-gen',
25 command='_bin/shwrap/embedded_file_gen $in > $out',
26 description='embedded_file_gen $in $out')
27
28 # Generated by build/py.sh all -> build/doc.sh all-help
29 # I wish Ninja had DIRECTORY-level dependencies? Because this should
30 # ultimately depend on doc/ref/*.md
31 # We could probably create a _build/ninja-stamp/HELP file and so forth
32 files = glob('_devbuild/help/*')
33
34 # OSH and YSH stdlib
35 tmp = glob('stdlib/ysh/*.ysh') + glob('stdlib/osh/*.sh')
36
37 # Remove this?
38 tmp.extend(glob('stdlib/*.ysh'))
39
40 # exclude test files
41 for path in tmp:
42 if fnmatch(path, '*-test.ysh'):
43 continue
44 if fnmatch(path, '*-test.sh'):
45 continue
46 if fnmatch(path, '*/draft-*'):
47 continue
48
49 files.append(path)
50
51 # Make sure it's DETERMINISTIC
52 files.sort()
53
54 n.build(['_gen/bin/text_files.cc'],
55 'embedded-file-gen',
56 files,
57 implicit=['_bin/shwrap/embedded_file_gen'])
58 n.newline()
59
60 ru.cc_library('//bin/text_files', srcs=['_gen/bin/text_files.cc'])
61
62 #
63 # Programs
64 #
65
66 mycpp_binary(
67 ru,
68 'bin/hello.py',
69 deps=['//mycpp/runtime'],
70 )
71
72 # Try out souffle
73 mycpp_binary(
74 ru,
75 'bin/hello.py',
76 translator='mycpp-souffle',
77 deps=['//mycpp/runtime'],
78 )
79
80 # Use the stdlib
81 mycpp_binary(
82 ru,
83 'bin/hello_mylib.py',
84 deps=['//mycpp/runtime'],
85 )
86
87 oils_deps = [
88 '//bin/text_files',
89 '//cpp/core',
90 '//cpp/data_lang',
91 '//cpp/fanos',
92 '//cpp/libc',
93 '//cpp/osh',
94 '//cpp/pgen2',
95 '//cpp/pylib',
96 '//cpp/stdlib',
97 '//cpp/frontend_flag_spec',
98 '//cpp/frontend_match',
99 '//cpp/frontend_pyreadline',
100 '//data_lang/nil8.asdl',
101 '//display/pretty.asdl',
102 '//frontend/arg_types',
103 '//frontend/consts',
104 '//frontend/help_meta',
105 '//frontend/id_kind.asdl',
106 '//frontend/option.asdl',
107 '//frontend/signal',
108 '//frontend/syntax.asdl',
109 '//frontend/types.asdl',
110 '//core/optview',
111 '//core/runtime.asdl',
112 '//core/value.asdl',
113 '//osh/arith_parse',
114 '//ysh/grammar',
115 '//mycpp/runtime',
116 ]
117
118 # TODO: other files should get their own
119 oils_preamble = 'bin/oils_for_unix_preamble.h'
120
121 mycpp_binary(ru, 'bin/osh_eval.py', preamble=oils_preamble, deps=oils_deps)
122 mycpp_binary(ru,
123 'bin/osh_parse.py',
124 preamble=oils_preamble,
125 deps=oils_deps)
126
127 oils_symlinks = ['osh', 'ysh']
128 matrix = (ninja_lib.COMPILERS_VARIANTS + ninja_lib.GC_PERF_VARIANTS +
129 ninja_lib.OTHER_VARIANTS)
130
131 # Main oils-for-unix binary
132 mycpp_binary(
133 ru,
134 'bin/oils_for_unix.py',
135 matrix=matrix,
136 # _bin/cxx-opt/oils-for-unix, NOT _bin/cxx-opt/bin/oils-for-unix
137 bin_path='oils-for-unix',
138 symlinks=oils_symlinks,
139 deps=oils_deps,
140 )
141 # Faster variant
142 # this could have been _bin/cxx-opt/oils-for-unix.mycpp-souffle?
143 mycpp_binary(
144 ru,
145 'bin/oils_for_unix.py',
146 translator='mycpp-souffle',
147 bin_path='mycpp-souffle/oils-for-unix',
148 symlinks=oils_symlinks,
149 deps=oils_deps,
150 )