Dan Willemsen | b3614d2 | 2019-10-07 16:06:34 -0700 | [diff] [blame] | 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 | |
| 15 | build = ["Android-bionic.bp", "Android-linux_x86_64.bp", "Android-darwin_x86_64.bp"] |
| 16 | |
| 17 | cc_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 | |
| 98 | cc_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 | |
| 231 | cc_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 | }, |
Jack He | 5e983f0 | 2019-11-07 17:21:40 -0800 | [diff] [blame] | 255 | linux: { |
| 256 | // Due to test infra limitations, Python native symbols are linked |
| 257 | // statically to py3-launcher(s). Hence, need this flag to export |
| 258 | // these symbols so that runtime imported native extensions can use |
| 259 | // them (e.g. PyBaseObject_Type) |
| 260 | ldflags: ["-Wl,--export-dynamic"], |
| 261 | }, |
Dan Willemsen | b3614d2 | 2019-10-07 16:06:34 -0700 | [diff] [blame] | 262 | darwin: { |
| 263 | host_ldlibs: [ |
| 264 | "-framework SystemConfiguration", |
| 265 | "-framework CoreFoundation", |
| 266 | ], |
| 267 | }, |
| 268 | host: { |
| 269 | static_libs: ["libsqlite"], |
| 270 | }, |
Dan Willemsen | b3614d2 | 2019-10-07 16:06:34 -0700 | [diff] [blame] | 271 | android: { |
Jack He | 5e983f0 | 2019-11-07 17:21:40 -0800 | [diff] [blame] | 272 | shared_libs: [ |
| 273 | // Use shared libsqlite for device side, otherwise |
| 274 | // the executable size will be really huge. |
| 275 | "libsqlite", |
| 276 | // Dependency from libbase |
| 277 | "liblog", |
| 278 | ], |
Dan Willemsen | b3614d2 | 2019-10-07 16:06:34 -0700 | [diff] [blame] | 279 | }, |
| 280 | }, |
| 281 | } |
| 282 | |
| 283 | cc_library_static { |
| 284 | name: "py3-launcher-lib", |
| 285 | defaults: ["py3-launcher-defaults"], |
| 286 | cflags: ["-DPy_BUILD_CORE"], |
| 287 | srcs: [ |
| 288 | // Makefile.pre.in MODULE_OBJS |
| 289 | "Modules/getpath.c", |
| 290 | "Modules/main.c", |
| 291 | "Modules/gcmodule.c", |
| 292 | |
| 293 | // Makefile.pre.in LIBRARY_OBJS_OMIT_FROZEN |
| 294 | "Modules/getbuildinfo.c", |
| 295 | ], |
| 296 | whole_static_libs: [ |
| 297 | "py3-interp", |
| 298 | "py3-c-modules", |
| 299 | ], |
| 300 | target: { |
| 301 | android: { |
| 302 | srcs: ["android/bionic/config.c"], |
| 303 | }, |
| 304 | linux_bionic: { |
| 305 | srcs: ["android/bionic/config.c"], |
| 306 | }, |
| 307 | linux_glibc_x86_64: { |
| 308 | srcs: ["android/linux_x86_64/config.c"], |
| 309 | }, |
| 310 | darwin: { |
| 311 | srcs: ["android/darwin_x86_64/config.c"], |
| 312 | }, |
| 313 | } |
| 314 | } |
| 315 | |
| 316 | cc_binary { |
| 317 | name: "py3-launcher", |
| 318 | defaults: ["py3-launcher-defaults"], |
| 319 | srcs: ["android/launcher_main.cpp"], |
| 320 | static_libs: ["py3-launcher-lib"], |
| 321 | } |
| 322 | |
| 323 | cc_binary { |
| 324 | name: "py3-launcher-autorun", |
| 325 | defaults: ["py3-launcher-defaults"], |
| 326 | srcs: ["android/launcher_main.cpp"], |
| 327 | static_libs: ["py3-launcher-lib"], |
| 328 | cflags: ["-DANDROID_AUTORUN"], |
| 329 | } |
| 330 | |
| 331 | python_binary_host { |
| 332 | name: "py3-cmd", |
| 333 | autorun: false, |
| 334 | version: { |
| 335 | py3: { |
| 336 | embedded_launcher: true, |
| 337 | }, |
| 338 | }, |
| 339 | } |
| 340 | |
| 341 | // Enabled extension py3-c-modules. |
| 342 | |
| 343 | cc_library_static { |
| 344 | name: "py3-c-modules", |
| 345 | defaults: ["py3-interp-defaults"], |
| 346 | cflags: [ |
| 347 | "-DPy_BUILD_CORE_BUILTIN", |
| 348 | "-DUSE_PYEXPAT_CAPI", |
| 349 | ], |
| 350 | static_libs: [ |
| 351 | "libexpat", |
| 352 | "libz", |
| 353 | ], |
| 354 | target: { |
| 355 | android: { |
| 356 | srcs: [":py3-c-modules-bionic"], |
| 357 | }, |
| 358 | linux_bionic: { |
| 359 | srcs: [":py3-c-modules-bionic"], |
| 360 | }, |
| 361 | linux_glibc_x86_64: { |
| 362 | srcs: [":py3-c-modules-linux_x86_64"], |
| 363 | }, |
| 364 | darwin: { |
| 365 | srcs: [":py3-c-modules-darwin_x86_64"], |
| 366 | }, |
| 367 | } |
| 368 | } |