blob: 570c9df82bcaea24b39eb4590035d3bb5a058c45 [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
74// By default, disable the source and use the prebuilts for host linux_glibc
75// 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 },
84 darwin: {
85 enabled: false,
86 },
87 },
88}
89
90cc_defaults {
91 name: "cpython3-interp-force_build_host",
92 defaults_visibility: ["//visibility:private"],
93 target: {
94 linux_glibc: {
95 enabled: true,
96 },
97 darwin: {
98 enabled: true,
99 },
100 },
101}
102
103cpython3_cc_defaults {
Dan Willemsenb3614d22019-10-07 16:06:34 -0700104 name: "py3-interp-defaults",
Dan Willemsenb33c6902020-12-23 16:39:22 -0800105 defaults_visibility: ["//visibility:private"],
Dan Willemsenb3614d22019-10-07 16:06:34 -0700106 cflags: [
107 "-fwrapv",
108 "-O3",
109 "-Wall",
110 "-Wstrict-prototypes",
111 "-DPy_BUILD_CORE",
112 "-Werror",
113 "-Wno-invalid-source-encoding",
114 "-Wno-int-conversion",
115 "-Wno-missing-field-initializers",
116 "-Wno-null-pointer-arithmetic",
117 "-Wno-register",
118 "-Wno-shift-count-overflow",
119 "-Wno-sign-compare",
120 "-Wno-tautological-compare",
121 "-Wno-tautological-constant-out-of-range-compare",
122 "-Wno-unused-function",
123 "-Wno-unused-parameter",
124 "-Wno-unused-result",
125 ],
126 local_include_dirs: [
127 "Include",
128 "Include/internal",
129 ],
130 static_libs: ["libffi"],
131 target: {
132 android: {
133 local_include_dirs: ["android/bionic/pyconfig"],
134 },
135 android_arm: {
Haibo Huang717117f2021-01-25 15:24:19 -0800136 cflags: ["-DSOABI=\"cpython-39android-arm-android-bionic\""],
Dan Willemsenb3614d22019-10-07 16:06:34 -0700137 },
138 android_arm64: {
Haibo Huang717117f2021-01-25 15:24:19 -0800139 cflags: ["-DSOABI=\"cpython-39android-arm64-android-bionic\""],
Dan Willemsenb3614d22019-10-07 16:06:34 -0700140 },
141 android_x86: {
Haibo Huang717117f2021-01-25 15:24:19 -0800142 cflags: ["-DSOABI=\"cpython-39android-x86-android-bionic\""],
Dan Willemsenb3614d22019-10-07 16:06:34 -0700143 },
144 android_x86_64: {
Haibo Huang717117f2021-01-25 15:24:19 -0800145 cflags: ["-DSOABI=\"cpython-39android-x86_64-android-bionic\""],
Dan Willemsenb3614d22019-10-07 16:06:34 -0700146 },
Dan Willemsen6e345142020-12-16 19:03:07 -0800147 host: {
148 // Host builds are moving to prebuilts, which has a higher risk of
149 // having an incompatible libc++.so when installed.
150 stl: "libc++_static",
151 },
Dan Willemsenb3614d22019-10-07 16:06:34 -0700152 // Regenerate include dirs with android_regen.sh
153 darwin_x86_64: {
154 local_include_dirs: ["android/darwin_x86_64/pyconfig"],
155 cflags: [
156 "-Wno-deprecated-declarations",
157 "-Wno-pointer-arith",
Haibo Huang717117f2021-01-25 15:24:19 -0800158 "-DSOABI=\"cpython-39android-x86_64-darwin\"",
Dan Willemsenb3614d22019-10-07 16:06:34 -0700159 ],
160 },
161 linux_bionic: {
162 // NB linux_bionic is a 'host' architecture but it uses the bionic libc like 'android'
163 // targets so use the android pyconfig.
164 local_include_dirs: ["android/bionic/pyconfig"],
Haibo Huang717117f2021-01-25 15:24:19 -0800165 cflags: ["-DSOABI=\"cpython-39android-x86_64-linux-bionic\""],
Dan Willemsenb3614d22019-10-07 16:06:34 -0700166 },
167 linux_glibc_x86: {
168 enabled: false,
169 },
170 linux_glibc_x86_64: {
171 local_include_dirs: ["android/linux_x86_64/pyconfig"],
Haibo Huang717117f2021-01-25 15:24:19 -0800172 cflags: ["-DSOABI=\"cpython-39android-x86_64-linux-gnu\""],
Dan Willemsenb3614d22019-10-07 16:06:34 -0700173 },
174 windows: {
175 enabled: false,
176 },
177 },
178 host_supported: true,
179 compile_multilib: "both",
180 multilib: {
181 lib32: {
182 suffix: "32",
183 },
184 lib64: {
185 suffix: "64",
186 },
187 },
Dan Willemsenb33c6902020-12-23 16:39:22 -0800188 soong_config_variables: {
189 force_build_host: {
190 defaults: ["cpython3-interp-force_build_host"],
191 },
192 },
Dan Willemsenb3614d22019-10-07 16:06:34 -0700193}
194
195cc_library_static {
196 name: "py3-interp",
Dan Willemsenb33c6902020-12-23 16:39:22 -0800197 defaults: ["py3-interp-defaults", "cpython3-interp-host-prebuilts"],
Haibo Huang5bb95e92021-01-14 11:35:14 -0800198 cflags: ["-DPy_BUILD_CORE", "-DPLATLIBDIR=\"lib\""],
Dan Willemsenb3614d22019-10-07 16:06:34 -0700199 srcs: [
Haibo Huang5bb95e92021-01-14 11:35:14 -0800200 // Makefile.pre.in PEGEN_OBJS
201 "Parser/pegen/pegen.c",
202 "Parser/pegen/parse.c",
203 "Parser/pegen/parse_string.c",
204 "Parser/pegen/peg_api.c",
205
Dan Willemsenb3614d22019-10-07 16:06:34 -0700206 // Makefile.pre.in PARSER_OBJS
207 "Parser/acceler.c",
208 "Parser/grammar1.c",
209 "Parser/listnode.c",
210 "Parser/myreadline.c",
211 "Parser/node.c",
212 "Parser/parser.c",
213 "Parser/parsetok.c",
214 "Parser/token.c",
215 "Parser/tokenizer.c",
216
217 // Makefile.pre.in OBJECT_OBJS
218 "Objects/abstract.c",
219 "Objects/accu.c",
220 "Objects/boolobject.c",
221 "Objects/bytes_methods.c",
222 "Objects/bytearrayobject.c",
223 "Objects/bytesobject.c",
224 "Objects/call.c",
225 "Objects/capsule.c",
226 "Objects/cellobject.c",
227 "Objects/classobject.c",
228 "Objects/codeobject.c",
229 "Objects/complexobject.c",
230 "Objects/descrobject.c",
231 "Objects/enumobject.c",
232 "Objects/exceptions.c",
Haibo Huang5bb95e92021-01-14 11:35:14 -0800233 "Objects/genericaliasobject.c",
Dan Willemsenb3614d22019-10-07 16:06:34 -0700234 "Objects/genobject.c",
235 "Objects/fileobject.c",
236 "Objects/floatobject.c",
237 "Objects/frameobject.c",
238 "Objects/funcobject.c",
239 "Objects/interpreteridobject.c",
240 "Objects/iterobject.c",
241 "Objects/listobject.c",
242 "Objects/longobject.c",
243 "Objects/dictobject.c",
244 "Objects/odictobject.c",
245 "Objects/memoryobject.c",
246 "Objects/methodobject.c",
247 "Objects/moduleobject.c",
248 "Objects/namespaceobject.c",
249 "Objects/object.c",
250 "Objects/obmalloc.c",
251 "Objects/picklebufobject.c",
252 "Objects/rangeobject.c",
253 "Objects/setobject.c",
254 "Objects/sliceobject.c",
255 "Objects/structseq.c",
256 "Objects/tupleobject.c",
257 "Objects/typeobject.c",
258 "Objects/unicodeobject.c",
259 "Objects/unicodectype.c",
260 "Objects/weakrefobject.c",
261
262 // Makefile.pre.in PYTHON_OBJS
263 "Python/_warnings.c",
264 "Python/Python-ast.c",
265 "Python/asdl.c",
266 "Python/ast.c",
267 "Python/ast_opt.c",
268 "Python/ast_unparse.c",
269 "Python/bltinmodule.c",
270 "Python/ceval.c",
271 "Python/codecs.c",
272 "Python/compile.c",
273 "Python/context.c",
274 "Python/dynamic_annotations.c",
275 "Python/errors.c",
276 "Python/frozen.c",
277 "Python/frozenmain.c",
278 "Python/future.c",
279 "Python/getargs.c",
280 "Python/getcompiler.c",
281 "Python/getcopyright.c",
282 "Python/getplatform.c",
283 "Python/getversion.c",
284 "Python/graminit.c",
285 "Python/hamt.c",
Haibo Huang5bb95e92021-01-14 11:35:14 -0800286 "Python/hashtable.c",
Dan Willemsenb3614d22019-10-07 16:06:34 -0700287 "Python/import.c",
288 "Python/importdl.c",
289 "Python/initconfig.c",
290 "Python/marshal.c",
291 "Python/modsupport.c",
292 "Python/mysnprintf.c",
293 "Python/mystrtoul.c",
294 "Python/pathconfig.c",
295 "Python/peephole.c",
296 "Python/preconfig.c",
297 "Python/pyarena.c",
298 "Python/pyctype.c",
299 "Python/pyfpe.c",
300 "Python/pyhash.c",
301 "Python/pylifecycle.c",
302 "Python/pymath.c",
303 "Python/pystate.c",
304 "Python/pythonrun.c",
305 "Python/pytime.c",
306 "Python/bootstrap_hash.c",
307 "Python/structmember.c",
308 "Python/symtable.c",
309 "Python/sysmodule.c",
310 "Python/thread.c",
311 "Python/traceback.c",
312 "Python/getopt.c",
313 "Python/pystrcmp.c",
314 "Python/pystrtod.c",
315 "Python/pystrhex.c",
316 "Python/dtoa.c",
317 "Python/formatter_unicode.c",
318 "Python/fileutils.c",
319 "Python/dynload_shlib.c",
320 ],
321
322 target: {
323 linux: {
324 cflags: [
Luca Stefani9d70c2b2020-08-24 14:25:20 +0200325 "-DPLATFORM=\"linux\"",
Luca Stefanib9c5ed92020-08-24 15:05:00 +0200326 "-DABIFLAGS=\"\"",
Dan Willemsenb3614d22019-10-07 16:06:34 -0700327 ],
328 },
329 darwin_x86_64: {
330 cflags: [
331 "-DPLATFORM=\"darwin\"",
Luca Stefanib9c5ed92020-08-24 15:05:00 +0200332 "-DABIFLAGS=\"\"",
Dan Willemsenb3614d22019-10-07 16:06:34 -0700333 ],
334 },
335 },
336}
337
338cc_defaults {
339 name: "py3-launcher-defaults",
Dan Willemsenb33c6902020-12-23 16:39:22 -0800340 defaults: ["py3-interp-defaults", "cpython3-interp-host-prebuilts"],
Dan Willemsenb3614d22019-10-07 16:06:34 -0700341 cflags: [
342 "-DVERSION=\"3.8\"",
343 "-DVPATH=\"\"",
344 "-DPREFIX=\"\"",
345 "-DEXEC_PREFIX=\"\"",
346 "-DPYTHONPATH=\"..:\"",
347 "-DANDROID_SKIP_ZIP_PATH",
348 "-DANDROID_SKIP_EXEC_PREFIX_PATH",
349 "-DANDROID_LIB_PYTHON_PATH=\"internal/stdlib\"",
350 "-DDATE=\"Dec 31 1969\"",
351 "-DTIME=\"23:59:59\"",
352 ],
353 static_libs: [
354 "libbase",
355 "libexpat",
356 "libz",
357 ],
358 target: {
359 linux_glibc_x86_64: {
360 host_ldlibs: ["-lutil"],
Dan Willemsene6b5c0a2020-12-11 14:16:07 -0800361 static_libs: [
362 "libopenssl_ssl",
363 "libopenssl_crypto",
364 ],
Dan Willemsenb3614d22019-10-07 16:06:34 -0700365 },
Jack He5e983f02019-11-07 17:21:40 -0800366 linux: {
367 // Due to test infra limitations, Python native symbols are linked
368 // statically to py3-launcher(s). Hence, need this flag to export
369 // these symbols so that runtime imported native extensions can use
370 // them (e.g. PyBaseObject_Type)
371 ldflags: ["-Wl,--export-dynamic"],
372 },
Dan Willemsenb3614d22019-10-07 16:06:34 -0700373 darwin: {
374 host_ldlibs: [
375 "-framework SystemConfiguration",
376 "-framework CoreFoundation",
377 ],
Dan Willemsene6b5c0a2020-12-11 14:16:07 -0800378 static_libs: [
379 "libopenssl_ssl",
380 "libopenssl_crypto",
381 ],
Dan Willemsenb3614d22019-10-07 16:06:34 -0700382 },
383 host: {
Tom Cherryff869db2020-01-08 14:13:00 -0800384 static_libs: [
385 "libsqlite",
386 "liblog",
387 ],
Dan Willemsenb3614d22019-10-07 16:06:34 -0700388 },
Dan Willemsenb3614d22019-10-07 16:06:34 -0700389 android: {
Jack He5e983f02019-11-07 17:21:40 -0800390 shared_libs: [
391 // Use shared libsqlite for device side, otherwise
392 // the executable size will be really huge.
393 "libsqlite",
394 // Dependency from libbase
395 "liblog",
396 ],
Dan Willemsenb3614d22019-10-07 16:06:34 -0700397 },
398 },
399}
400
401cc_library_static {
402 name: "py3-launcher-lib",
403 defaults: ["py3-launcher-defaults"],
404 cflags: ["-DPy_BUILD_CORE"],
405 srcs: [
406 // Makefile.pre.in MODULE_OBJS
407 "Modules/getpath.c",
408 "Modules/main.c",
409 "Modules/gcmodule.c",
410
411 // Makefile.pre.in LIBRARY_OBJS_OMIT_FROZEN
412 "Modules/getbuildinfo.c",
413 ],
414 whole_static_libs: [
415 "py3-interp",
416 "py3-c-modules",
417 ],
418 target: {
419 android: {
420 srcs: ["android/bionic/config.c"],
421 },
422 linux_bionic: {
423 srcs: ["android/bionic/config.c"],
424 },
425 linux_glibc_x86_64: {
426 srcs: ["android/linux_x86_64/config.c"],
427 },
428 darwin: {
429 srcs: ["android/darwin_x86_64/config.c"],
430 },
Tom Cherryff869db2020-01-08 14:13:00 -0800431 },
Dan Willemsenb3614d22019-10-07 16:06:34 -0700432}
433
434cc_binary {
435 name: "py3-launcher",
436 defaults: ["py3-launcher-defaults"],
437 srcs: ["android/launcher_main.cpp"],
438 static_libs: ["py3-launcher-lib"],
439}
440
441cc_binary {
442 name: "py3-launcher-autorun",
443 defaults: ["py3-launcher-defaults"],
444 srcs: ["android/launcher_main.cpp"],
445 static_libs: ["py3-launcher-lib"],
446 cflags: ["-DANDROID_AUTORUN"],
447}
448
449python_binary_host {
450 name: "py3-cmd",
451 autorun: false,
452 version: {
453 py3: {
454 embedded_launcher: true,
455 },
456 },
457}
458
459// Enabled extension py3-c-modules.
460
461cc_library_static {
462 name: "py3-c-modules",
Dan Willemsenb33c6902020-12-23 16:39:22 -0800463 defaults: ["py3-interp-defaults", "cpython3-interp-host-prebuilts"],
Dan Willemsenb3614d22019-10-07 16:06:34 -0700464 cflags: [
465 "-DPy_BUILD_CORE_BUILTIN",
466 "-DUSE_PYEXPAT_CAPI",
467 ],
468 static_libs: [
469 "libexpat",
470 "libz",
471 ],
472 target: {
473 android: {
474 srcs: [":py3-c-modules-bionic"],
475 },
476 linux_bionic: {
477 srcs: [":py3-c-modules-bionic"],
478 },
479 linux_glibc_x86_64: {
480 srcs: [":py3-c-modules-linux_x86_64"],
Dan Willemsene6b5c0a2020-12-11 14:16:07 -0800481 static_libs: [
482 "libopenssl_ssl",
483 "libopenssl_crypto",
484 ],
Dan Willemsenb3614d22019-10-07 16:06:34 -0700485 },
486 darwin: {
487 srcs: [":py3-c-modules-darwin_x86_64"],
Dan Willemsene6b5c0a2020-12-11 14:16:07 -0800488 static_libs: [
489 "libopenssl_ssl",
490 "libopenssl_crypto",
491 ],
Dan Willemsenb3614d22019-10-07 16:06:34 -0700492 },
Tom Cherryff869db2020-01-08 14:13:00 -0800493 },
Dan Willemsenb3614d22019-10-07 16:06:34 -0700494}