blob: f841dc9e9b2c68d8f92246904d8474e3fa7819e4 [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
Dan Willemsenb33c6902020-12-23 16:39:22 -080021soong_config_module_type {
22 name: "cpython3_cc_defaults",
23 module_type: "cc_defaults",
24 config_namespace: "cpython3",
25 bool_variables: ["force_build_host"],
26 properties: ["defaults"],
27}
28
29// By default, disable the source and use the prebuilts for host linux_glibc
30// and darwin. Overridden by cpython3-interp-force_build_host when
31// force_build_host is true (set on aosp-build-tools).
Dan Willemsenb3614d22019-10-07 16:06:34 -070032cc_defaults {
Dan Willemsenb33c6902020-12-23 16:39:22 -080033 name: "cpython3-interp-host-prebuilts",
34 defaults_visibility: ["//visibility:private"],
35 target: {
36 linux_glibc: {
37 enabled: false,
38 },
39 darwin: {
40 enabled: false,
41 },
42 },
43}
44
45cc_defaults {
46 name: "cpython3-interp-force_build_host",
47 defaults_visibility: ["//visibility:private"],
48 target: {
49 linux_glibc: {
50 enabled: true,
51 },
52 darwin: {
53 enabled: true,
54 },
55 },
56}
57
58cpython3_cc_defaults {
Dan Willemsenb3614d22019-10-07 16:06:34 -070059 name: "py3-interp-defaults",
Dan Willemsenb33c6902020-12-23 16:39:22 -080060 defaults_visibility: ["//visibility:private"],
Dan Willemsenb3614d22019-10-07 16:06:34 -070061 cflags: [
62 "-fwrapv",
63 "-O3",
64 "-Wall",
65 "-Wstrict-prototypes",
66 "-DPy_BUILD_CORE",
67 "-Werror",
68 "-Wno-invalid-source-encoding",
69 "-Wno-int-conversion",
70 "-Wno-missing-field-initializers",
71 "-Wno-null-pointer-arithmetic",
72 "-Wno-register",
73 "-Wno-shift-count-overflow",
74 "-Wno-sign-compare",
75 "-Wno-tautological-compare",
76 "-Wno-tautological-constant-out-of-range-compare",
77 "-Wno-unused-function",
78 "-Wno-unused-parameter",
79 "-Wno-unused-result",
80 ],
81 local_include_dirs: [
82 "Include",
83 "Include/internal",
84 ],
85 static_libs: ["libffi"],
86 target: {
87 android: {
88 local_include_dirs: ["android/bionic/pyconfig"],
89 },
90 android_arm: {
91 cflags: ["-DSOABI=\"cpython-38android-arm-android-bionic\""],
92 },
93 android_arm64: {
94 cflags: ["-DSOABI=\"cpython-38android-arm64-android-bionic\""],
95 },
96 android_x86: {
97 cflags: ["-DSOABI=\"cpython-38android-x86-android-bionic\""],
98 },
99 android_x86_64: {
100 cflags: ["-DSOABI=\"cpython-38android-x86_64-android-bionic\""],
101 },
Dan Willemsen6e345142020-12-16 19:03:07 -0800102 host: {
103 // Host builds are moving to prebuilts, which has a higher risk of
104 // having an incompatible libc++.so when installed.
105 stl: "libc++_static",
106 },
Dan Willemsenb3614d22019-10-07 16:06:34 -0700107 // Regenerate include dirs with android_regen.sh
108 darwin_x86_64: {
109 local_include_dirs: ["android/darwin_x86_64/pyconfig"],
110 cflags: [
111 "-Wno-deprecated-declarations",
112 "-Wno-pointer-arith",
113 "-DSOABI=\"cpython-38android-x86_64-darwin\"",
114 ],
115 },
116 linux_bionic: {
117 // NB linux_bionic is a 'host' architecture but it uses the bionic libc like 'android'
118 // targets so use the android pyconfig.
119 local_include_dirs: ["android/bionic/pyconfig"],
120 cflags: ["-DSOABI=\"cpython-38android-x86_64-linux-bionic\""],
121 },
122 linux_glibc_x86: {
123 enabled: false,
124 },
125 linux_glibc_x86_64: {
126 local_include_dirs: ["android/linux_x86_64/pyconfig"],
127 cflags: ["-DSOABI=\"cpython-38android-x86_64-linux-gnu\""],
128 },
129 windows: {
130 enabled: false,
131 },
132 },
133 host_supported: true,
134 compile_multilib: "both",
135 multilib: {
136 lib32: {
137 suffix: "32",
138 },
139 lib64: {
140 suffix: "64",
141 },
142 },
Dan Willemsenb33c6902020-12-23 16:39:22 -0800143 soong_config_variables: {
144 force_build_host: {
145 defaults: ["cpython3-interp-force_build_host"],
146 },
147 },
Dan Willemsenb3614d22019-10-07 16:06:34 -0700148}
149
150cc_library_static {
151 name: "py3-interp",
Dan Willemsenb33c6902020-12-23 16:39:22 -0800152 defaults: ["py3-interp-defaults", "cpython3-interp-host-prebuilts"],
Dan Willemsenb3614d22019-10-07 16:06:34 -0700153 cflags: ["-DPy_BUILD_CORE"],
154 srcs: [
155 // Makefile.pre.in PARSER_OBJS
156 "Parser/acceler.c",
157 "Parser/grammar1.c",
158 "Parser/listnode.c",
159 "Parser/myreadline.c",
160 "Parser/node.c",
161 "Parser/parser.c",
162 "Parser/parsetok.c",
163 "Parser/token.c",
164 "Parser/tokenizer.c",
165
166 // Makefile.pre.in OBJECT_OBJS
167 "Objects/abstract.c",
168 "Objects/accu.c",
169 "Objects/boolobject.c",
170 "Objects/bytes_methods.c",
171 "Objects/bytearrayobject.c",
172 "Objects/bytesobject.c",
173 "Objects/call.c",
174 "Objects/capsule.c",
175 "Objects/cellobject.c",
176 "Objects/classobject.c",
177 "Objects/codeobject.c",
178 "Objects/complexobject.c",
179 "Objects/descrobject.c",
180 "Objects/enumobject.c",
181 "Objects/exceptions.c",
182 "Objects/genobject.c",
183 "Objects/fileobject.c",
184 "Objects/floatobject.c",
185 "Objects/frameobject.c",
186 "Objects/funcobject.c",
187 "Objects/interpreteridobject.c",
188 "Objects/iterobject.c",
189 "Objects/listobject.c",
190 "Objects/longobject.c",
191 "Objects/dictobject.c",
192 "Objects/odictobject.c",
193 "Objects/memoryobject.c",
194 "Objects/methodobject.c",
195 "Objects/moduleobject.c",
196 "Objects/namespaceobject.c",
197 "Objects/object.c",
198 "Objects/obmalloc.c",
199 "Objects/picklebufobject.c",
200 "Objects/rangeobject.c",
201 "Objects/setobject.c",
202 "Objects/sliceobject.c",
203 "Objects/structseq.c",
204 "Objects/tupleobject.c",
205 "Objects/typeobject.c",
206 "Objects/unicodeobject.c",
207 "Objects/unicodectype.c",
208 "Objects/weakrefobject.c",
209
210 // Makefile.pre.in PYTHON_OBJS
211 "Python/_warnings.c",
212 "Python/Python-ast.c",
213 "Python/asdl.c",
214 "Python/ast.c",
215 "Python/ast_opt.c",
216 "Python/ast_unparse.c",
217 "Python/bltinmodule.c",
218 "Python/ceval.c",
219 "Python/codecs.c",
220 "Python/compile.c",
221 "Python/context.c",
222 "Python/dynamic_annotations.c",
223 "Python/errors.c",
224 "Python/frozen.c",
225 "Python/frozenmain.c",
226 "Python/future.c",
227 "Python/getargs.c",
228 "Python/getcompiler.c",
229 "Python/getcopyright.c",
230 "Python/getplatform.c",
231 "Python/getversion.c",
232 "Python/graminit.c",
233 "Python/hamt.c",
234 "Python/import.c",
235 "Python/importdl.c",
236 "Python/initconfig.c",
237 "Python/marshal.c",
238 "Python/modsupport.c",
239 "Python/mysnprintf.c",
240 "Python/mystrtoul.c",
241 "Python/pathconfig.c",
242 "Python/peephole.c",
243 "Python/preconfig.c",
244 "Python/pyarena.c",
245 "Python/pyctype.c",
246 "Python/pyfpe.c",
247 "Python/pyhash.c",
248 "Python/pylifecycle.c",
249 "Python/pymath.c",
250 "Python/pystate.c",
251 "Python/pythonrun.c",
252 "Python/pytime.c",
253 "Python/bootstrap_hash.c",
254 "Python/structmember.c",
255 "Python/symtable.c",
256 "Python/sysmodule.c",
257 "Python/thread.c",
258 "Python/traceback.c",
259 "Python/getopt.c",
260 "Python/pystrcmp.c",
261 "Python/pystrtod.c",
262 "Python/pystrhex.c",
263 "Python/dtoa.c",
264 "Python/formatter_unicode.c",
265 "Python/fileutils.c",
266 "Python/dynload_shlib.c",
267 ],
268
269 target: {
270 linux: {
271 cflags: [
Luca Stefani9d70c2b2020-08-24 14:25:20 +0200272 "-DPLATFORM=\"linux\"",
Luca Stefanib9c5ed92020-08-24 15:05:00 +0200273 "-DABIFLAGS=\"\"",
Dan Willemsenb3614d22019-10-07 16:06:34 -0700274 ],
275 },
276 darwin_x86_64: {
277 cflags: [
278 "-DPLATFORM=\"darwin\"",
Luca Stefanib9c5ed92020-08-24 15:05:00 +0200279 "-DABIFLAGS=\"\"",
Dan Willemsenb3614d22019-10-07 16:06:34 -0700280 ],
281 },
282 },
283}
284
285cc_defaults {
286 name: "py3-launcher-defaults",
Dan Willemsenb33c6902020-12-23 16:39:22 -0800287 defaults: ["py3-interp-defaults", "cpython3-interp-host-prebuilts"],
Dan Willemsenb3614d22019-10-07 16:06:34 -0700288 cflags: [
289 "-DVERSION=\"3.8\"",
290 "-DVPATH=\"\"",
291 "-DPREFIX=\"\"",
292 "-DEXEC_PREFIX=\"\"",
293 "-DPYTHONPATH=\"..:\"",
294 "-DANDROID_SKIP_ZIP_PATH",
295 "-DANDROID_SKIP_EXEC_PREFIX_PATH",
296 "-DANDROID_LIB_PYTHON_PATH=\"internal/stdlib\"",
297 "-DDATE=\"Dec 31 1969\"",
298 "-DTIME=\"23:59:59\"",
299 ],
300 static_libs: [
301 "libbase",
302 "libexpat",
303 "libz",
304 ],
305 target: {
306 linux_glibc_x86_64: {
307 host_ldlibs: ["-lutil"],
Dan Willemsene6b5c0a2020-12-11 14:16:07 -0800308 static_libs: [
309 "libopenssl_ssl",
310 "libopenssl_crypto",
311 ],
Dan Willemsenb3614d22019-10-07 16:06:34 -0700312 },
Jack He5e983f02019-11-07 17:21:40 -0800313 linux: {
314 // Due to test infra limitations, Python native symbols are linked
315 // statically to py3-launcher(s). Hence, need this flag to export
316 // these symbols so that runtime imported native extensions can use
317 // them (e.g. PyBaseObject_Type)
318 ldflags: ["-Wl,--export-dynamic"],
319 },
Dan Willemsenb3614d22019-10-07 16:06:34 -0700320 darwin: {
321 host_ldlibs: [
322 "-framework SystemConfiguration",
323 "-framework CoreFoundation",
324 ],
Dan Willemsene6b5c0a2020-12-11 14:16:07 -0800325 static_libs: [
326 "libopenssl_ssl",
327 "libopenssl_crypto",
328 ],
Dan Willemsenb3614d22019-10-07 16:06:34 -0700329 },
330 host: {
Tom Cherryff869db2020-01-08 14:13:00 -0800331 static_libs: [
332 "libsqlite",
333 "liblog",
334 ],
Dan Willemsenb3614d22019-10-07 16:06:34 -0700335 },
Dan Willemsenb3614d22019-10-07 16:06:34 -0700336 android: {
Jack He5e983f02019-11-07 17:21:40 -0800337 shared_libs: [
338 // Use shared libsqlite for device side, otherwise
339 // the executable size will be really huge.
340 "libsqlite",
341 // Dependency from libbase
342 "liblog",
343 ],
Dan Willemsenb3614d22019-10-07 16:06:34 -0700344 },
345 },
346}
347
348cc_library_static {
349 name: "py3-launcher-lib",
350 defaults: ["py3-launcher-defaults"],
351 cflags: ["-DPy_BUILD_CORE"],
352 srcs: [
353 // Makefile.pre.in MODULE_OBJS
354 "Modules/getpath.c",
355 "Modules/main.c",
356 "Modules/gcmodule.c",
357
358 // Makefile.pre.in LIBRARY_OBJS_OMIT_FROZEN
359 "Modules/getbuildinfo.c",
360 ],
361 whole_static_libs: [
362 "py3-interp",
363 "py3-c-modules",
364 ],
365 target: {
366 android: {
367 srcs: ["android/bionic/config.c"],
368 },
369 linux_bionic: {
370 srcs: ["android/bionic/config.c"],
371 },
372 linux_glibc_x86_64: {
373 srcs: ["android/linux_x86_64/config.c"],
374 },
375 darwin: {
376 srcs: ["android/darwin_x86_64/config.c"],
377 },
Tom Cherryff869db2020-01-08 14:13:00 -0800378 },
Dan Willemsenb3614d22019-10-07 16:06:34 -0700379}
380
381cc_binary {
382 name: "py3-launcher",
383 defaults: ["py3-launcher-defaults"],
384 srcs: ["android/launcher_main.cpp"],
385 static_libs: ["py3-launcher-lib"],
386}
387
388cc_binary {
389 name: "py3-launcher-autorun",
390 defaults: ["py3-launcher-defaults"],
391 srcs: ["android/launcher_main.cpp"],
392 static_libs: ["py3-launcher-lib"],
393 cflags: ["-DANDROID_AUTORUN"],
394}
395
396python_binary_host {
397 name: "py3-cmd",
398 autorun: false,
399 version: {
400 py3: {
401 embedded_launcher: true,
402 },
403 },
404}
405
406// Enabled extension py3-c-modules.
407
408cc_library_static {
409 name: "py3-c-modules",
Dan Willemsenb33c6902020-12-23 16:39:22 -0800410 defaults: ["py3-interp-defaults", "cpython3-interp-host-prebuilts"],
Dan Willemsenb3614d22019-10-07 16:06:34 -0700411 cflags: [
412 "-DPy_BUILD_CORE_BUILTIN",
413 "-DUSE_PYEXPAT_CAPI",
414 ],
415 static_libs: [
416 "libexpat",
417 "libz",
418 ],
419 target: {
420 android: {
421 srcs: [":py3-c-modules-bionic"],
422 },
423 linux_bionic: {
424 srcs: [":py3-c-modules-bionic"],
425 },
426 linux_glibc_x86_64: {
427 srcs: [":py3-c-modules-linux_x86_64"],
Dan Willemsene6b5c0a2020-12-11 14:16:07 -0800428 static_libs: [
429 "libopenssl_ssl",
430 "libopenssl_crypto",
431 ],
Dan Willemsenb3614d22019-10-07 16:06:34 -0700432 },
433 darwin: {
434 srcs: [":py3-c-modules-darwin_x86_64"],
Dan Willemsene6b5c0a2020-12-11 14:16:07 -0800435 static_libs: [
436 "libopenssl_ssl",
437 "libopenssl_crypto",
438 ],
Dan Willemsenb3614d22019-10-07 16:06:34 -0700439 },
Tom Cherryff869db2020-01-08 14:13:00 -0800440 },
Dan Willemsenb3614d22019-10-07 16:06:34 -0700441}