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