blob: a2bb2b35edc8d59e1a4c37aec8b9f424e4344cd4 [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: {
Haibo Huang717117f2021-01-25 15:24:19 -080091 cflags: ["-DSOABI=\"cpython-39android-arm-android-bionic\""],
Dan Willemsenb3614d22019-10-07 16:06:34 -070092 },
93 android_arm64: {
Haibo Huang717117f2021-01-25 15:24:19 -080094 cflags: ["-DSOABI=\"cpython-39android-arm64-android-bionic\""],
Dan Willemsenb3614d22019-10-07 16:06:34 -070095 },
96 android_x86: {
Haibo Huang717117f2021-01-25 15:24:19 -080097 cflags: ["-DSOABI=\"cpython-39android-x86-android-bionic\""],
Dan Willemsenb3614d22019-10-07 16:06:34 -070098 },
99 android_x86_64: {
Haibo Huang717117f2021-01-25 15:24:19 -0800100 cflags: ["-DSOABI=\"cpython-39android-x86_64-android-bionic\""],
Dan Willemsenb3614d22019-10-07 16:06:34 -0700101 },
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",
Haibo Huang717117f2021-01-25 15:24:19 -0800113 "-DSOABI=\"cpython-39android-x86_64-darwin\"",
Dan Willemsenb3614d22019-10-07 16:06:34 -0700114 ],
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"],
Haibo Huang717117f2021-01-25 15:24:19 -0800120 cflags: ["-DSOABI=\"cpython-39android-x86_64-linux-bionic\""],
Dan Willemsenb3614d22019-10-07 16:06:34 -0700121 },
122 linux_glibc_x86: {
123 enabled: false,
124 },
125 linux_glibc_x86_64: {
126 local_include_dirs: ["android/linux_x86_64/pyconfig"],
Haibo Huang717117f2021-01-25 15:24:19 -0800127 cflags: ["-DSOABI=\"cpython-39android-x86_64-linux-gnu\""],
Dan Willemsenb3614d22019-10-07 16:06:34 -0700128 },
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"],
Haibo Huang5bb95e92021-01-14 11:35:14 -0800153 cflags: ["-DPy_BUILD_CORE", "-DPLATLIBDIR=\"lib\""],
Dan Willemsenb3614d22019-10-07 16:06:34 -0700154 srcs: [
Haibo Huang5bb95e92021-01-14 11:35:14 -0800155 // Makefile.pre.in PEGEN_OBJS
156 "Parser/pegen/pegen.c",
157 "Parser/pegen/parse.c",
158 "Parser/pegen/parse_string.c",
159 "Parser/pegen/peg_api.c",
160
Dan Willemsenb3614d22019-10-07 16:06:34 -0700161 // Makefile.pre.in PARSER_OBJS
162 "Parser/acceler.c",
163 "Parser/grammar1.c",
164 "Parser/listnode.c",
165 "Parser/myreadline.c",
166 "Parser/node.c",
167 "Parser/parser.c",
168 "Parser/parsetok.c",
169 "Parser/token.c",
170 "Parser/tokenizer.c",
171
172 // Makefile.pre.in OBJECT_OBJS
173 "Objects/abstract.c",
174 "Objects/accu.c",
175 "Objects/boolobject.c",
176 "Objects/bytes_methods.c",
177 "Objects/bytearrayobject.c",
178 "Objects/bytesobject.c",
179 "Objects/call.c",
180 "Objects/capsule.c",
181 "Objects/cellobject.c",
182 "Objects/classobject.c",
183 "Objects/codeobject.c",
184 "Objects/complexobject.c",
185 "Objects/descrobject.c",
186 "Objects/enumobject.c",
187 "Objects/exceptions.c",
Haibo Huang5bb95e92021-01-14 11:35:14 -0800188 "Objects/genericaliasobject.c",
Dan Willemsenb3614d22019-10-07 16:06:34 -0700189 "Objects/genobject.c",
190 "Objects/fileobject.c",
191 "Objects/floatobject.c",
192 "Objects/frameobject.c",
193 "Objects/funcobject.c",
194 "Objects/interpreteridobject.c",
195 "Objects/iterobject.c",
196 "Objects/listobject.c",
197 "Objects/longobject.c",
198 "Objects/dictobject.c",
199 "Objects/odictobject.c",
200 "Objects/memoryobject.c",
201 "Objects/methodobject.c",
202 "Objects/moduleobject.c",
203 "Objects/namespaceobject.c",
204 "Objects/object.c",
205 "Objects/obmalloc.c",
206 "Objects/picklebufobject.c",
207 "Objects/rangeobject.c",
208 "Objects/setobject.c",
209 "Objects/sliceobject.c",
210 "Objects/structseq.c",
211 "Objects/tupleobject.c",
212 "Objects/typeobject.c",
213 "Objects/unicodeobject.c",
214 "Objects/unicodectype.c",
215 "Objects/weakrefobject.c",
216
217 // Makefile.pre.in PYTHON_OBJS
218 "Python/_warnings.c",
219 "Python/Python-ast.c",
220 "Python/asdl.c",
221 "Python/ast.c",
222 "Python/ast_opt.c",
223 "Python/ast_unparse.c",
224 "Python/bltinmodule.c",
225 "Python/ceval.c",
226 "Python/codecs.c",
227 "Python/compile.c",
228 "Python/context.c",
229 "Python/dynamic_annotations.c",
230 "Python/errors.c",
231 "Python/frozen.c",
232 "Python/frozenmain.c",
233 "Python/future.c",
234 "Python/getargs.c",
235 "Python/getcompiler.c",
236 "Python/getcopyright.c",
237 "Python/getplatform.c",
238 "Python/getversion.c",
239 "Python/graminit.c",
240 "Python/hamt.c",
Haibo Huang5bb95e92021-01-14 11:35:14 -0800241 "Python/hashtable.c",
Dan Willemsenb3614d22019-10-07 16:06:34 -0700242 "Python/import.c",
243 "Python/importdl.c",
244 "Python/initconfig.c",
245 "Python/marshal.c",
246 "Python/modsupport.c",
247 "Python/mysnprintf.c",
248 "Python/mystrtoul.c",
249 "Python/pathconfig.c",
250 "Python/peephole.c",
251 "Python/preconfig.c",
252 "Python/pyarena.c",
253 "Python/pyctype.c",
254 "Python/pyfpe.c",
255 "Python/pyhash.c",
256 "Python/pylifecycle.c",
257 "Python/pymath.c",
258 "Python/pystate.c",
259 "Python/pythonrun.c",
260 "Python/pytime.c",
261 "Python/bootstrap_hash.c",
262 "Python/structmember.c",
263 "Python/symtable.c",
264 "Python/sysmodule.c",
265 "Python/thread.c",
266 "Python/traceback.c",
267 "Python/getopt.c",
268 "Python/pystrcmp.c",
269 "Python/pystrtod.c",
270 "Python/pystrhex.c",
271 "Python/dtoa.c",
272 "Python/formatter_unicode.c",
273 "Python/fileutils.c",
274 "Python/dynload_shlib.c",
275 ],
276
277 target: {
278 linux: {
279 cflags: [
Luca Stefani9d70c2b2020-08-24 14:25:20 +0200280 "-DPLATFORM=\"linux\"",
Luca Stefanib9c5ed92020-08-24 15:05:00 +0200281 "-DABIFLAGS=\"\"",
Dan Willemsenb3614d22019-10-07 16:06:34 -0700282 ],
283 },
284 darwin_x86_64: {
285 cflags: [
286 "-DPLATFORM=\"darwin\"",
Luca Stefanib9c5ed92020-08-24 15:05:00 +0200287 "-DABIFLAGS=\"\"",
Dan Willemsenb3614d22019-10-07 16:06:34 -0700288 ],
289 },
290 },
291}
292
293cc_defaults {
294 name: "py3-launcher-defaults",
Dan Willemsenb33c6902020-12-23 16:39:22 -0800295 defaults: ["py3-interp-defaults", "cpython3-interp-host-prebuilts"],
Dan Willemsenb3614d22019-10-07 16:06:34 -0700296 cflags: [
297 "-DVERSION=\"3.8\"",
298 "-DVPATH=\"\"",
299 "-DPREFIX=\"\"",
300 "-DEXEC_PREFIX=\"\"",
301 "-DPYTHONPATH=\"..:\"",
302 "-DANDROID_SKIP_ZIP_PATH",
303 "-DANDROID_SKIP_EXEC_PREFIX_PATH",
304 "-DANDROID_LIB_PYTHON_PATH=\"internal/stdlib\"",
305 "-DDATE=\"Dec 31 1969\"",
306 "-DTIME=\"23:59:59\"",
307 ],
308 static_libs: [
309 "libbase",
310 "libexpat",
311 "libz",
312 ],
313 target: {
314 linux_glibc_x86_64: {
315 host_ldlibs: ["-lutil"],
Dan Willemsene6b5c0a2020-12-11 14:16:07 -0800316 static_libs: [
317 "libopenssl_ssl",
318 "libopenssl_crypto",
319 ],
Dan Willemsenb3614d22019-10-07 16:06:34 -0700320 },
Jack He5e983f02019-11-07 17:21:40 -0800321 linux: {
322 // Due to test infra limitations, Python native symbols are linked
323 // statically to py3-launcher(s). Hence, need this flag to export
324 // these symbols so that runtime imported native extensions can use
325 // them (e.g. PyBaseObject_Type)
326 ldflags: ["-Wl,--export-dynamic"],
327 },
Dan Willemsenb3614d22019-10-07 16:06:34 -0700328 darwin: {
329 host_ldlibs: [
330 "-framework SystemConfiguration",
331 "-framework CoreFoundation",
332 ],
Dan Willemsene6b5c0a2020-12-11 14:16:07 -0800333 static_libs: [
334 "libopenssl_ssl",
335 "libopenssl_crypto",
336 ],
Dan Willemsenb3614d22019-10-07 16:06:34 -0700337 },
338 host: {
Tom Cherryff869db2020-01-08 14:13:00 -0800339 static_libs: [
340 "libsqlite",
341 "liblog",
342 ],
Dan Willemsenb3614d22019-10-07 16:06:34 -0700343 },
Dan Willemsenb3614d22019-10-07 16:06:34 -0700344 android: {
Jack He5e983f02019-11-07 17:21:40 -0800345 shared_libs: [
346 // Use shared libsqlite for device side, otherwise
347 // the executable size will be really huge.
348 "libsqlite",
349 // Dependency from libbase
350 "liblog",
351 ],
Dan Willemsenb3614d22019-10-07 16:06:34 -0700352 },
353 },
354}
355
356cc_library_static {
357 name: "py3-launcher-lib",
358 defaults: ["py3-launcher-defaults"],
359 cflags: ["-DPy_BUILD_CORE"],
360 srcs: [
361 // Makefile.pre.in MODULE_OBJS
362 "Modules/getpath.c",
363 "Modules/main.c",
364 "Modules/gcmodule.c",
365
366 // Makefile.pre.in LIBRARY_OBJS_OMIT_FROZEN
367 "Modules/getbuildinfo.c",
368 ],
369 whole_static_libs: [
370 "py3-interp",
371 "py3-c-modules",
372 ],
373 target: {
374 android: {
375 srcs: ["android/bionic/config.c"],
376 },
377 linux_bionic: {
378 srcs: ["android/bionic/config.c"],
379 },
380 linux_glibc_x86_64: {
381 srcs: ["android/linux_x86_64/config.c"],
382 },
383 darwin: {
384 srcs: ["android/darwin_x86_64/config.c"],
385 },
Tom Cherryff869db2020-01-08 14:13:00 -0800386 },
Dan Willemsenb3614d22019-10-07 16:06:34 -0700387}
388
389cc_binary {
390 name: "py3-launcher",
391 defaults: ["py3-launcher-defaults"],
392 srcs: ["android/launcher_main.cpp"],
393 static_libs: ["py3-launcher-lib"],
394}
395
396cc_binary {
397 name: "py3-launcher-autorun",
398 defaults: ["py3-launcher-defaults"],
399 srcs: ["android/launcher_main.cpp"],
400 static_libs: ["py3-launcher-lib"],
401 cflags: ["-DANDROID_AUTORUN"],
402}
403
404python_binary_host {
405 name: "py3-cmd",
406 autorun: false,
407 version: {
408 py3: {
409 embedded_launcher: true,
410 },
411 },
412}
413
414// Enabled extension py3-c-modules.
415
416cc_library_static {
417 name: "py3-c-modules",
Dan Willemsenb33c6902020-12-23 16:39:22 -0800418 defaults: ["py3-interp-defaults", "cpython3-interp-host-prebuilts"],
Dan Willemsenb3614d22019-10-07 16:06:34 -0700419 cflags: [
420 "-DPy_BUILD_CORE_BUILTIN",
421 "-DUSE_PYEXPAT_CAPI",
422 ],
423 static_libs: [
424 "libexpat",
425 "libz",
426 ],
427 target: {
428 android: {
429 srcs: [":py3-c-modules-bionic"],
430 },
431 linux_bionic: {
432 srcs: [":py3-c-modules-bionic"],
433 },
434 linux_glibc_x86_64: {
435 srcs: [":py3-c-modules-linux_x86_64"],
Dan Willemsene6b5c0a2020-12-11 14:16:07 -0800436 static_libs: [
437 "libopenssl_ssl",
438 "libopenssl_crypto",
439 ],
Dan Willemsenb3614d22019-10-07 16:06:34 -0700440 },
441 darwin: {
442 srcs: [":py3-c-modules-darwin_x86_64"],
Dan Willemsene6b5c0a2020-12-11 14:16:07 -0800443 static_libs: [
444 "libopenssl_ssl",
445 "libopenssl_crypto",
446 ],
Dan Willemsenb3614d22019-10-07 16:06:34 -0700447 },
Tom Cherryff869db2020-01-08 14:13:00 -0800448 },
Dan Willemsenb3614d22019-10-07 16:06:34 -0700449}