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

231 lines, 180 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_demo.cc',
56 deps=['//mycpp/runtime'],
57 matrix=ninja_lib.COMPILERS_VARIANTS)
58
59 ru.cc_binary('cpp/libc_demo.cc',
60 deps=['//mycpp/runtime'],
61 matrix=ninja_lib.COMPILERS_VARIANTS)
62
63 ru.cc_library(
64 '//cpp/core',
65 srcs=['cpp/core.cc'],
66 deps=[
67 '//cpp/build_stamp',
68 '//frontend/consts', # for gVersion
69 '//frontend/syntax.asdl',
70 '//mycpp/runtime',
71 '//ysh/grammar',
72 ],
73 )
74
75 ru.cc_binary('cpp/core_test.cc',
76 deps=[
77 '//cpp/core',
78 '//cpp/stdlib',
79 ],
80 matrix=ninja_lib.COMPILERS_VARIANTS)
81
82 ru.cc_binary('cpp/data_race_test.cc',
83 deps=[
84 '//cpp/core',
85 ],
86 matrix=ninja_lib.SMALL_TEST_MATRIX + [
87 ('cxx', 'tsan'),
88 ('clang', 'tsan'),
89 ])
90
91 ru.cc_library(
92 '//cpp/data_lang',
93 srcs=[
94 'cpp/data_lang.cc',
95 ],
96 deps=[
97 '//core/value.asdl',
98 '//data_lang/j8',
99 '//mycpp/runtime',
100 ],
101 )
102
103 ru.cc_binary('cpp/data_lang_test.cc',
104 deps=[
105 '//cpp/data_lang',
106 '//data_lang/j8_libc',
107 '//data_lang/j8_test_lib',
108 ],
109 matrix=ninja_lib.COMPILERS_VARIANTS)
110
111 # Note: depends on code generated by re2c
112 ru.cc_library(
113 '//cpp/frontend_match',
114 srcs=[
115 'cpp/frontend_match.cc',
116 ],
117 deps=[
118 '//frontend/syntax.asdl',
119 '//frontend/types.asdl',
120 '//mycpp/runtime',
121 ],
122 )
123
124 ru.cc_library(
125 '//cpp/frontend_pyreadline',
126 srcs=[
127 'cpp/frontend_pyreadline.cc',
128 ],
129 deps=[
130 '//cpp/core',
131 '//mycpp/runtime',
132 ],
133 )
134
135 ru.cc_binary('cpp/frontend_match_test.cc',
136 deps=['//cpp/frontend_match'],
137 matrix=ninja_lib.COMPILERS_VARIANTS)
138
139 ru.cc_library(
140 '//cpp/frontend_flag_spec',
141 srcs=[
142 'cpp/frontend_flag_spec.cc',
143 ],
144 deps=[
145 # Dependencies of //prebuilt/frontend/args.mycpp
146 '//core/runtime.asdl',
147 '//core/value.asdl',
148 '//frontend/syntax.asdl',
149 '//frontend/arg_types', # generated code
150 '//mycpp/runtime',
151 ],
152 )
153
154 ru.cc_binary(
155 'cpp/frontend_flag_spec_test.cc',
156 deps=[
157 '//cpp/frontend_flag_spec',
158 '//prebuilt/frontend/args.mycpp', # prebuilt args::Reader, etc.
159 ],
160 # special -D CPP_UNIT_TEST
161 #matrix = CPP_UNIT_MATRIX)
162 matrix=ninja_lib.COMPILERS_VARIANTS)
163
164 ru.cc_library('//cpp/fanos_shared', srcs=['cpp/fanos_shared.c'])
165
166 ru.cc_library('//cpp/fanos',
167 srcs=['cpp/fanos.cc'],
168 deps=['//cpp/fanos_shared', '//mycpp/runtime'])
169
170 ru.cc_library('//cpp/libc', srcs=['cpp/libc.cc'], deps=['//mycpp/runtime'])
171
172 ru.cc_binary('cpp/libc_test.cc',
173 deps=['//cpp/libc'],
174 matrix=ninja_lib.COMPILERS_VARIANTS)
175
176 ru.cc_library('//cpp/osh',
177 srcs=[
178 'cpp/osh.cc',
179 'cpp/osh_tdop.cc',
180 ],
181 deps=[
182 '//frontend/syntax.asdl',
183 '//cpp/core',
184 '//mycpp/runtime',
185 ])
186
187 ru.cc_binary(
188 'cpp/osh_test.cc',
189 deps=[
190 '//cpp/osh',
191 '//prebuilt/core/error.mycpp', # prebuilt e_die()
192 ],
193 matrix=ninja_lib.COMPILERS_VARIANTS)
194
195 ru.cc_library('//cpp/pgen2',
196 srcs=['cpp/pgen2.cc'],
197 deps=[
198 '//mycpp/runtime',
199 '//frontend/syntax.asdl',
200 ])
201
202 ru.cc_binary('cpp/pgen2_test.cc',
203 deps=['//cpp/pgen2'],
204 matrix=ninja_lib.COMPILERS_VARIANTS)
205
206 ru.cc_library('//cpp/pylib',
207 srcs=['cpp/pylib.cc'],
208 deps=['//mycpp/runtime'])
209
210 ru.cc_binary('cpp/pylib_test.cc',
211 deps=['//cpp/pylib'],
212 matrix=ninja_lib.COMPILERS_VARIANTS)
213
214 ru.cc_library(
215 '//cpp/stdlib',
216 srcs=['cpp/stdlib.cc'],
217 deps=[
218 '//mycpp/runtime',
219 # Annoying: because of the circular dep issue, we need to repeat
220 # dependencies of //prebuilt/core/error.mycpp. We don't want to depend
221 # on it directly because we'd get duplicate symbols during linking.
222 '//frontend/syntax.asdl',
223 ])
224
225 ru.cc_binary(
226 'cpp/stdlib_test.cc',
227 deps=[
228 '//cpp/stdlib',
229 '//prebuilt/core/error.mycpp', # prebuilt e_die()
230 ],
231 matrix=ninja_lib.COMPILERS_VARIANTS)