blob: 365351b9dd7e4c75ff3c6e1bc0acebd560eca146 [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"],
308 },
Jack He5e983f02019-11-07 17:21:40 -0800309 linux: {
310 // Due to test infra limitations, Python native symbols are linked
311 // statically to py3-launcher(s). Hence, need this flag to export
312 // these symbols so that runtime imported native extensions can use
313 // them (e.g. PyBaseObject_Type)
314 ldflags: ["-Wl,--export-dynamic"],
315 },
Dan Willemsenb3614d22019-10-07 16:06:34 -0700316 darwin: {
317 host_ldlibs: [
318 "-framework SystemConfiguration",
319 "-framework CoreFoundation",
320 ],
321 },
322 host: {
Tom Cherryff869db2020-01-08 14:13:00 -0800323 static_libs: [
324 "libsqlite",
325 "liblog",
326 ],
Dan Willemsenb3614d22019-10-07 16:06:34 -0700327 },
Dan Willemsenb3614d22019-10-07 16:06:34 -0700328 android: {
Jack He5e983f02019-11-07 17:21:40 -0800329 shared_libs: [
330 // Use shared libsqlite for device side, otherwise
331 // the executable size will be really huge.
332 "libsqlite",
333 // Dependency from libbase
334 "liblog",
335 ],
Dan Willemsenb3614d22019-10-07 16:06:34 -0700336 },
337 },
338}
339
340cc_library_static {
341 name: "py3-launcher-lib",
342 defaults: ["py3-launcher-defaults"],
343 cflags: ["-DPy_BUILD_CORE"],
344 srcs: [
345 // Makefile.pre.in MODULE_OBJS
346 "Modules/getpath.c",
347 "Modules/main.c",
348 "Modules/gcmodule.c",
349
350 // Makefile.pre.in LIBRARY_OBJS_OMIT_FROZEN
351 "Modules/getbuildinfo.c",
352 ],
353 whole_static_libs: [
354 "py3-interp",
355 "py3-c-modules",
356 ],
357 target: {
358 android: {
359 srcs: ["android/bionic/config.c"],
360 },
361 linux_bionic: {
362 srcs: ["android/bionic/config.c"],
363 },
364 linux_glibc_x86_64: {
365 srcs: ["android/linux_x86_64/config.c"],
366 },
367 darwin: {
368 srcs: ["android/darwin_x86_64/config.c"],
369 },
Tom Cherryff869db2020-01-08 14:13:00 -0800370 },
Dan Willemsenb3614d22019-10-07 16:06:34 -0700371}
372
373cc_binary {
374 name: "py3-launcher",
375 defaults: ["py3-launcher-defaults"],
376 srcs: ["android/launcher_main.cpp"],
377 static_libs: ["py3-launcher-lib"],
378}
379
380cc_binary {
381 name: "py3-launcher-autorun",
382 defaults: ["py3-launcher-defaults"],
383 srcs: ["android/launcher_main.cpp"],
384 static_libs: ["py3-launcher-lib"],
385 cflags: ["-DANDROID_AUTORUN"],
386}
387
388python_binary_host {
389 name: "py3-cmd",
390 autorun: false,
391 version: {
392 py3: {
393 embedded_launcher: true,
394 },
395 },
396}
397
398// Enabled extension py3-c-modules.
399
400cc_library_static {
401 name: "py3-c-modules",
Dan Willemsenb33c6902020-12-23 16:39:22 -0800402 defaults: ["py3-interp-defaults", "cpython3-interp-host-prebuilts"],
Dan Willemsenb3614d22019-10-07 16:06:34 -0700403 cflags: [
404 "-DPy_BUILD_CORE_BUILTIN",
405 "-DUSE_PYEXPAT_CAPI",
406 ],
407 static_libs: [
408 "libexpat",
409 "libz",
410 ],
411 target: {
412 android: {
413 srcs: [":py3-c-modules-bionic"],
414 },
415 linux_bionic: {
416 srcs: [":py3-c-modules-bionic"],
417 },
418 linux_glibc_x86_64: {
419 srcs: [":py3-c-modules-linux_x86_64"],
420 },
421 darwin: {
422 srcs: [":py3-c-modules-darwin_x86_64"],
423 },
Tom Cherryff869db2020-01-08 14:13:00 -0800424 },
Dan Willemsenb3614d22019-10-07 16:06:34 -0700425}