blob: 38295dce575420845de3fa1039e60c7f2844691c [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
15build = ["Android-bionic.bp", "Android-linux_x86_64.bp", "Android-darwin_x86_64.bp"]
16
17cc_defaults {
18 name: "py3-interp-defaults",
19 cflags: [
20 "-fwrapv",
21 "-O3",
22 "-Wall",
23 "-Wstrict-prototypes",
24 "-DPy_BUILD_CORE",
25 "-Werror",
26 "-Wno-invalid-source-encoding",
27 "-Wno-int-conversion",
28 "-Wno-missing-field-initializers",
29 "-Wno-null-pointer-arithmetic",
30 "-Wno-register",
31 "-Wno-shift-count-overflow",
32 "-Wno-sign-compare",
33 "-Wno-tautological-compare",
34 "-Wno-tautological-constant-out-of-range-compare",
35 "-Wno-unused-function",
36 "-Wno-unused-parameter",
37 "-Wno-unused-result",
38 ],
39 local_include_dirs: [
40 "Include",
41 "Include/internal",
42 ],
43 static_libs: ["libffi"],
44 target: {
45 android: {
46 local_include_dirs: ["android/bionic/pyconfig"],
47 },
48 android_arm: {
49 cflags: ["-DSOABI=\"cpython-38android-arm-android-bionic\""],
50 },
51 android_arm64: {
52 cflags: ["-DSOABI=\"cpython-38android-arm64-android-bionic\""],
53 },
54 android_x86: {
55 cflags: ["-DSOABI=\"cpython-38android-x86-android-bionic\""],
56 },
57 android_x86_64: {
58 cflags: ["-DSOABI=\"cpython-38android-x86_64-android-bionic\""],
59 },
60 // Regenerate include dirs with android_regen.sh
61 darwin_x86_64: {
62 local_include_dirs: ["android/darwin_x86_64/pyconfig"],
63 cflags: [
64 "-Wno-deprecated-declarations",
65 "-Wno-pointer-arith",
66 "-DSOABI=\"cpython-38android-x86_64-darwin\"",
67 ],
68 },
69 linux_bionic: {
70 // NB linux_bionic is a 'host' architecture but it uses the bionic libc like 'android'
71 // targets so use the android pyconfig.
72 local_include_dirs: ["android/bionic/pyconfig"],
73 cflags: ["-DSOABI=\"cpython-38android-x86_64-linux-bionic\""],
74 },
75 linux_glibc_x86: {
76 enabled: false,
77 },
78 linux_glibc_x86_64: {
79 local_include_dirs: ["android/linux_x86_64/pyconfig"],
80 cflags: ["-DSOABI=\"cpython-38android-x86_64-linux-gnu\""],
81 },
82 windows: {
83 enabled: false,
84 },
85 },
86 host_supported: true,
87 compile_multilib: "both",
88 multilib: {
89 lib32: {
90 suffix: "32",
91 },
92 lib64: {
93 suffix: "64",
94 },
95 },
96}
97
98cc_library_static {
99 name: "py3-interp",
100 defaults: ["py3-interp-defaults"],
101 cflags: ["-DPy_BUILD_CORE"],
102 srcs: [
103 // Makefile.pre.in PARSER_OBJS
104 "Parser/acceler.c",
105 "Parser/grammar1.c",
106 "Parser/listnode.c",
107 "Parser/myreadline.c",
108 "Parser/node.c",
109 "Parser/parser.c",
110 "Parser/parsetok.c",
111 "Parser/token.c",
112 "Parser/tokenizer.c",
113
114 // Makefile.pre.in OBJECT_OBJS
115 "Objects/abstract.c",
116 "Objects/accu.c",
117 "Objects/boolobject.c",
118 "Objects/bytes_methods.c",
119 "Objects/bytearrayobject.c",
120 "Objects/bytesobject.c",
121 "Objects/call.c",
122 "Objects/capsule.c",
123 "Objects/cellobject.c",
124 "Objects/classobject.c",
125 "Objects/codeobject.c",
126 "Objects/complexobject.c",
127 "Objects/descrobject.c",
128 "Objects/enumobject.c",
129 "Objects/exceptions.c",
130 "Objects/genobject.c",
131 "Objects/fileobject.c",
132 "Objects/floatobject.c",
133 "Objects/frameobject.c",
134 "Objects/funcobject.c",
135 "Objects/interpreteridobject.c",
136 "Objects/iterobject.c",
137 "Objects/listobject.c",
138 "Objects/longobject.c",
139 "Objects/dictobject.c",
140 "Objects/odictobject.c",
141 "Objects/memoryobject.c",
142 "Objects/methodobject.c",
143 "Objects/moduleobject.c",
144 "Objects/namespaceobject.c",
145 "Objects/object.c",
146 "Objects/obmalloc.c",
147 "Objects/picklebufobject.c",
148 "Objects/rangeobject.c",
149 "Objects/setobject.c",
150 "Objects/sliceobject.c",
151 "Objects/structseq.c",
152 "Objects/tupleobject.c",
153 "Objects/typeobject.c",
154 "Objects/unicodeobject.c",
155 "Objects/unicodectype.c",
156 "Objects/weakrefobject.c",
157
158 // Makefile.pre.in PYTHON_OBJS
159 "Python/_warnings.c",
160 "Python/Python-ast.c",
161 "Python/asdl.c",
162 "Python/ast.c",
163 "Python/ast_opt.c",
164 "Python/ast_unparse.c",
165 "Python/bltinmodule.c",
166 "Python/ceval.c",
167 "Python/codecs.c",
168 "Python/compile.c",
169 "Python/context.c",
170 "Python/dynamic_annotations.c",
171 "Python/errors.c",
172 "Python/frozen.c",
173 "Python/frozenmain.c",
174 "Python/future.c",
175 "Python/getargs.c",
176 "Python/getcompiler.c",
177 "Python/getcopyright.c",
178 "Python/getplatform.c",
179 "Python/getversion.c",
180 "Python/graminit.c",
181 "Python/hamt.c",
182 "Python/import.c",
183 "Python/importdl.c",
184 "Python/initconfig.c",
185 "Python/marshal.c",
186 "Python/modsupport.c",
187 "Python/mysnprintf.c",
188 "Python/mystrtoul.c",
189 "Python/pathconfig.c",
190 "Python/peephole.c",
191 "Python/preconfig.c",
192 "Python/pyarena.c",
193 "Python/pyctype.c",
194 "Python/pyfpe.c",
195 "Python/pyhash.c",
196 "Python/pylifecycle.c",
197 "Python/pymath.c",
198 "Python/pystate.c",
199 "Python/pythonrun.c",
200 "Python/pytime.c",
201 "Python/bootstrap_hash.c",
202 "Python/structmember.c",
203 "Python/symtable.c",
204 "Python/sysmodule.c",
205 "Python/thread.c",
206 "Python/traceback.c",
207 "Python/getopt.c",
208 "Python/pystrcmp.c",
209 "Python/pystrtod.c",
210 "Python/pystrhex.c",
211 "Python/dtoa.c",
212 "Python/formatter_unicode.c",
213 "Python/fileutils.c",
214 "Python/dynload_shlib.c",
215 ],
216
217 target: {
218 linux: {
219 cflags: [
220 "-DPLATFORM=\"linux2\"",
221 ],
222 },
223 darwin_x86_64: {
224 cflags: [
225 "-DPLATFORM=\"darwin\"",
226 ],
227 },
228 },
229}
230
231cc_defaults {
232 name: "py3-launcher-defaults",
233 defaults: ["py3-interp-defaults"],
234 cflags: [
235 "-DVERSION=\"3.8\"",
236 "-DVPATH=\"\"",
237 "-DPREFIX=\"\"",
238 "-DEXEC_PREFIX=\"\"",
239 "-DPYTHONPATH=\"..:\"",
240 "-DANDROID_SKIP_ZIP_PATH",
241 "-DANDROID_SKIP_EXEC_PREFIX_PATH",
242 "-DANDROID_LIB_PYTHON_PATH=\"internal/stdlib\"",
243 "-DDATE=\"Dec 31 1969\"",
244 "-DTIME=\"23:59:59\"",
245 ],
246 static_libs: [
247 "libbase",
248 "libexpat",
249 "libz",
250 ],
251 target: {
252 linux_glibc_x86_64: {
253 host_ldlibs: ["-lutil"],
254 },
255 darwin: {
256 host_ldlibs: [
257 "-framework SystemConfiguration",
258 "-framework CoreFoundation",
259 ],
260 },
261 host: {
262 static_libs: ["libsqlite"],
263 },
264 // Use shared libsqlite for device side, otherwise
265 // the executable size will be really huge.
266 android: {
267 shared_libs: ["libsqlite"],
268 },
269 },
270}
271
272cc_library_static {
273 name: "py3-launcher-lib",
274 defaults: ["py3-launcher-defaults"],
275 cflags: ["-DPy_BUILD_CORE"],
276 srcs: [
277 // Makefile.pre.in MODULE_OBJS
278 "Modules/getpath.c",
279 "Modules/main.c",
280 "Modules/gcmodule.c",
281
282 // Makefile.pre.in LIBRARY_OBJS_OMIT_FROZEN
283 "Modules/getbuildinfo.c",
284 ],
285 whole_static_libs: [
286 "py3-interp",
287 "py3-c-modules",
288 ],
289 target: {
290 android: {
291 srcs: ["android/bionic/config.c"],
292 },
293 linux_bionic: {
294 srcs: ["android/bionic/config.c"],
295 },
296 linux_glibc_x86_64: {
297 srcs: ["android/linux_x86_64/config.c"],
298 },
299 darwin: {
300 srcs: ["android/darwin_x86_64/config.c"],
301 },
302 }
303}
304
305cc_binary {
306 name: "py3-launcher",
307 defaults: ["py3-launcher-defaults"],
308 srcs: ["android/launcher_main.cpp"],
309 static_libs: ["py3-launcher-lib"],
310}
311
312cc_binary {
313 name: "py3-launcher-autorun",
314 defaults: ["py3-launcher-defaults"],
315 srcs: ["android/launcher_main.cpp"],
316 static_libs: ["py3-launcher-lib"],
317 cflags: ["-DANDROID_AUTORUN"],
318}
319
320python_binary_host {
321 name: "py3-cmd",
322 autorun: false,
323 version: {
324 py3: {
325 embedded_launcher: true,
326 },
327 },
328}
329
330// Enabled extension py3-c-modules.
331
332cc_library_static {
333 name: "py3-c-modules",
334 defaults: ["py3-interp-defaults"],
335 cflags: [
336 "-DPy_BUILD_CORE_BUILTIN",
337 "-DUSE_PYEXPAT_CAPI",
338 ],
339 static_libs: [
340 "libexpat",
341 "libz",
342 ],
343 target: {
344 android: {
345 srcs: [":py3-c-modules-bionic"],
346 },
347 linux_bionic: {
348 srcs: [":py3-c-modules-bionic"],
349 },
350 linux_glibc_x86_64: {
351 srcs: [":py3-c-modules-linux_x86_64"],
352 },
353 darwin: {
354 srcs: [":py3-c-modules-darwin_x86_64"],
355 },
356 }
357}