blob: ed4d20929c31e748482544afcbd6bcdb23a7aee1 [file] [log] [blame]
Dan Willemsenb3614d22019-10-07 16:06:34 -07001// Copyright 2019 Google Inc. All rights reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
Tom Cherryff869db2020-01-08 14:13:00 -080015build = [
16 "Android-bionic.bp",
17 "Android-linux_x86_64.bp",
18 "Android-darwin_x86_64.bp",
19]
Dan Willemsenb3614d22019-10-07 16:06:34 -070020
21cc_defaults {
22 name: "py3-interp-defaults",
23 cflags: [
24 "-fwrapv",
25 "-O3",
26 "-Wall",
27 "-Wstrict-prototypes",
28 "-DPy_BUILD_CORE",
29 "-Werror",
30 "-Wno-invalid-source-encoding",
31 "-Wno-int-conversion",
32 "-Wno-missing-field-initializers",
33 "-Wno-null-pointer-arithmetic",
34 "-Wno-register",
35 "-Wno-shift-count-overflow",
36 "-Wno-sign-compare",
37 "-Wno-tautological-compare",
38 "-Wno-tautological-constant-out-of-range-compare",
39 "-Wno-unused-function",
40 "-Wno-unused-parameter",
41 "-Wno-unused-result",
42 ],
43 local_include_dirs: [
44 "Include",
45 "Include/internal",
46 ],
47 static_libs: ["libffi"],
48 target: {
49 android: {
50 local_include_dirs: ["android/bionic/pyconfig"],
51 },
52 android_arm: {
53 cflags: ["-DSOABI=\"cpython-38android-arm-android-bionic\""],
54 },
55 android_arm64: {
56 cflags: ["-DSOABI=\"cpython-38android-arm64-android-bionic\""],
57 },
58 android_x86: {
59 cflags: ["-DSOABI=\"cpython-38android-x86-android-bionic\""],
60 },
61 android_x86_64: {
62 cflags: ["-DSOABI=\"cpython-38android-x86_64-android-bionic\""],
63 },
64 // Regenerate include dirs with android_regen.sh
65 darwin_x86_64: {
66 local_include_dirs: ["android/darwin_x86_64/pyconfig"],
67 cflags: [
68 "-Wno-deprecated-declarations",
69 "-Wno-pointer-arith",
70 "-DSOABI=\"cpython-38android-x86_64-darwin\"",
71 ],
72 },
73 linux_bionic: {
74 // NB linux_bionic is a 'host' architecture but it uses the bionic libc like 'android'
75 // targets so use the android pyconfig.
76 local_include_dirs: ["android/bionic/pyconfig"],
77 cflags: ["-DSOABI=\"cpython-38android-x86_64-linux-bionic\""],
78 },
79 linux_glibc_x86: {
80 enabled: false,
81 },
82 linux_glibc_x86_64: {
83 local_include_dirs: ["android/linux_x86_64/pyconfig"],
84 cflags: ["-DSOABI=\"cpython-38android-x86_64-linux-gnu\""],
85 },
86 windows: {
87 enabled: false,
88 },
89 },
90 host_supported: true,
91 compile_multilib: "both",
92 multilib: {
93 lib32: {
94 suffix: "32",
95 },
96 lib64: {
97 suffix: "64",
98 },
99 },
100}
101
102cc_library_static {
103 name: "py3-interp",
104 defaults: ["py3-interp-defaults"],
105 cflags: ["-DPy_BUILD_CORE"],
106 srcs: [
107 // Makefile.pre.in PARSER_OBJS
108 "Parser/acceler.c",
109 "Parser/grammar1.c",
110 "Parser/listnode.c",
111 "Parser/myreadline.c",
112 "Parser/node.c",
113 "Parser/parser.c",
114 "Parser/parsetok.c",
115 "Parser/token.c",
116 "Parser/tokenizer.c",
117
118 // Makefile.pre.in OBJECT_OBJS
119 "Objects/abstract.c",
120 "Objects/accu.c",
121 "Objects/boolobject.c",
122 "Objects/bytes_methods.c",
123 "Objects/bytearrayobject.c",
124 "Objects/bytesobject.c",
125 "Objects/call.c",
126 "Objects/capsule.c",
127 "Objects/cellobject.c",
128 "Objects/classobject.c",
129 "Objects/codeobject.c",
130 "Objects/complexobject.c",
131 "Objects/descrobject.c",
132 "Objects/enumobject.c",
133 "Objects/exceptions.c",
134 "Objects/genobject.c",
135 "Objects/fileobject.c",
136 "Objects/floatobject.c",
137 "Objects/frameobject.c",
138 "Objects/funcobject.c",
139 "Objects/interpreteridobject.c",
140 "Objects/iterobject.c",
141 "Objects/listobject.c",
142 "Objects/longobject.c",
143 "Objects/dictobject.c",
144 "Objects/odictobject.c",
145 "Objects/memoryobject.c",
146 "Objects/methodobject.c",
147 "Objects/moduleobject.c",
148 "Objects/namespaceobject.c",
149 "Objects/object.c",
150 "Objects/obmalloc.c",
151 "Objects/picklebufobject.c",
152 "Objects/rangeobject.c",
153 "Objects/setobject.c",
154 "Objects/sliceobject.c",
155 "Objects/structseq.c",
156 "Objects/tupleobject.c",
157 "Objects/typeobject.c",
158 "Objects/unicodeobject.c",
159 "Objects/unicodectype.c",
160 "Objects/weakrefobject.c",
161
162 // Makefile.pre.in PYTHON_OBJS
163 "Python/_warnings.c",
164 "Python/Python-ast.c",
165 "Python/asdl.c",
166 "Python/ast.c",
167 "Python/ast_opt.c",
168 "Python/ast_unparse.c",
169 "Python/bltinmodule.c",
170 "Python/ceval.c",
171 "Python/codecs.c",
172 "Python/compile.c",
173 "Python/context.c",
174 "Python/dynamic_annotations.c",
175 "Python/errors.c",
176 "Python/frozen.c",
177 "Python/frozenmain.c",
178 "Python/future.c",
179 "Python/getargs.c",
180 "Python/getcompiler.c",
181 "Python/getcopyright.c",
182 "Python/getplatform.c",
183 "Python/getversion.c",
184 "Python/graminit.c",
185 "Python/hamt.c",
186 "Python/import.c",
187 "Python/importdl.c",
188 "Python/initconfig.c",
189 "Python/marshal.c",
190 "Python/modsupport.c",
191 "Python/mysnprintf.c",
192 "Python/mystrtoul.c",
193 "Python/pathconfig.c",
194 "Python/peephole.c",
195 "Python/preconfig.c",
196 "Python/pyarena.c",
197 "Python/pyctype.c",
198 "Python/pyfpe.c",
199 "Python/pyhash.c",
200 "Python/pylifecycle.c",
201 "Python/pymath.c",
202 "Python/pystate.c",
203 "Python/pythonrun.c",
204 "Python/pytime.c",
205 "Python/bootstrap_hash.c",
206 "Python/structmember.c",
207 "Python/symtable.c",
208 "Python/sysmodule.c",
209 "Python/thread.c",
210 "Python/traceback.c",
211 "Python/getopt.c",
212 "Python/pystrcmp.c",
213 "Python/pystrtod.c",
214 "Python/pystrhex.c",
215 "Python/dtoa.c",
216 "Python/formatter_unicode.c",
217 "Python/fileutils.c",
218 "Python/dynload_shlib.c",
219 ],
220
221 target: {
222 linux: {
223 cflags: [
Luca Stefani9d70c2b2020-08-24 14:25:20 +0200224 "-DPLATFORM=\"linux\"",
Luca Stefanib9c5ed92020-08-24 15:05:00 +0200225 "-DABIFLAGS=\"\"",
Dan Willemsenb3614d22019-10-07 16:06:34 -0700226 ],
227 },
228 darwin_x86_64: {
229 cflags: [
230 "-DPLATFORM=\"darwin\"",
Luca Stefanib9c5ed92020-08-24 15:05:00 +0200231 "-DABIFLAGS=\"\"",
Dan Willemsenb3614d22019-10-07 16:06:34 -0700232 ],
233 },
234 },
235}
236
237cc_defaults {
238 name: "py3-launcher-defaults",
239 defaults: ["py3-interp-defaults"],
240 cflags: [
241 "-DVERSION=\"3.8\"",
242 "-DVPATH=\"\"",
243 "-DPREFIX=\"\"",
244 "-DEXEC_PREFIX=\"\"",
245 "-DPYTHONPATH=\"..:\"",
246 "-DANDROID_SKIP_ZIP_PATH",
247 "-DANDROID_SKIP_EXEC_PREFIX_PATH",
248 "-DANDROID_LIB_PYTHON_PATH=\"internal/stdlib\"",
249 "-DDATE=\"Dec 31 1969\"",
250 "-DTIME=\"23:59:59\"",
251 ],
252 static_libs: [
253 "libbase",
254 "libexpat",
255 "libz",
256 ],
257 target: {
258 linux_glibc_x86_64: {
259 host_ldlibs: ["-lutil"],
260 },
Jack He5e983f02019-11-07 17:21:40 -0800261 linux: {
262 // Due to test infra limitations, Python native symbols are linked
263 // statically to py3-launcher(s). Hence, need this flag to export
264 // these symbols so that runtime imported native extensions can use
265 // them (e.g. PyBaseObject_Type)
266 ldflags: ["-Wl,--export-dynamic"],
267 },
Dan Willemsenb3614d22019-10-07 16:06:34 -0700268 darwin: {
269 host_ldlibs: [
270 "-framework SystemConfiguration",
271 "-framework CoreFoundation",
272 ],
273 },
274 host: {
Tom Cherryff869db2020-01-08 14:13:00 -0800275 static_libs: [
276 "libsqlite",
277 "liblog",
278 ],
Dan Willemsenb3614d22019-10-07 16:06:34 -0700279 },
Dan Willemsenb3614d22019-10-07 16:06:34 -0700280 android: {
Jack He5e983f02019-11-07 17:21:40 -0800281 shared_libs: [
282 // Use shared libsqlite for device side, otherwise
283 // the executable size will be really huge.
284 "libsqlite",
285 // Dependency from libbase
286 "liblog",
287 ],
Dan Willemsenb3614d22019-10-07 16:06:34 -0700288 },
289 },
290}
291
292cc_library_static {
293 name: "py3-launcher-lib",
294 defaults: ["py3-launcher-defaults"],
295 cflags: ["-DPy_BUILD_CORE"],
296 srcs: [
297 // Makefile.pre.in MODULE_OBJS
298 "Modules/getpath.c",
299 "Modules/main.c",
300 "Modules/gcmodule.c",
301
302 // Makefile.pre.in LIBRARY_OBJS_OMIT_FROZEN
303 "Modules/getbuildinfo.c",
304 ],
305 whole_static_libs: [
306 "py3-interp",
307 "py3-c-modules",
308 ],
309 target: {
310 android: {
311 srcs: ["android/bionic/config.c"],
312 },
313 linux_bionic: {
314 srcs: ["android/bionic/config.c"],
315 },
316 linux_glibc_x86_64: {
317 srcs: ["android/linux_x86_64/config.c"],
318 },
319 darwin: {
320 srcs: ["android/darwin_x86_64/config.c"],
321 },
Tom Cherryff869db2020-01-08 14:13:00 -0800322 },
Dan Willemsenb3614d22019-10-07 16:06:34 -0700323}
324
325cc_binary {
326 name: "py3-launcher",
327 defaults: ["py3-launcher-defaults"],
328 srcs: ["android/launcher_main.cpp"],
329 static_libs: ["py3-launcher-lib"],
330}
331
332cc_binary {
333 name: "py3-launcher-autorun",
334 defaults: ["py3-launcher-defaults"],
335 srcs: ["android/launcher_main.cpp"],
336 static_libs: ["py3-launcher-lib"],
337 cflags: ["-DANDROID_AUTORUN"],
338}
339
340python_binary_host {
341 name: "py3-cmd",
342 autorun: false,
343 version: {
344 py3: {
345 embedded_launcher: true,
346 },
347 },
348}
349
350// Enabled extension py3-c-modules.
351
352cc_library_static {
353 name: "py3-c-modules",
354 defaults: ["py3-interp-defaults"],
355 cflags: [
356 "-DPy_BUILD_CORE_BUILTIN",
357 "-DUSE_PYEXPAT_CAPI",
358 ],
359 static_libs: [
360 "libexpat",
361 "libz",
362 ],
363 target: {
364 android: {
365 srcs: [":py3-c-modules-bionic"],
366 },
367 linux_bionic: {
368 srcs: [":py3-c-modules-bionic"],
369 },
370 linux_glibc_x86_64: {
371 srcs: [":py3-c-modules-linux_x86_64"],
372 },
373 darwin: {
374 srcs: [":py3-c-modules-darwin_x86_64"],
375 },
Tom Cherryff869db2020-01-08 14:13:00 -0800376 },
Dan Willemsenb3614d22019-10-07 16:06:34 -0700377}