1// Copyright 2017 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
15// *** THIS PACKAGE HAS SPECIAL LICENSING CONDITIONS.  PLEASE
16//     CONSULT THE OWNERS AND [email protected] BEFORE
17//     DEPENDING ON IT IN YOUR PROJECT. ***
18package {
19    default_applicable_licenses: ["external_python_cpython2_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_cpython2_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-GPL-2.0",
46        "SPDX-license-identifier-GPL-3.0",
47        "SPDX-license-identifier-LGPL-2.1",
48        "SPDX-license-identifier-MIT",
49        "SPDX-license-identifier-MPL",
50        "SPDX-license-identifier-PSF-2.0",
51        "SPDX-license-identifier-Zlib",
52        "legacy_by_exception_only", // by exception only
53        "legacy_notice",
54        "legacy_unencumbered",
55    ],
56    license_text: [
57        "LICENSE",
58    ],
59}
60
61subdirs = [
62    "Lib",
63]
64
65cc_defaults {
66    name: "py2-interp-defaults",
67    cflags: [
68        "-fwrapv",
69        "-O3",
70        "-Wall",
71        "-Wstrict-prototypes",
72        "-DPy_BUILD_CORE",
73        "-Werror",
74        "-Wno-invalid-source-encoding",
75        "-Wno-int-conversion",
76        "-Wno-missing-field-initializers",
77        "-Wno-null-pointer-arithmetic",
78        "-Wno-register",
79        "-Wno-shift-count-overflow",
80        "-Wno-single-bit-bitfield-constant-conversion",
81        "-Wno-sign-compare",
82        "-Wno-strict-prototypes",
83        "-Wno-tautological-compare",
84        "-Wno-tautological-constant-out-of-range-compare",
85        "-Wno-unused-parameter",
86        "-Wno-unused-result",
87    ],
88    local_include_dirs: ["Include"],
89    target: {
90        android_arm: {
91            local_include_dirs: ["android_arm/pyconfig"],
92        },
93        android_arm64: {
94            local_include_dirs: ["android_arm64/pyconfig"],
95        },
96        android_x86: {
97            local_include_dirs: ["android_x86/pyconfig"],
98        },
99        linux_bionic: {
100            // NB linux_bionic is a 'host' architecture but it uses the bionic libc like 'android'
101            // targets so use the android pyconfig.
102            local_include_dirs: ["android_x86_64/pyconfig"],
103        },
104        android_x86_64: {
105            local_include_dirs: ["android_x86_64/pyconfig"],
106        },
107        // Regenerate include dirs with android_regen.sh
108        darwin_x86_64: {
109            local_include_dirs: ["darwin_x86_64/pyconfig"],
110            cflags: [
111                "-Wno-deprecated-declarations",
112                "-Wno-pointer-arith",
113            ],
114        },
115        linux_glibc_x86: {
116            enabled: false,
117        },
118        linux_musl_arm: {
119            enabled: false,
120        },
121        linux_musl_x86: {
122            enabled: false,
123        },
124        linux_glibc_x86_64: {
125            local_include_dirs: ["linux_x86_64/pyconfig"],
126            cflags: ["-Werror"],
127        },
128        linux_musl_arm64: {
129            local_include_dirs: ["linux_arm64/pyconfig"],
130            cflags: ["-Werror"],
131        },
132        linux_musl_x86_64: {
133            local_include_dirs: ["linux_x86_64/pyconfig"],
134            cflags: ["-Werror"],
135        },
136        windows: {
137            enabled: false,
138        },
139    },
140    host_supported: true,
141    compile_multilib: "both",
142    multilib: {
143        lib32: {
144            suffix: "32",
145        },
146        lib64: {
147            suffix: "64",
148        },
149    },
150}
151
152cc_library_static {
153    name: "py2-interp-parser",
154    defaults: ["py2-interp-defaults"],
155    srcs: [
156        "Parser/acceler.c",
157        "Parser/bitset.c",
158        "Parser/firstsets.c",
159        "Parser/grammar.c",
160        "Parser/grammar1.c",
161        "Parser/listnode.c",
162        "Parser/metagrammar.c",
163        "Parser/myreadline.c",
164        "Parser/node.c",
165        "Parser/parser.c",
166        "Parser/parsetok.c",
167        "Parser/pgen.c",
168        "Parser/tokenizer.c",
169    ],
170}
171
172cc_library_static {
173    name: "py2-interp-object",
174    defaults: ["py2-interp-defaults"],
175    srcs: [
176        "Objects/abstract.c",
177        "Objects/boolobject.c",
178        "Objects/bufferobject.c",
179        "Objects/bytes_methods.c",
180        "Objects/bytearrayobject.c",
181        "Objects/capsule.c",
182        "Objects/cellobject.c",
183        "Objects/classobject.c",
184        "Objects/cobject.c",
185        "Objects/codeobject.c",
186        "Objects/complexobject.c",
187        "Objects/descrobject.c",
188        "Objects/enumobject.c",
189        "Objects/exceptions.c",
190        "Objects/genobject.c",
191        "Objects/fileobject.c",
192        "Objects/floatobject.c",
193        "Objects/frameobject.c",
194        "Objects/funcobject.c",
195        "Objects/intobject.c",
196        "Objects/iterobject.c",
197        "Objects/listobject.c",
198        "Objects/longobject.c",
199        "Objects/dictobject.c",
200        "Objects/memoryobject.c",
201        "Objects/methodobject.c",
202        "Objects/moduleobject.c",
203        "Objects/object.c",
204        "Objects/obmalloc.c",
205        "Objects/rangeobject.c",
206        "Objects/setobject.c",
207        "Objects/sliceobject.c",
208        "Objects/stringobject.c",
209        "Objects/structseq.c",
210        "Objects/tupleobject.c",
211        "Objects/typeobject.c",
212        "Objects/weakrefobject.c",
213        "Objects/unicodeobject.c",
214        "Objects/unicodectype.c",
215    ],
216}
217
218cc_library_static {
219    name: "py2-interp-python",
220    defaults: ["py2-interp-defaults"],
221    target: {
222        linux: {
223            cflags: [
224                "-DPLATFORM=\"linux2\"",
225            ],
226        },
227        darwin_x86_64: {
228            cflags: [
229                "-DPLATFORM=\"darwin\"",
230            ],
231        },
232    },
233    srcs: [
234        "Python/_warnings.c",
235        "Python/Python-ast.c",
236        "Python/asdl.c",
237        "Python/ast.c",
238        "Python/bltinmodule.c",
239        "Python/ceval.c",
240        "Python/compile.c",
241        "Python/codecs.c",
242        "Python/errors.c",
243        "Python/frozen.c",
244        "Python/frozenmain.c",
245        "Python/future.c",
246        "Python/getargs.c",
247        "Python/getcompiler.c",
248        "Python/getcopyright.c",
249        "Python/getplatform.c",
250        "Python/getversion.c",
251        "Python/graminit.c",
252        "Python/import.c",
253        "Python/importdl.c",
254        "Python/marshal.c",
255        "Python/modsupport.c",
256        "Python/mystrtoul.c",
257        "Python/mysnprintf.c",
258        "Python/peephole.c",
259        "Python/pyarena.c",
260        "Python/pyctype.c",
261        "Python/pyfpe.c",
262        "Python/pymath.c",
263        "Python/pystate.c",
264        "Python/pythonrun.c",
265        "Python/random.c",
266        "Python/structmember.c",
267        "Python/symtable.c",
268        "Python/sysmodule.c",
269        "Python/traceback.c",
270        "Python/getopt.c",
271        "Python/pystrcmp.c",
272        "Python/pystrtod.c",
273        "Python/dtoa.c",
274        "Python/formatter_unicode.c",
275        "Python/formatter_string.c",
276        "Python/dynload_shlib.c",
277        "Python/thread.c",
278    ],
279}
280
281cc_defaults {
282    name: "py2-launcher-defaults",
283    defaults: ["py2-interp-defaults"],
284    cflags: [
285        "-DVERSION=\"2.7\"",
286        "-DVPATH=\"\"",
287        "-DPREFIX=\"\"",
288        "-DEXEC_PREFIX=\"\"",
289        "-DPYTHONPATH=\"..:\"",
290        "-DANDROID_SKIP_ZIP_PATH",
291        "-DANDROID_SKIP_EXEC_PREFIX_PATH",
292        "-DANDROID_LIB_PYTHON_PATH=\"internal/stdlib\"",
293        "-DDATE=\"Dec 31 1969\"",
294        "-DTIME=\"23:59:59\"",
295    ],
296    static_libs: [
297        "libbase",
298        "libcrypto_static",
299        "libexpat",
300        "liblog",
301        "libssl",
302        "libz",
303    ],
304    target: {
305        linux_glibc_x86_64: {
306            host_ldlibs: ["-lutil"],
307        },
308        darwin: {
309            host_ldlibs: [
310                "-framework SystemConfiguration",
311                "-framework CoreFoundation",
312            ],
313        },
314        host: {
315            static_libs: ["libsqlite_static_noicu"],
316        },
317        // Use shared libsqlite for device side, otherwise
318        // the executable size will be really huge.
319        android: {
320            shared_libs: ["libsqlite"],
321        },
322    },
323}
324
325cc_library_static {
326    name: "py2-launcher-lib",
327    defaults: ["py2-launcher-defaults"],
328    srcs: [
329        "Modules/gcmodule.c",
330        "Modules/getpath.c",
331        "Modules/config.c",
332        "Modules/getbuildinfo.c",
333        // Default built-in extension py2-c-modules.
334        "Modules/threadmodule.c",
335        "Modules/signalmodule.c",
336        "Modules/posixmodule.c",
337        "Modules/errnomodule.c",
338        "Modules/pwdmodule.c",
339        "Modules/_sre.c",
340        "Modules/_codecsmodule.c",
341        "Modules/_weakref.c",
342        "Modules/zipimport.c",
343        "Modules/symtablemodule.c",
344        "Modules/main.c",
345    ],
346    // NOTE: Please update Modules/config.c if new lib get added in the static_libs.
347    whole_static_libs: [
348        // Be careful the order of these three static libraries below due to
349        // missing symbols issues.
350        "py2-interp-object",
351        "py2-interp-python",
352        "py2-interp-parser",
353        "py2-c-module-array",
354        "py2-c-module-cmath",
355        "py2-c-module-math",
356        "py2-c-module-_struct",
357        "py2-c-module-time",
358        "py2-c-module-operator",
359        "py2-c-module-_testcapi",
360        "py2-c-module-_random",
361        "py2-c-module-_collections",
362        "py2-c-module-_heapq",
363        "py2-c-module-itertools",
364        "py2-c-module-strop",
365        "py2-c-module-_functools",
366        "py2-c-module-datetime",
367        "py2-c-module-_bisect",
368        "py2-c-module-unicodedata",
369        "py2-c-module-_io",
370        "py2-c-module-fcntl",
371        "py2-c-module-select",
372        "py2-c-module-mmap",
373        "py2-c-module-_csv",
374        "py2-c-module-_socket",
375        "py2-c-module-termios",
376        "py2-c-module-_ssl",
377        "py2-c-module-_md5",
378        "py2-c-module-_sha",
379        "py2-c-module-_sha256",
380        "py2-c-module-_sha512",
381        "py2-c-module-binascii",
382        "py2-c-module-parser",
383        "py2-c-module-cStringIO",
384        "py2-c-module-cPickle",
385        "py2-c-module-xxsubtype",
386        "py2-c-module-future_builtins",
387        "py2-c-module-_json",
388        "py2-c-module-_hotshot",
389        "py2-c-module-_lsprof",
390        "py2-c-module-grp",
391        "py2-c-module-syslog",
392        "py2-c-module-audioop",
393        "py2-c-module-resource",
394        "py2-c-module-_multibytecodec",
395        "py2-c-module-_codecs_kr",
396        "py2-c-module-_codecs_jp",
397        "py2-c-module-_codecs_cn",
398        "py2-c-module-_codecs_tw",
399        "py2-c-module-_codecs_hk",
400        "py2-c-module-_codecs_iso2022",
401        "py2-c-module-_multiprocessing",
402        "py2-c-module-zlib",
403        "py2-c-module-pyexpat",
404        "py2-c-module-_sqlite3",
405        "py2-c-module-_ctypes_test",
406        "py2-c-module-_ctypes",
407    ],
408    target: {
409        darwin: {
410            whole_static_libs: ["py2-c-module-_scproxy"],
411        },
412    },
413}
414
415cc_binary {
416    name: "py2-launcher",
417    defaults: ["py2-launcher-defaults"],
418    srcs: ["Launcher/launcher_main.cpp"],
419    static_libs: ["py2-launcher-lib"],
420}
421
422cc_binary {
423    name: "py2-launcher-autorun",
424    defaults: ["py2-launcher-defaults"],
425    srcs: ["Launcher/launcher_main.cpp"],
426    static_libs: ["py2-launcher-lib"],
427    cflags: ["-DANDROID_AUTORUN"],
428}
429
430python_binary_host {
431    name: "py2-cmd",
432    autorun: false,
433    version: {
434        py2: {
435            enabled: true,
436            embedded_launcher: true,
437        },
438        py3: {
439            enabled: false,
440        },
441    },
442}
443
444// Enabled extension py2-c-modules.
445
446cc_library_static {
447    name: "py2-c-module-array",
448    defaults: ["py2-interp-defaults"],
449    srcs: [
450        "Modules/arraymodule.c",
451    ],
452}
453
454cc_library_static {
455    name: "py2-c-module-cmath",
456    defaults: ["py2-interp-defaults"],
457    srcs: [
458        "Modules/cmathmodule.c",
459        "Modules/_math.c",
460    ],
461}
462
463cc_library_static {
464    name: "py2-c-module-math",
465    defaults: ["py2-interp-defaults"],
466    srcs: [
467        "Modules/mathmodule.c",
468        "Modules/_math.c",
469    ],
470}
471
472cc_library_static {
473    name: "py2-c-module-_struct",
474    defaults: ["py2-interp-defaults"],
475    srcs: [
476        "Modules/_struct.c",
477    ],
478}
479
480cc_library_static {
481    name: "py2-c-module-time",
482    defaults: ["py2-interp-defaults"],
483    srcs: [
484        "Modules/timemodule.c",
485    ],
486}
487
488cc_library_static {
489    name: "py2-c-module-operator",
490    defaults: ["py2-interp-defaults"],
491    srcs: [
492        "Modules/operator.c",
493    ],
494}
495
496cc_library_static {
497    name: "py2-c-module-_testcapi",
498    defaults: ["py2-interp-defaults"],
499    srcs: [
500        "Modules/_testcapimodule.c",
501    ],
502}
503
504cc_library_static {
505    name: "py2-c-module-_random",
506    defaults: ["py2-interp-defaults"],
507    srcs: [
508        "Modules/_randommodule.c",
509    ],
510}
511
512cc_library_static {
513    name: "py2-c-module-_collections",
514    defaults: ["py2-interp-defaults"],
515    srcs: [
516        "Modules/_collectionsmodule.c",
517    ],
518}
519
520cc_library_static {
521    name: "py2-c-module-_heapq",
522    defaults: ["py2-interp-defaults"],
523    srcs: [
524        "Modules/_heapqmodule.c",
525    ],
526}
527
528cc_library_static {
529    name: "py2-c-module-itertools",
530    defaults: ["py2-interp-defaults"],
531    srcs: [
532        "Modules/itertoolsmodule.c",
533    ],
534}
535
536cc_library_static {
537    name: "py2-c-module-strop",
538    defaults: ["py2-interp-defaults"],
539    srcs: [
540        "Modules/stropmodule.c",
541    ],
542}
543
544cc_library_static {
545    name: "py2-c-module-_functools",
546    defaults: ["py2-interp-defaults"],
547    srcs: [
548        "Modules/_functoolsmodule.c",
549    ],
550}
551
552cc_library_static {
553    name: "py2-c-module-datetime",
554    defaults: ["py2-interp-defaults"],
555    srcs: [
556        "Modules/datetimemodule.c",
557    ],
558}
559
560cc_library_static {
561    name: "py2-c-module-_bisect",
562    defaults: ["py2-interp-defaults"],
563    srcs: [
564        "Modules/_bisectmodule.c",
565    ],
566}
567
568cc_library_static {
569    name: "py2-c-module-unicodedata",
570    defaults: ["py2-interp-defaults"],
571    srcs: [
572        "Modules/unicodedata.c",
573    ],
574}
575
576cc_library_static {
577    name: "py2-c-module-_io",
578    defaults: ["py2-interp-defaults"],
579    srcs: [
580        "Modules/_io/bufferedio.c",
581        "Modules/_io/bytesio.c",
582        "Modules/_io/fileio.c",
583        "Modules/_io/iobase.c",
584        "Modules/_io/_iomodule.c",
585        "Modules/_io/stringio.c",
586        "Modules/_io/textio.c",
587    ],
588    local_include_dirs: [
589        "Modules/_io",
590    ],
591}
592
593cc_library_static {
594    name: "py2-c-module-fcntl",
595    defaults: ["py2-interp-defaults"],
596    srcs: [
597        "Modules/fcntlmodule.c",
598    ],
599}
600
601cc_library_static {
602    name: "py2-c-module-select",
603    defaults: ["py2-interp-defaults"],
604    srcs: [
605        "Modules/selectmodule.c",
606    ],
607}
608
609cc_library_static {
610    name: "py2-c-module-mmap",
611    defaults: ["py2-interp-defaults"],
612    srcs: [
613        "Modules/mmapmodule.c",
614    ],
615}
616
617cc_library_static {
618    name: "py2-c-module-_csv",
619    defaults: ["py2-interp-defaults"],
620    srcs: [
621        "Modules/_csv.c",
622    ],
623}
624
625cc_library_static {
626    name: "py2-c-module-_socket",
627    defaults: ["py2-interp-defaults"],
628    srcs: [
629        "Modules/socketmodule.c",
630        "Modules/timemodule.c",
631    ],
632}
633
634cc_library_static {
635    name: "py2-c-module-termios",
636    defaults: ["py2-interp-defaults"],
637    srcs: [
638        "Modules/termios.c",
639    ],
640}
641
642cc_library_static {
643    name: "py2-c-module-_ssl",
644    defaults: ["py2-interp-defaults"],
645    srcs: ["Modules/_ssl.c"],
646    cflags: ["-Wno-incompatible-pointer-types-discards-qualifiers"],
647    static_libs: [
648        "libssl",
649        "libcrypto_static",
650    ],
651}
652
653cc_library_static {
654    name: "py2-c-module-_md5",
655    defaults: ["py2-interp-defaults"],
656    srcs: [
657        "Modules/md5module.c",
658        "Modules/md5.c",
659    ],
660}
661
662cc_library_static {
663    name: "py2-c-module-_sha",
664    defaults: ["py2-interp-defaults"],
665    srcs: [
666        "Modules/shamodule.c",
667    ],
668}
669
670cc_library_static {
671    name: "py2-c-module-_sha256",
672    defaults: ["py2-interp-defaults"],
673    srcs: [
674        "Modules/sha256module.c",
675    ],
676}
677
678cc_library_static {
679    name: "py2-c-module-_sha512",
680    defaults: ["py2-interp-defaults"],
681    srcs: [
682        "Modules/sha512module.c",
683    ],
684}
685
686cc_library_static {
687    name: "py2-c-module-binascii",
688    defaults: ["py2-interp-defaults"],
689    srcs: [
690        "Modules/binascii.c",
691    ],
692}
693
694cc_library_static {
695    name: "py2-c-module-parser",
696    defaults: ["py2-interp-defaults"],
697    srcs: [
698        "Modules/parsermodule.c",
699    ],
700}
701
702cc_library_static {
703    name: "py2-c-module-cStringIO",
704    defaults: ["py2-interp-defaults"],
705    srcs: [
706        "Modules/cStringIO.c",
707    ],
708}
709
710cc_library_static {
711    name: "py2-c-module-cPickle",
712    defaults: ["py2-interp-defaults"],
713    srcs: [
714        "Modules/cPickle.c",
715    ],
716}
717
718cc_library_static {
719    name: "py2-c-module-xxsubtype",
720    defaults: ["py2-interp-defaults"],
721    srcs: [
722        "Modules/xxsubtype.c",
723    ],
724}
725
726cc_library_static {
727    name: "py2-c-module-future_builtins",
728    defaults: ["py2-interp-defaults"],
729    srcs: [
730        "Modules/future_builtins.c",
731    ],
732}
733
734cc_library_static {
735    name: "py2-c-module-_json",
736    defaults: ["py2-interp-defaults"],
737    srcs: [
738        "Modules/_json.c",
739    ],
740}
741
742cc_library_static {
743    name: "py2-c-module-_hotshot",
744    defaults: ["py2-interp-defaults"],
745    srcs: [
746        "Modules/_hotshot.c",
747    ],
748}
749
750cc_library_static {
751    name: "py2-c-module-_lsprof",
752    defaults: ["py2-interp-defaults"],
753    srcs: [
754        "Modules/_lsprof.c",
755        "Modules/rotatingtree.c",
756    ],
757}
758
759cc_library_static {
760    name: "py2-c-module-grp",
761    defaults: ["py2-interp-defaults"],
762    srcs: [
763        "Modules/grpmodule.c",
764        "Modules/rotatingtree.c",
765    ],
766}
767
768cc_library_static {
769    name: "py2-c-module-syslog",
770    defaults: ["py2-interp-defaults"],
771    srcs: [
772        "Modules/syslogmodule.c",
773    ],
774}
775
776cc_library_static {
777    name: "py2-c-module-audioop",
778    defaults: ["py2-interp-defaults"],
779    srcs: [
780        "Modules/audioop.c",
781    ],
782}
783
784cc_library_static {
785    name: "py2-c-module-resource",
786    defaults: ["py2-interp-defaults"],
787    srcs: [
788        "Modules/resource.c",
789    ],
790}
791
792cc_library_static {
793    name: "py2-c-module-_multibytecodec",
794    defaults: ["py2-interp-defaults"],
795    srcs: [
796        "Modules/cjkcodecs/multibytecodec.c",
797    ],
798}
799
800cc_library_static {
801    name: "py2-c-module-_codecs_kr",
802    defaults: ["py2-interp-defaults"],
803    srcs: ["Modules/cjkcodecs/_codecs_kr.c"],
804}
805
806cc_library_static {
807    name: "py2-c-module-_codecs_jp",
808    defaults: ["py2-interp-defaults"],
809    srcs: ["Modules/cjkcodecs/_codecs_jp.c"],
810}
811
812cc_library_static {
813    name: "py2-c-module-_codecs_cn",
814    defaults: ["py2-interp-defaults"],
815    srcs: ["Modules/cjkcodecs/_codecs_cn.c"],
816}
817
818cc_library_static {
819    name: "py2-c-module-_codecs_tw",
820    defaults: ["py2-interp-defaults"],
821    srcs: ["Modules/cjkcodecs/_codecs_tw.c"],
822}
823
824cc_library_static {
825    name: "py2-c-module-_codecs_hk",
826    defaults: ["py2-interp-defaults"],
827    srcs: ["Modules/cjkcodecs/_codecs_hk.c"],
828}
829
830cc_library_static {
831    name: "py2-c-module-_codecs_iso2022",
832    defaults: ["py2-interp-defaults"],
833    srcs: ["Modules/cjkcodecs/_codecs_iso2022.c"],
834}
835
836cc_library_static {
837    name: "py2-c-module-_multiprocessing",
838    defaults: ["py2-interp-defaults"],
839    srcs: [
840        "Modules/_multiprocessing/multiprocessing.c",
841        "Modules/_multiprocessing/semaphore.c",
842        "Modules/_multiprocessing/socket_connection.c",
843    ],
844}
845
846cc_library_static {
847    name: "py2-c-module-zlib",
848    defaults: [
849        "py2-interp-defaults",
850    ],
851    cflags: [
852        "-DUSE_ZLIB_CRC32",
853    ],
854    srcs: [
855        "Modules/zlibmodule.c",
856    ],
857    static_libs: [
858        "libz",
859    ],
860}
861
862cc_library_static {
863    name: "py2-c-module-pyexpat",
864    defaults: [
865        "py2-interp-defaults",
866    ],
867    cflags: [
868        "-DUSE_PYEXPAT_CAPI",
869    ],
870    srcs: [
871        "Modules/pyexpat.c",
872    ],
873    static_libs: [
874        "libexpat",
875    ],
876}
877
878cc_library_static {
879    name: "py2-c-module-_sqlite3",
880    defaults: [
881        "py2-interp-defaults",
882    ],
883    cflags: [
884        "-DMODULE_NAME=\"sqlite3\"",
885        "-DSQLITE_OMIT_LOAD_EXTENSION",
886        "-Wno-format-security",
887        "-Wno-type-limits",
888        "-Wno-char-subscripts",
889    ],
890    local_include_dirs: [
891        "Modules/_sqlite",
892    ],
893    srcs: [
894        "Modules/_sqlite/cache.c",
895        "Modules/_sqlite/connection.c",
896        "Modules/_sqlite/cursor.c",
897        "Modules/_sqlite/microprotocols.c",
898        "Modules/_sqlite/module.c",
899        "Modules/_sqlite/prepare_protocol.c",
900        "Modules/_sqlite/row.c",
901        "Modules/_sqlite/statement.c",
902        "Modules/_sqlite/util.c",
903    ],
904    target: {
905        host: {
906            static_libs: [
907                "libsqlite",
908            ],
909        },
910        android: {
911            shared_libs: [
912                "libsqlite",
913            ],
914        },
915    },
916}
917
918cc_library_static {
919    name: "py2-c-module-_ctypes_test",
920    defaults: ["py2-interp-defaults"],
921    srcs: ["Modules/_ctypes/_ctypes_test.c"],
922}
923
924cc_library_static {
925    name: "py2-c-module-_ctypes",
926    defaults: [
927        "py2-interp-defaults",
928    ],
929    local_include_dirs: [
930        "Modules/_ctypes/libffi/include",
931    ],
932    srcs: [
933        "Modules/_ctypes/_ctypes.c",
934        "Modules/_ctypes/callbacks.c",
935        "Modules/_ctypes/callproc.c",
936        "Modules/_ctypes/stgdict.c",
937        "Modules/_ctypes/cfield.c",
938        "Modules/_ctypes/libffi/src/prep_cif.c",
939        "Modules/_ctypes/libffi/src/closures.c",
940    ],
941    arch: {
942        x86_64: {
943            local_include_dirs: [
944                "Modules/_ctypes/libffi/src/x86",
945            ],
946            srcs: [
947                "Modules/_ctypes/libffi/src/x86/ffi64.c",
948                "Modules/_ctypes/libffi/src/x86/ffi.c",
949                "Modules/_ctypes/libffi/src/x86/sysv.S",
950            ],
951        },
952        x86: {
953            local_include_dirs: [
954                "Modules/_ctypes/libffi/src/x86",
955            ],
956            srcs: [
957                "Modules/_ctypes/libffi/src/x86/ffi.c",
958                "Modules/_ctypes/libffi/src/x86/sysv.S",
959            ],
960        },
961        arm: {
962            local_include_dirs: [
963                "android_arm/libffi",
964                "Modules/_ctypes/libffi/src/arm",
965            ],
966            srcs: [
967                "Modules/_ctypes/libffi/src/arm/ffi.c",
968                "Modules/_ctypes/libffi/src/arm/sysv.S",
969                "Modules/_ctypes/libffi/src/arm/trampoline.S",
970            ],
971        },
972        arm64: {
973            // arithmetic on a pointer in _ctypes/libffi/src/aarch64/ffi.c
974            cflags: ["-Wno-pointer-arith"],
975            local_include_dirs: [
976                "android_arm64/libffi",
977                "Modules/_ctypes/libffi/src/aarch64",
978            ],
979            srcs: [
980                "Modules/_ctypes/libffi/src/aarch64/ffi.c",
981                "Modules/_ctypes/libffi/src/aarch64/sysv.S",
982            ],
983        },
984    },
985    target: {
986        // Regenerate include dirs with android_regen.sh
987        darwin_x86_64: {
988            local_include_dirs: ["darwin_x86_64/libffi"],
989            srcs: [
990                "Modules/_ctypes/libffi/src/x86/darwin.S",
991                "Modules/_ctypes/libffi/src/x86/darwin64.S",
992            ],
993        },
994        linux_glibc_x86_64: {
995            local_include_dirs: ["linux_x86_64/libffi"],
996            srcs: [
997                "Modules/_ctypes/libffi/src/x86/unix64.S",
998            ],
999        },
1000        linux_musl_arm64: {
1001            local_include_dirs: ["linux_arm64/libffi"],
1002            srcs: [
1003                "Modules/_ctypes/libffi/src/x86/unix64.S",
1004            ],
1005        },
1006        linux_musl_x86_64: {
1007            local_include_dirs: ["linux_x86_64/libffi"],
1008            srcs: [
1009                "Modules/_ctypes/libffi/src/x86/unix64.S",
1010            ],
1011        },
1012        android_x86: {
1013            local_include_dirs: ["android_x86/libffi"],
1014            srcs: [
1015                "Modules/_ctypes/libffi/src/x86/win32.S",
1016            ],
1017        },
1018        android_x86_64: {
1019            local_include_dirs: ["android_x86_64/libffi"],
1020            srcs: [
1021                "Modules/_ctypes/libffi/src/x86/unix64.S",
1022            ],
1023        },
1024    },
1025}
1026
1027cc_library_host_static {
1028    name: "py2-c-module-_scproxy",
1029    defaults: ["py2-interp-defaults"],
1030    srcs: ["Mac/Modules/_scproxy.c"],
1031    target: {
1032        linux: {
1033            enabled: false,
1034        },
1035    },
1036}
1037