OILS / cpp / NINJA_subgraph.py View on Github | oilshell.org

227 lines, 177 significant
1"""
2cpp/NINJA_subgraph.py
3"""
4
5from __future__ import print_function
6
7from build import ninja_lib
8from build.ninja_lib import log
9
10# Some tests use #ifndef CPP_UNIT_TEST to disable circular dependencies on
11# generated code
12CPP_UNIT_MATRIX = [
13 ('cxx', 'dbg', '-D CPP_UNIT_TEST'),
14 ('cxx', 'asan', '-D CPP_UNIT_TEST'),
15 ('cxx', 'ubsan', '-D CPP_UNIT_TEST'),
16 #('cxx', 'gcalways', '-D CPP_UNIT_TEST'),
17 ('clang', 'coverage', '-D CPP_UNIT_TEST'),
18]
19
20
21def NinjaGraph(ru):
22 n = ru.n
23
24 ru.comment('Generated by %s' % __name__)
25
26 ru.py_binary('cpp/embedded_file_gen.py')
27
28 # Written by build/py.sh
29 git_commit = '_build/git-commit.txt'
30
31 n.rule('build-stamp-cpp',
32 command='build/stamp.sh gen-cpp $in $out',
33 description='build-stamp-cpp $in $out')
34
35 stamp_prefix = '_gen/cpp/build_stamp'
36 n.build([stamp_prefix + '.h', stamp_prefix + '.cc'],
37 'build-stamp-cpp',
38 git_commit,
39 implicit=['build/stamp.sh'])
40 n.newline()
41
42 ru.cc_library('//cpp/build_stamp',
43 srcs=[stamp_prefix + '.cc'],
44 generated_headers=[stamp_prefix + '.h'])
45
46 ru.cc_binary(
47 'cpp/obj_layout_test.cc',
48 deps=[
49 '//core/runtime.asdl',
50 '//mycpp/runtime',
51 ],
52 # Add tcmalloc for malloc_address_test
53 matrix=ninja_lib.COMPILERS_VARIANTS + [('cxx', 'tcmalloc')])
54
55 ru.cc_binary('cpp/unicode_test.cc',
56 deps=['//mycpp/runtime'],
57 matrix=ninja_lib.COMPILERS_VARIANTS)
58
59 ru.cc_library(
60 '//cpp/core',
61 srcs=['cpp/core.cc'],
62 deps=[
63 '//cpp/build_stamp',
64 '//frontend/consts', # for gVersion
65 '//frontend/syntax.asdl',
66 '//mycpp/runtime',
67 '//ysh/grammar',
68 ],
69 )
70
71 ru.cc_binary('cpp/core_test.cc',
72 deps=[
73 '//cpp/core',
74 '//cpp/stdlib',
75 ],
76 matrix=ninja_lib.COMPILERS_VARIANTS)
77
78 ru.cc_binary('cpp/data_race_test.cc',
79 deps=[
80 '//cpp/core',
81 ],
82 matrix=ninja_lib.SMALL_TEST_MATRIX + [
83 ('cxx', 'tsan'),
84 ('clang', 'tsan'),
85 ])
86
87 ru.cc_library(
88 '//cpp/data_lang',
89 srcs=[
90 'cpp/data_lang.cc',
91 ],
92 deps=[
93 '//core/value.asdl',
94 '//data_lang/j8',
95 '//mycpp/runtime',
96 ],
97 )
98
99 ru.cc_binary('cpp/data_lang_test.cc',
100 deps=[
101 '//cpp/data_lang',
102 '//data_lang/j8_libc',
103 '//data_lang/j8_test_lib',
104 ],
105 matrix=ninja_lib.COMPILERS_VARIANTS)
106
107 # Note: depends on code generated by re2c
108 ru.cc_library(
109 '//cpp/frontend_match',
110 srcs=[
111 'cpp/frontend_match.cc',
112 ],
113 deps=[
114 '//frontend/syntax.asdl',
115 '//frontend/types.asdl',
116 '//mycpp/runtime',
117 ],
118 )
119
120 ru.cc_library(
121 '//cpp/frontend_pyreadline',
122 srcs=[
123 'cpp/frontend_pyreadline.cc',
124 ],
125 deps=[
126 '//cpp/core',
127 '//mycpp/runtime',
128 ],
129 )
130
131 ru.cc_binary('cpp/frontend_match_test.cc',
132 deps=['//cpp/frontend_match'],
133 matrix=ninja_lib.COMPILERS_VARIANTS)
134
135 ru.cc_library(
136 '//cpp/frontend_flag_spec',
137 srcs=[
138 'cpp/frontend_flag_spec.cc',
139 ],
140 deps=[
141 # Dependencies of //prebuilt/frontend/args.mycpp
142 '//core/runtime.asdl',
143 '//core/value.asdl',
144 '//frontend/syntax.asdl',
145 '//frontend/arg_types', # generated code
146 '//mycpp/runtime',
147 ],
148 )
149
150 ru.cc_binary(
151 'cpp/frontend_flag_spec_test.cc',
152 deps=[
153 '//cpp/frontend_flag_spec',
154 '//prebuilt/frontend/args.mycpp', # prebuilt args::Reader, etc.
155 ],
156 # special -D CPP_UNIT_TEST
157 #matrix = CPP_UNIT_MATRIX)
158 matrix=ninja_lib.COMPILERS_VARIANTS)
159
160 ru.cc_library('//cpp/fanos_shared', srcs=['cpp/fanos_shared.c'])
161
162 ru.cc_library('//cpp/fanos',
163 srcs=['cpp/fanos.cc'],
164 deps=['//cpp/fanos_shared', '//mycpp/runtime'])
165
166 ru.cc_library('//cpp/libc', srcs=['cpp/libc.cc'], deps=['//mycpp/runtime'])
167
168 ru.cc_binary('cpp/libc_test.cc',
169 deps=['//cpp/libc'],
170 matrix=ninja_lib.COMPILERS_VARIANTS)
171
172 ru.cc_library('//cpp/osh',
173 srcs=[
174 'cpp/osh.cc',
175 'cpp/osh_tdop.cc',
176 ],
177 deps=[
178 '//frontend/syntax.asdl',
179 '//cpp/core',
180 '//mycpp/runtime',
181 ])
182
183 ru.cc_binary(
184 'cpp/osh_test.cc',
185 deps=[
186 '//cpp/osh',
187 '//prebuilt/core/error.mycpp', # prebuilt e_die()
188 ],
189 matrix=ninja_lib.COMPILERS_VARIANTS)
190
191 ru.cc_library('//cpp/pgen2',
192 srcs=['cpp/pgen2.cc'],
193 deps=[
194 '//mycpp/runtime',
195 '//frontend/syntax.asdl',
196 ])
197
198 ru.cc_binary('cpp/pgen2_test.cc',
199 deps=['//cpp/pgen2'],
200 matrix=ninja_lib.COMPILERS_VARIANTS)
201
202 ru.cc_library('//cpp/pylib',
203 srcs=['cpp/pylib.cc'],
204 deps=['//mycpp/runtime'])
205
206 ru.cc_binary('cpp/pylib_test.cc',
207 deps=['//cpp/pylib'],
208 matrix=ninja_lib.COMPILERS_VARIANTS)
209
210 ru.cc_library(
211 '//cpp/stdlib',
212 srcs=['cpp/stdlib.cc'],
213 deps=[
214 '//mycpp/runtime',
215 # Annoying: because of the circular dep issue, we need to repeat
216 # dependencies of //prebuilt/core/error.mycpp. We don't want to depend
217 # on it directly because we'd get duplicate symbols during linking.
218 '//frontend/syntax.asdl',
219 ])
220
221 ru.cc_binary(
222 'cpp/stdlib_test.cc',
223 deps=[
224 '//cpp/stdlib',
225 '//prebuilt/core/error.mycpp', # prebuilt e_die()
226 ],
227 matrix=ninja_lib.COMPILERS_VARIANTS)