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

228 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 # This includes in the release tarball. (It doesn't change any
98 # compiler command lines, which don't include header files)
99 headers=[
100 'data_lang/utf8_impls/bjoern_dfa.h',
101 ],
102 )
103
104 ru.cc_binary('cpp/data_lang_test.cc',
105 deps=[
106 '//cpp/data_lang',
107 '//data_lang/j8_libc',
108 '//data_lang/j8_test_lib',
109 ],
110 matrix=ninja_lib.COMPILERS_VARIANTS)
111
112 # Note: depends on code generated by re2c
113 ru.cc_library(
114 '//cpp/frontend_match',
115 srcs=[
116 'cpp/frontend_match.cc',
117 ],
118 deps=[
119 '//frontend/syntax.asdl',
120 '//frontend/types.asdl',
121 '//mycpp/runtime',
122 ],
123 )
124
125 ru.cc_library(
126 '//cpp/frontend_pyreadline',
127 srcs=[
128 'cpp/frontend_pyreadline.cc',
129 ],
130 deps=[
131 '//cpp/core',
132 '//mycpp/runtime',
133 ],
134 )
135
136 ru.cc_binary('cpp/frontend_match_test.cc',
137 deps=['//cpp/frontend_match'],
138 matrix=ninja_lib.COMPILERS_VARIANTS)
139
140 ru.cc_library(
141 '//cpp/frontend_flag_spec',
142 srcs=[
143 'cpp/frontend_flag_spec.cc',
144 ],
145 deps=[
146 # Dependencies of //prebuilt/frontend/args.mycpp
147 '//core/runtime.asdl',
148 '//core/value.asdl',
149 '//frontend/syntax.asdl',
150 '//frontend/arg_types', # generated code
151 '//mycpp/runtime',
152 ],
153 )
154
155 ru.cc_binary(
156 'cpp/frontend_flag_spec_test.cc',
157 deps=[
158 '//cpp/frontend_flag_spec',
159 '//prebuilt/frontend/args.mycpp', # prebuilt args::Reader, etc.
160 ],
161 # special -D CPP_UNIT_TEST
162 #matrix = CPP_UNIT_MATRIX)
163 matrix=ninja_lib.COMPILERS_VARIANTS)
164
165 ru.cc_library('//cpp/fanos_shared', srcs=['cpp/fanos_shared.c'])
166
167 ru.cc_library('//cpp/fanos',
168 srcs=['cpp/fanos.cc'],
169 deps=['//cpp/fanos_shared', '//mycpp/runtime'])
170
171 ru.cc_library('//cpp/libc', srcs=['cpp/libc.cc'], deps=['//mycpp/runtime'])
172
173 ru.cc_binary('cpp/libc_test.cc',
174 deps=['//cpp/libc'],
175 matrix=ninja_lib.COMPILERS_VARIANTS)
176
177 ru.cc_library('//cpp/osh',
178 srcs=[
179 'cpp/osh.cc',
180 'cpp/osh_tdop.cc',
181 ],
182 deps=[
183 '//frontend/syntax.asdl',
184 '//cpp/core',
185 '//mycpp/runtime',
186 ])
187
188 ru.cc_binary(
189 'cpp/osh_test.cc',
190 deps=[
191 '//cpp/osh',
192 '//prebuilt/core/error.mycpp', # prebuilt e_die()
193 ],
194 matrix=ninja_lib.COMPILERS_VARIANTS)
195
196 ru.cc_library('//cpp/pgen2',
197 srcs=['cpp/pgen2.cc'],
198 deps=[
199 '//mycpp/runtime',
200 '//frontend/syntax.asdl',
201 ])
202
203 ru.cc_library('//cpp/pylib',
204 srcs=['cpp/pylib.cc'],
205 deps=['//mycpp/runtime'])
206
207 ru.cc_binary('cpp/pylib_test.cc',
208 deps=['//cpp/pylib'],
209 matrix=ninja_lib.COMPILERS_VARIANTS)
210
211 ru.cc_library(
212 '//cpp/stdlib',
213 srcs=['cpp/stdlib.cc'],
214 deps=[
215 '//mycpp/runtime',
216 # Annoying: because of the circular dep issue, we need to repeat
217 # dependencies of //prebuilt/core/error.mycpp. We don't want to depend
218 # on it directly because we'd get duplicate symbols during linking.
219 '//frontend/syntax.asdl',
220 ])
221
222 ru.cc_binary(
223 'cpp/stdlib_test.cc',
224 deps=[
225 '//cpp/stdlib',
226 '//prebuilt/core/error.mycpp', # prebuilt e_die()
227 ],
228 matrix=ninja_lib.COMPILERS_VARIANTS)