blob: 209f4e7fc83d8b3c8be99c3a93964854b1b5a257 [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
Bob Badour5f197c62021-03-08 11:42:11 -080015// *** THIS PACKAGE HAS SPECIAL LICENSING CONDITIONS. PLEASE
16// CONSULT THE OWNERS AND opensource-licensing@google.com BEFORE
17// DEPENDING ON IT IN YOUR PROJECT. ***
18package {
19 default_applicable_licenses: ["external_python_cpython3_license"],
20}
21
22// Added automatically by a large-scale-change that took the approach of
23// 'apply every license found to every target'. While this makes sure we respect
24// every license restriction, it may not be entirely correct.
25//
26// e.g. GPL in an MIT project might only apply to the contrib/ directory.
27//
28// Please consider splitting the single license below into multiple licenses,
29// taking care not to lose any license_kind information, and overriding the
30// default license using the 'licenses: [...]' property on targets as needed.
31//
32// For unused files, consider creating a 'fileGroup' with "//visibility:private"
33// to attach the license to, and including a comment whether the files may be
34// used in the current project.
35// See: http://go/android-license-faq
36license {
37 name: "external_python_cpython3_license",
38 visibility: [":__subpackages__"],
39 license_kinds: [
40 "SPDX-license-identifier-0BSD",
41 "SPDX-license-identifier-Apache-2.0",
42 "SPDX-license-identifier-BSD",
43 "SPDX-license-identifier-CC0-1.0",
44 "SPDX-license-identifier-GPL",
45 "SPDX-license-identifier-MIT",
46 "SPDX-license-identifier-MS-RL", // by exception only
47 "SPDX-license-identifier-PSF-2.0",
48 "SPDX-license-identifier-Unicode-DFS",
49 "SPDX-license-identifier-W3C",
50 "SPDX-license-identifier-Zlib",
51 "legacy_by_exception_only", // by exception only
52 "legacy_notice",
53 "legacy_unencumbered",
54 ],
55 license_text: [
56 "LICENSE",
57 ],
58}
59
Tom Cherryff869db2020-01-08 14:13:00 -080060build = [
61 "Android-bionic.bp",
62 "Android-linux_x86_64.bp",
63 "Android-darwin_x86_64.bp",
64]
Dan Willemsenb3614d22019-10-07 16:06:34 -070065
Dan Willemsenb33c6902020-12-23 16:39:22 -080066soong_config_module_type {
67 name: "cpython3_cc_defaults",
68 module_type: "cc_defaults",
69 config_namespace: "cpython3",
70 bool_variables: ["force_build_host"],
71 properties: ["defaults"],
72}
73
Colin Cross70204152022-03-08 15:12:48 -080074// By default, disable the source and use the prebuilts for host linux
Dan Willemsenb33c6902020-12-23 16:39:22 -080075// and darwin. Overridden by cpython3-interp-force_build_host when
76// force_build_host is true (set on aosp-build-tools).
Dan Willemsenb3614d22019-10-07 16:06:34 -070077cc_defaults {
Dan Willemsenb33c6902020-12-23 16:39:22 -080078 name: "cpython3-interp-host-prebuilts",
79 defaults_visibility: ["//visibility:private"],
80 target: {
81 linux_glibc: {
82 enabled: false,
83 },
Colin Cross70204152022-03-08 15:12:48 -080084 linux_musl: {
85 enabled: false,
86 },
Dan Willemsenb33c6902020-12-23 16:39:22 -080087 darwin: {
88 enabled: false,
89 },
90 },
91}
92
93cc_defaults {
94 name: "cpython3-interp-force_build_host",
95 defaults_visibility: ["//visibility:private"],
96 target: {
97 linux_glibc: {
98 enabled: true,
99 },
Colin Cross70204152022-03-08 15:12:48 -0800100 linux_musl: {
101 enabled: true,
102 },
Dan Willemsenb33c6902020-12-23 16:39:22 -0800103 darwin: {
104 enabled: true,
105 },
106 },
107}
108
109cpython3_cc_defaults {
Dan Willemsenb3614d22019-10-07 16:06:34 -0700110 name: "py3-interp-defaults",
Dan Willemsenb33c6902020-12-23 16:39:22 -0800111 defaults_visibility: ["//visibility:private"],
Dan Willemsenb3614d22019-10-07 16:06:34 -0700112 cflags: [
113 "-fwrapv",
114 "-O3",
115 "-Wall",
116 "-Wstrict-prototypes",
117 "-DPy_BUILD_CORE",
118 "-Werror",
119 "-Wno-invalid-source-encoding",
120 "-Wno-int-conversion",
121 "-Wno-missing-field-initializers",
122 "-Wno-null-pointer-arithmetic",
123 "-Wno-register",
124 "-Wno-shift-count-overflow",
125 "-Wno-sign-compare",
126 "-Wno-tautological-compare",
127 "-Wno-tautological-constant-out-of-range-compare",
128 "-Wno-unused-function",
129 "-Wno-unused-parameter",
130 "-Wno-unused-result",
131 ],
132 local_include_dirs: [
133 "Include",
134 "Include/internal",
135 ],
136 static_libs: ["libffi"],
137 target: {
138 android: {
139 local_include_dirs: ["android/bionic/pyconfig"],
140 },
141 android_arm: {
Haibo Huang717117f2021-01-25 15:24:19 -0800142 cflags: ["-DSOABI=\"cpython-39android-arm-android-bionic\""],
Dan Willemsenb3614d22019-10-07 16:06:34 -0700143 },
144 android_arm64: {
Haibo Huang717117f2021-01-25 15:24:19 -0800145 cflags: ["-DSOABI=\"cpython-39android-arm64-android-bionic\""],
Dan Willemsenb3614d22019-10-07 16:06:34 -0700146 },
147 android_x86: {
Haibo Huang717117f2021-01-25 15:24:19 -0800148 cflags: ["-DSOABI=\"cpython-39android-x86-android-bionic\""],
Dan Willemsenb3614d22019-10-07 16:06:34 -0700149 },
150 android_x86_64: {
Haibo Huang717117f2021-01-25 15:24:19 -0800151 cflags: ["-DSOABI=\"cpython-39android-x86_64-android-bionic\""],
Dan Willemsenb3614d22019-10-07 16:06:34 -0700152 },
Dan Willemsen6e345142020-12-16 19:03:07 -0800153 host: {
154 // Host builds are moving to prebuilts, which has a higher risk of
155 // having an incompatible libc++.so when installed.
156 stl: "libc++_static",
157 },
Dan Willemsenb3614d22019-10-07 16:06:34 -0700158 // Regenerate include dirs with android_regen.sh
159 darwin_x86_64: {
160 local_include_dirs: ["android/darwin_x86_64/pyconfig"],
161 cflags: [
162 "-Wno-deprecated-declarations",
163 "-Wno-pointer-arith",
Haibo Huang717117f2021-01-25 15:24:19 -0800164 "-DSOABI=\"cpython-39android-x86_64-darwin\"",
Dan Willemsenb3614d22019-10-07 16:06:34 -0700165 ],
166 },
167 linux_bionic: {
168 // NB linux_bionic is a 'host' architecture but it uses the bionic libc like 'android'
169 // targets so use the android pyconfig.
170 local_include_dirs: ["android/bionic/pyconfig"],
Haibo Huang717117f2021-01-25 15:24:19 -0800171 cflags: ["-DSOABI=\"cpython-39android-x86_64-linux-bionic\""],
Dan Willemsenb3614d22019-10-07 16:06:34 -0700172 },
173 linux_glibc_x86: {
174 enabled: false,
175 },
Colin Cross70204152022-03-08 15:12:48 -0800176 linux_musl_x86: {
177 enabled: false,
178 },
Dan Willemsenb3614d22019-10-07 16:06:34 -0700179 linux_glibc_x86_64: {
180 local_include_dirs: ["android/linux_x86_64/pyconfig"],
Haibo Huang717117f2021-01-25 15:24:19 -0800181 cflags: ["-DSOABI=\"cpython-39android-x86_64-linux-gnu\""],
Dan Willemsenb3614d22019-10-07 16:06:34 -0700182 },
Colin Cross70204152022-03-08 15:12:48 -0800183 linux_musl_x86_64: {
184 local_include_dirs: ["android/linux_x86_64/pyconfig"],
185 cflags: ["-DSOABI=\"cpython-39android-x86_64-linux-gnu\""],
186 },
Dan Willemsenb3614d22019-10-07 16:06:34 -0700187 windows: {
188 enabled: false,
189 },
190 },
191 host_supported: true,
192 compile_multilib: "both",
193 multilib: {
194 lib32: {
195 suffix: "32",
196 },
197 lib64: {
198 suffix: "64",
199 },
200 },
Dan Willemsenb33c6902020-12-23 16:39:22 -0800201 soong_config_variables: {
202 force_build_host: {
203 defaults: ["cpython3-interp-force_build_host"],
204 },
205 },
Dan Willemsenb3614d22019-10-07 16:06:34 -0700206}
207
208cc_library_static {
209 name: "py3-interp",
Dan Willemsenb33c6902020-12-23 16:39:22 -0800210 defaults: ["py3-interp-defaults", "cpython3-interp-host-prebuilts"],
Haibo Huang5bb95e92021-01-14 11:35:14 -0800211 cflags: ["-DPy_BUILD_CORE", "-DPLATLIBDIR=\"lib\""],
Dan Willemsenb3614d22019-10-07 16:06:34 -0700212 srcs: [
Haibo Huang5bb95e92021-01-14 11:35:14 -0800213 // Makefile.pre.in PEGEN_OBJS
214 "Parser/pegen/pegen.c",
215 "Parser/pegen/parse.c",
216 "Parser/pegen/parse_string.c",
217 "Parser/pegen/peg_api.c",
218
Dan Willemsenb3614d22019-10-07 16:06:34 -0700219 // Makefile.pre.in PARSER_OBJS
220 "Parser/acceler.c",
221 "Parser/grammar1.c",
222 "Parser/listnode.c",
223 "Parser/myreadline.c",
224 "Parser/node.c",
225 "Parser/parser.c",
226 "Parser/parsetok.c",
227 "Parser/token.c",
228 "Parser/tokenizer.c",
229
230 // Makefile.pre.in OBJECT_OBJS
231 "Objects/abstract.c",
232 "Objects/accu.c",
233 "Objects/boolobject.c",
234 "Objects/bytes_methods.c",
235 "Objects/bytearrayobject.c",
236 "Objects/bytesobject.c",
237 "Objects/call.c",
238 "Objects/capsule.c",
239 "Objects/cellobject.c",
240 "Objects/classobject.c",
241 "Objects/codeobject.c",
242 "Objects/complexobject.c",
243 "Objects/descrobject.c",
244 "Objects/enumobject.c",
245 "Objects/exceptions.c",
Haibo Huang5bb95e92021-01-14 11:35:14 -0800246 "Objects/genericaliasobject.c",
Dan Willemsenb3614d22019-10-07 16:06:34 -0700247 "Objects/genobject.c",
248 "Objects/fileobject.c",
249 "Objects/floatobject.c",
250 "Objects/frameobject.c",
251 "Objects/funcobject.c",
252 "Objects/interpreteridobject.c",
253 "Objects/iterobject.c",
254 "Objects/listobject.c",
255 "Objects/longobject.c",
256 "Objects/dictobject.c",
257 "Objects/odictobject.c",
258 "Objects/memoryobject.c",
259 "Objects/methodobject.c",
260 "Objects/moduleobject.c",
261 "Objects/namespaceobject.c",
262 "Objects/object.c",
263 "Objects/obmalloc.c",
264 "Objects/picklebufobject.c",
265 "Objects/rangeobject.c",
266 "Objects/setobject.c",
267 "Objects/sliceobject.c",
268 "Objects/structseq.c",
269 "Objects/tupleobject.c",
270 "Objects/typeobject.c",
271 "Objects/unicodeobject.c",
272 "Objects/unicodectype.c",
273 "Objects/weakrefobject.c",
274
275 // Makefile.pre.in PYTHON_OBJS
276 "Python/_warnings.c",
277 "Python/Python-ast.c",
278 "Python/asdl.c",
279 "Python/ast.c",
280 "Python/ast_opt.c",
281 "Python/ast_unparse.c",
282 "Python/bltinmodule.c",
283 "Python/ceval.c",
284 "Python/codecs.c",
285 "Python/compile.c",
286 "Python/context.c",
287 "Python/dynamic_annotations.c",
288 "Python/errors.c",
289 "Python/frozen.c",
290 "Python/frozenmain.c",
291 "Python/future.c",
292 "Python/getargs.c",
293 "Python/getcompiler.c",
294 "Python/getcopyright.c",
295 "Python/getplatform.c",
296 "Python/getversion.c",
297 "Python/graminit.c",
298 "Python/hamt.c",
Haibo Huang5bb95e92021-01-14 11:35:14 -0800299 "Python/hashtable.c",
Dan Willemsenb3614d22019-10-07 16:06:34 -0700300 "Python/import.c",
301 "Python/importdl.c",
302 "Python/initconfig.c",
303 "Python/marshal.c",
304 "Python/modsupport.c",
305 "Python/mysnprintf.c",
306 "Python/mystrtoul.c",
307 "Python/pathconfig.c",
308 "Python/peephole.c",
309 "Python/preconfig.c",
310 "Python/pyarena.c",
311 "Python/pyctype.c",
312 "Python/pyfpe.c",
313 "Python/pyhash.c",
314 "Python/pylifecycle.c",
315 "Python/pymath.c",
316 "Python/pystate.c",
317 "Python/pythonrun.c",
318 "Python/pytime.c",
319 "Python/bootstrap_hash.c",
320 "Python/structmember.c",
321 "Python/symtable.c",
322 "Python/sysmodule.c",
323 "Python/thread.c",
324 "Python/traceback.c",
325 "Python/getopt.c",
326 "Python/pystrcmp.c",
327 "Python/pystrtod.c",
328 "Python/pystrhex.c",
329 "Python/dtoa.c",
330 "Python/formatter_unicode.c",
331 "Python/fileutils.c",
332 "Python/dynload_shlib.c",
333 ],
334
335 target: {
336 linux: {
337 cflags: [
Luca Stefani9d70c2b2020-08-24 14:25:20 +0200338 "-DPLATFORM=\"linux\"",
Luca Stefanib9c5ed92020-08-24 15:05:00 +0200339 "-DABIFLAGS=\"\"",
Dan Willemsenb3614d22019-10-07 16:06:34 -0700340 ],
341 },
342 darwin_x86_64: {
343 cflags: [
344 "-DPLATFORM=\"darwin\"",
Luca Stefanib9c5ed92020-08-24 15:05:00 +0200345 "-DABIFLAGS=\"\"",
Dan Willemsenb3614d22019-10-07 16:06:34 -0700346 ],
347 },
348 },
349}
350
351cc_defaults {
352 name: "py3-launcher-defaults",
Dan Willemsenb33c6902020-12-23 16:39:22 -0800353 defaults: ["py3-interp-defaults", "cpython3-interp-host-prebuilts"],
Dan Willemsenb3614d22019-10-07 16:06:34 -0700354 cflags: [
Spandan Dasb9068f62021-08-18 16:46:57 +0000355 "-DVERSION=\"3.9\"",
Dan Willemsenb3614d22019-10-07 16:06:34 -0700356 "-DVPATH=\"\"",
357 "-DPREFIX=\"\"",
358 "-DEXEC_PREFIX=\"\"",
359 "-DPYTHONPATH=\"..:\"",
360 "-DANDROID_SKIP_ZIP_PATH",
361 "-DANDROID_SKIP_EXEC_PREFIX_PATH",
362 "-DANDROID_LIB_PYTHON_PATH=\"internal/stdlib\"",
363 "-DDATE=\"Dec 31 1969\"",
364 "-DTIME=\"23:59:59\"",
365 ],
366 static_libs: [
367 "libbase",
368 "libexpat",
369 "libz",
370 ],
371 target: {
372 linux_glibc_x86_64: {
373 host_ldlibs: ["-lutil"],
374 },
Jack He5e983f02019-11-07 17:21:40 -0800375 linux: {
376 // Due to test infra limitations, Python native symbols are linked
377 // statically to py3-launcher(s). Hence, need this flag to export
378 // these symbols so that runtime imported native extensions can use
379 // them (e.g. PyBaseObject_Type)
380 ldflags: ["-Wl,--export-dynamic"],
381 },
Dan Willemsenb3614d22019-10-07 16:06:34 -0700382 darwin: {
383 host_ldlibs: [
384 "-framework SystemConfiguration",
385 "-framework CoreFoundation",
386 ],
387 },
388 host: {
Tom Cherryff869db2020-01-08 14:13:00 -0800389 static_libs: [
390 "libsqlite",
391 "liblog",
Colin Cross70204152022-03-08 15:12:48 -0800392 "libopenssl_ssl",
393 "libopenssl_crypto",
394 ],
395 },
396 linux_bionic: {
397 // Linux Bionic doesn't have openssl prebuilts
398 exclude_static_libs: [
399 "libopenssl_ssl",
400 "libopenssl_crypto",
Tom Cherryff869db2020-01-08 14:13:00 -0800401 ],
Dan Willemsenb3614d22019-10-07 16:06:34 -0700402 },
Dan Willemsenb3614d22019-10-07 16:06:34 -0700403 android: {
Jack He5e983f02019-11-07 17:21:40 -0800404 shared_libs: [
405 // Use shared libsqlite for device side, otherwise
406 // the executable size will be really huge.
407 "libsqlite",
408 // Dependency from libbase
409 "liblog",
410 ],
Dan Willemsenb3614d22019-10-07 16:06:34 -0700411 },
412 },
413}
414
415cc_library_static {
416 name: "py3-launcher-lib",
417 defaults: ["py3-launcher-defaults"],
418 cflags: ["-DPy_BUILD_CORE"],
419 srcs: [
420 // Makefile.pre.in MODULE_OBJS
421 "Modules/getpath.c",
422 "Modules/main.c",
423 "Modules/gcmodule.c",
424
425 // Makefile.pre.in LIBRARY_OBJS_OMIT_FROZEN
426 "Modules/getbuildinfo.c",
427 ],
428 whole_static_libs: [
429 "py3-interp",
430 "py3-c-modules",
431 ],
432 target: {
433 android: {
434 srcs: ["android/bionic/config.c"],
435 },
436 linux_bionic: {
437 srcs: ["android/bionic/config.c"],
438 },
439 linux_glibc_x86_64: {
440 srcs: ["android/linux_x86_64/config.c"],
441 },
Colin Cross70204152022-03-08 15:12:48 -0800442 linux_musl_x86_64: {
443 srcs: ["android/linux_x86_64/config.c"],
444 },
Dan Willemsenb3614d22019-10-07 16:06:34 -0700445 darwin: {
446 srcs: ["android/darwin_x86_64/config.c"],
447 },
Tom Cherryff869db2020-01-08 14:13:00 -0800448 },
Dan Willemsenb3614d22019-10-07 16:06:34 -0700449}
450
451cc_binary {
452 name: "py3-launcher",
453 defaults: ["py3-launcher-defaults"],
454 srcs: ["android/launcher_main.cpp"],
455 static_libs: ["py3-launcher-lib"],
456}
457
458cc_binary {
459 name: "py3-launcher-autorun",
460 defaults: ["py3-launcher-defaults"],
461 srcs: ["android/launcher_main.cpp"],
462 static_libs: ["py3-launcher-lib"],
463 cflags: ["-DANDROID_AUTORUN"],
464}
465
Colin Crosse1349762022-03-08 13:20:46 -0800466cc_binary_host {
467 name: "py3-launcher-static",
468 defaults: ["py3-launcher-defaults"],
469 srcs: ["android/launcher_main.cpp"],
470 static_libs: ["py3-launcher-lib"],
471 static_executable: true,
472 target: {
473 glibc: {
474 enabled: false,
475 },
476 },
477}
478
479cc_binary_host {
480 name: "py3-launcher-autorun-static",
481 defaults: ["py3-launcher-defaults"],
482 srcs: ["android/launcher_main.cpp"],
483 static_libs: ["py3-launcher-lib"],
484 static_executable: true,
485 cflags: ["-DANDROID_AUTORUN"],
486 target: {
487 glibc: {
488 enabled: false,
489 },
490 },
491}
492
Dan Willemsenb3614d22019-10-07 16:06:34 -0700493python_binary_host {
494 name: "py3-cmd",
495 autorun: false,
496 version: {
497 py3: {
498 embedded_launcher: true,
499 },
500 },
501}
502
503// Enabled extension py3-c-modules.
504
505cc_library_static {
506 name: "py3-c-modules",
Dan Willemsenb33c6902020-12-23 16:39:22 -0800507 defaults: ["py3-interp-defaults", "cpython3-interp-host-prebuilts"],
Dan Willemsenb3614d22019-10-07 16:06:34 -0700508 cflags: [
509 "-DPy_BUILD_CORE_BUILTIN",
510 "-DUSE_PYEXPAT_CAPI",
511 ],
512 static_libs: [
513 "libexpat",
514 "libz",
515 ],
516 target: {
517 android: {
518 srcs: [":py3-c-modules-bionic"],
519 },
520 linux_bionic: {
521 srcs: [":py3-c-modules-bionic"],
522 },
523 linux_glibc_x86_64: {
524 srcs: [":py3-c-modules-linux_x86_64"],
Dan Willemsene6b5c0a2020-12-11 14:16:07 -0800525 static_libs: [
526 "libopenssl_ssl",
527 "libopenssl_crypto",
528 ],
Dan Willemsenb3614d22019-10-07 16:06:34 -0700529 },
Colin Cross70204152022-03-08 15:12:48 -0800530 linux_musl_x86_64: {
531 srcs: [":py3-c-modules-linux_x86_64"],
532 static_libs: [
533 "libopenssl_ssl",
534 "libopenssl_crypto",
535 ],
536 },
Dan Willemsenb3614d22019-10-07 16:06:34 -0700537 darwin: {
538 srcs: [":py3-c-modules-darwin_x86_64"],
Dan Willemsene6b5c0a2020-12-11 14:16:07 -0800539 static_libs: [
540 "libopenssl_ssl",
541 "libopenssl_crypto",
542 ],
Dan Willemsenb3614d22019-10-07 16:06:34 -0700543 },
Tom Cherryff869db2020-01-08 14:13:00 -0800544 },
Dan Willemsenb3614d22019-10-07 16:06:34 -0700545}