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

166 lines, 115 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 hello_py_inputs = ninja_lib.TryDynamicDeps('bin/hello.py')
67
68 mycpp_binary(
69 ru,
70 'bin/hello.py',
71 main_style='windows-main',
72 py_inputs=hello_py_inputs,
73 deps=['//mycpp/runtime_pure'],
74 )
75
76 # Try out souffle
77 mycpp_binary(
78 ru,
79 'bin/hello.py',
80 main_style='windows-main',
81 py_inputs=hello_py_inputs,
82 translator='mycpp-souffle',
83 deps=['//mycpp/runtime_pure'],
84 )
85
86 # Use the stdlib
87 mycpp_binary(
88 ru,
89 'bin/hello_mylib.py',
90 deps=['//mycpp/runtime'],
91 )
92
93 oils_deps = [
94 '//bin/text_files',
95 '//cpp/core',
96 '//cpp/data_lang',
97 '//cpp/fanos',
98 '//cpp/libc',
99 '//cpp/osh',
100 '//cpp/pgen2',
101 '//cpp/pylib',
102 '//cpp/stdlib',
103 '//cpp/frontend_flag_spec',
104 '//cpp/frontend_match',
105 '//cpp/frontend_pyreadline',
106 '//data_lang/nil8.asdl',
107 '//display/pretty.asdl',
108 '//frontend/arg_types',
109 '//frontend/consts',
110 '//frontend/help_meta',
111 '//frontend/id_kind.asdl',
112 '//frontend/option.asdl',
113 '//frontend/signal',
114 '//frontend/syntax.asdl',
115 '//frontend/types.asdl',
116 '//core/optview',
117 '//core/runtime.asdl',
118 '//core/value.asdl',
119 '//osh/arith_parse',
120 '//ysh/grammar',
121 '//mycpp/runtime',
122 ]
123
124 # TODO: other files should get their own
125 oils_preamble = 'bin/oils_for_unix_preamble.h'
126
127 mycpp_binary(ru,
128 'bin/osh_eval.py',
129 py_inputs=ninja_lib.TryDynamicDeps('bin/osh_eval.py'),
130 preamble=oils_preamble,
131 deps=oils_deps)
132 mycpp_binary(ru,
133 'bin/osh_parse.py',
134 py_inputs=ninja_lib.TryDynamicDeps('bin/osh_parse.py'),
135 preamble=oils_preamble,
136 deps=oils_deps)
137
138 oils_symlinks = ['osh', 'ysh']
139 matrix = (ninja_lib.COMPILERS_VARIANTS + ninja_lib.GC_PERF_VARIANTS +
140 ninja_lib.OTHER_VARIANTS)
141
142 oils_py_inputs = ninja_lib.TryDynamicDeps('bin/oils_for_unix.py')
143
144 # Main oils-for-unix binary
145 mycpp_binary(
146 ru,
147 'bin/oils_for_unix.py',
148 py_inputs=oils_py_inputs,
149 matrix=matrix,
150 # _bin/cxx-opt/oils-for-unix, NOT _bin/cxx-opt/bin/oils-for-unix
151 bin_path='oils-for-unix',
152 symlinks=oils_symlinks,
153 deps=oils_deps,
154 preprocessed=True,
155 )
156 # Faster variant
157 # this could have been _bin/cxx-opt/oils-for-unix.mycpp-souffle?
158 mycpp_binary(
159 ru,
160 'bin/oils_for_unix.py',
161 py_inputs=oils_py_inputs,
162 translator='mycpp-souffle',
163 bin_path='mycpp-souffle/oils-for-unix',
164 symlinks=oils_symlinks,
165 deps=oils_deps,
166 )