| // Copyright 2019 Google Inc. All rights reserved. | |
| // | |
| // Licensed under the Apache License, Version 2.0 (the "License"); | |
| // you may not use this file except in compliance with the License. | |
| // You may obtain a copy of the License at | |
| // | |
| // http://www.apache.org/licenses/LICENSE-2.0 | |
| // | |
| // Unless required by applicable law or agreed to in writing, software | |
| // distributed under the License is distributed on an "AS IS" BASIS, | |
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| // See the License for the specific language governing permissions and | |
| // limitations under the License. | |
| // *** THIS PACKAGE HAS SPECIAL LICENSING CONDITIONS. PLEASE | |
| // CONSULT THE OWNERS AND opensource-licensing@google.com BEFORE | |
| // DEPENDING ON IT IN YOUR PROJECT. *** | |
| package { | |
| default_applicable_licenses: ["external_python_cpython3_license"], | |
| } | |
| // Added automatically by a large-scale-change that took the approach of | |
| // 'apply every license found to every target'. While this makes sure we respect | |
| // every license restriction, it may not be entirely correct. | |
| // | |
| // e.g. GPL in an MIT project might only apply to the contrib/ directory. | |
| // | |
| // Please consider splitting the single license below into multiple licenses, | |
| // taking care not to lose any license_kind information, and overriding the | |
| // default license using the 'licenses: [...]' property on targets as needed. | |
| // | |
| // For unused files, consider creating a 'fileGroup' with "//visibility:private" | |
| // to attach the license to, and including a comment whether the files may be | |
| // used in the current project. | |
| // See: http://go/android-license-faq | |
| license { | |
| name: "external_python_cpython3_license", | |
| visibility: [":__subpackages__"], | |
| license_kinds: [ | |
| "SPDX-license-identifier-0BSD", | |
| "SPDX-license-identifier-Apache-2.0", | |
| "SPDX-license-identifier-BSD", | |
| "SPDX-license-identifier-CC0-1.0", | |
| "SPDX-license-identifier-GPL", | |
| "SPDX-license-identifier-MIT", | |
| "SPDX-license-identifier-MS-RL", // by exception only | |
| "SPDX-license-identifier-PSF-2.0", | |
| "SPDX-license-identifier-Unicode-DFS", | |
| "SPDX-license-identifier-W3C", | |
| "SPDX-license-identifier-Zlib", | |
| "legacy_by_exception_only", // by exception only | |
| "legacy_notice", | |
| "legacy_unencumbered", | |
| ], | |
| license_text: [ | |
| "LICENSE", | |
| ], | |
| } | |
| build = [ | |
| "Android-bionic.bp", | |
| "Android-linux_x86_64.bp", | |
| "Android-darwin_x86_64.bp", | |
| ] | |
| soong_config_module_type { | |
| name: "cpython3_cc_defaults", | |
| module_type: "cc_defaults", | |
| config_namespace: "cpython3", | |
| bool_variables: ["force_build_host"], | |
| properties: ["defaults"], | |
| } | |
| // By default, disable the source and use the prebuilts for host linux | |
| // and darwin. Overridden by cpython3-interp-force_build_host when | |
| // force_build_host is true (set on aosp-build-tools). | |
| cc_defaults { | |
| name: "cpython3-interp-host-prebuilts", | |
| defaults_visibility: ["//visibility:private"], | |
| target: { | |
| linux_glibc: { | |
| enabled: false, | |
| }, | |
| linux_musl: { | |
| enabled: false, | |
| }, | |
| darwin: { | |
| enabled: false, | |
| }, | |
| }, | |
| } | |
| cc_defaults { | |
| name: "cpython3-interp-force_build_host", | |
| defaults_visibility: ["//visibility:private"], | |
| target: { | |
| linux_glibc: { | |
| enabled: true, | |
| }, | |
| linux_musl: { | |
| enabled: true, | |
| }, | |
| darwin: { | |
| enabled: true, | |
| }, | |
| }, | |
| } | |
| cpython3_cc_defaults { | |
| name: "py3-interp-defaults", | |
| defaults_visibility: ["//visibility:private"], | |
| cflags: [ | |
| "-fwrapv", | |
| "-O3", | |
| "-Wall", | |
| "-Wstrict-prototypes", | |
| "-DPy_BUILD_CORE", | |
| "-Werror", | |
| "-Wno-invalid-source-encoding", | |
| "-Wno-int-conversion", | |
| "-Wno-missing-field-initializers", | |
| "-Wno-null-pointer-arithmetic", | |
| "-Wno-register", | |
| "-Wno-shift-count-overflow", | |
| "-Wno-sign-compare", | |
| "-Wno-tautological-compare", | |
| "-Wno-tautological-constant-out-of-range-compare", | |
| "-Wno-unused-function", | |
| "-Wno-unused-parameter", | |
| "-Wno-unused-result", | |
| ], | |
| local_include_dirs: [ | |
| "Include", | |
| "Include/internal", | |
| ], | |
| static_libs: ["libffi"], | |
| target: { | |
| android: { | |
| local_include_dirs: ["android/bionic/pyconfig"], | |
| }, | |
| android_arm: { | |
| cflags: ["-DSOABI=\"cpython-310android-arm-android-bionic\""], | |
| }, | |
| android_arm64: { | |
| cflags: ["-DSOABI=\"cpython-310android-arm64-android-bionic\""], | |
| }, | |
| android_x86: { | |
| cflags: ["-DSOABI=\"cpython-310android-x86-android-bionic\""], | |
| }, | |
| android_x86_64: { | |
| cflags: ["-DSOABI=\"cpython-310android-x86_64-android-bionic\""], | |
| }, | |
| host: { | |
| // Host builds are moving to prebuilts, which has a higher risk of | |
| // having an incompatible libc++.so when installed. | |
| stl: "libc++_static", | |
| }, | |
| // Regenerate include dirs with android_regen.sh | |
| darwin_x86_64: { | |
| local_include_dirs: ["android/darwin_x86_64/pyconfig"], | |
| cflags: [ | |
| "-Wno-deprecated-declarations", | |
| "-Wno-pointer-arith", | |
| "-DSOABI=\"cpython-310android-x86_64-darwin\"", | |
| ], | |
| }, | |
| linux_bionic: { | |
| // NB linux_bionic is a 'host' architecture but it uses the bionic libc like 'android' | |
| // targets so use the android pyconfig. | |
| local_include_dirs: ["android/bionic/pyconfig"], | |
| cflags: ["-DSOABI=\"cpython-310android-x86_64-linux-bionic\""], | |
| }, | |
| linux_glibc_x86: { | |
| enabled: false, | |
| }, | |
| linux_musl_x86: { | |
| enabled: false, | |
| }, | |
| linux_glibc_x86_64: { | |
| local_include_dirs: ["android/linux_x86_64/pyconfig"], | |
| cflags: ["-DSOABI=\"cpython-310android-x86_64-linux-gnu\""], | |
| }, | |
| linux_musl_x86_64: { | |
| local_include_dirs: ["android/linux_x86_64/pyconfig"], | |
| cflags: ["-DSOABI=\"cpython-310android-x86_64-linux-gnu\""], | |
| }, | |
| windows: { | |
| enabled: false, | |
| }, | |
| }, | |
| host_supported: true, | |
| compile_multilib: "both", | |
| multilib: { | |
| lib32: { | |
| suffix: "32", | |
| }, | |
| lib64: { | |
| suffix: "64", | |
| }, | |
| }, | |
| soong_config_variables: { | |
| force_build_host: { | |
| defaults: ["cpython3-interp-force_build_host"], | |
| }, | |
| }, | |
| } | |
| cc_library_static { | |
| name: "py3-interp", | |
| defaults: ["py3-interp-defaults", "cpython3-interp-host-prebuilts"], | |
| cflags: ["-DPy_BUILD_CORE", "-DPLATLIBDIR=\"lib\""], | |
| srcs: [ | |
| // Makefile.pre.in PEGEN_OBJS | |
| "Parser/pegen.c", | |
| "Parser/parser.c", | |
| "Parser/string_parser.c", | |
| "Parser/peg_api.c", | |
| // Makefile.pre.in PARSER_OBJS | |
| "Parser/myreadline.c", | |
| "Parser/token.c", | |
| "Parser/tokenizer.c", | |
| // Makefile.pre.in OBJECT_OBJS | |
| "Objects/abstract.c", | |
| "Objects/accu.c", | |
| "Objects/boolobject.c", | |
| "Objects/bytes_methods.c", | |
| "Objects/bytearrayobject.c", | |
| "Objects/bytesobject.c", | |
| "Objects/call.c", | |
| "Objects/capsule.c", | |
| "Objects/cellobject.c", | |
| "Objects/classobject.c", | |
| "Objects/codeobject.c", | |
| "Objects/complexobject.c", | |
| "Objects/descrobject.c", | |
| "Objects/enumobject.c", | |
| "Objects/exceptions.c", | |
| "Objects/genericaliasobject.c", | |
| "Objects/genobject.c", | |
| "Objects/fileobject.c", | |
| "Objects/floatobject.c", | |
| "Objects/frameobject.c", | |
| "Objects/funcobject.c", | |
| "Objects/interpreteridobject.c", | |
| "Objects/iterobject.c", | |
| "Objects/listobject.c", | |
| "Objects/longobject.c", | |
| "Objects/dictobject.c", | |
| "Objects/odictobject.c", | |
| "Objects/memoryobject.c", | |
| "Objects/methodobject.c", | |
| "Objects/moduleobject.c", | |
| "Objects/namespaceobject.c", | |
| "Objects/object.c", | |
| "Objects/obmalloc.c", | |
| "Objects/picklebufobject.c", | |
| "Objects/rangeobject.c", | |
| "Objects/setobject.c", | |
| "Objects/sliceobject.c", | |
| "Objects/structseq.c", | |
| "Objects/tupleobject.c", | |
| "Objects/typeobject.c", | |
| "Objects/unicodeobject.c", | |
| "Objects/unicodectype.c", | |
| "Objects/unionobject.c", | |
| "Objects/weakrefobject.c", | |
| // Makefile.pre.in PYTHON_OBJS | |
| "Python/_warnings.c", | |
| "Python/Python-ast.c", | |
| "Python/asdl.c", | |
| "Python/ast.c", | |
| "Python/ast_opt.c", | |
| "Python/ast_unparse.c", | |
| "Python/bltinmodule.c", | |
| "Python/ceval.c", | |
| "Python/codecs.c", | |
| "Python/compile.c", | |
| "Python/context.c", | |
| "Python/dynamic_annotations.c", | |
| "Python/errors.c", | |
| "Python/frozen.c", | |
| "Python/frozenmain.c", | |
| "Python/future.c", | |
| "Python/getargs.c", | |
| "Python/getcompiler.c", | |
| "Python/getcopyright.c", | |
| "Python/getplatform.c", | |
| "Python/getversion.c", | |
| "Python/hamt.c", | |
| "Python/hashtable.c", | |
| "Python/import.c", | |
| "Python/importdl.c", | |
| "Python/initconfig.c", | |
| "Python/marshal.c", | |
| "Python/modsupport.c", | |
| "Python/mysnprintf.c", | |
| "Python/mystrtoul.c", | |
| "Python/pathconfig.c", | |
| "Python/preconfig.c", | |
| "Python/pyarena.c", | |
| "Python/pyctype.c", | |
| "Python/pyfpe.c", | |
| "Python/pyhash.c", | |
| "Python/pylifecycle.c", | |
| "Python/pymath.c", | |
| "Python/pystate.c", | |
| "Python/pythonrun.c", | |
| "Python/pytime.c", | |
| "Python/bootstrap_hash.c", | |
| "Python/structmember.c", | |
| "Python/symtable.c", | |
| "Python/sysmodule.c", | |
| "Python/thread.c", | |
| "Python/traceback.c", | |
| "Python/getopt.c", | |
| "Python/pystrcmp.c", | |
| "Python/pystrtod.c", | |
| "Python/pystrhex.c", | |
| "Python/dtoa.c", | |
| "Python/formatter_unicode.c", | |
| "Python/fileutils.c", | |
| "Python/suggestions.c", | |
| "Python/dynload_shlib.c", | |
| ], | |
| target: { | |
| linux: { | |
| cflags: [ | |
| "-DPLATFORM=\"linux\"", | |
| "-DABIFLAGS=\"\"", | |
| ], | |
| }, | |
| darwin_x86_64: { | |
| cflags: [ | |
| "-DPLATFORM=\"darwin\"", | |
| "-DABIFLAGS=\"\"", | |
| ], | |
| }, | |
| }, | |
| } | |
| cc_defaults { | |
| name: "py3-launcher-defaults", | |
| defaults: ["py3-interp-defaults", "cpython3-interp-host-prebuilts"], | |
| cflags: [ | |
| "-DVERSION=\"3.10\"", | |
| "-DVPATH=\"\"", | |
| "-DPREFIX=\"\"", | |
| "-DEXEC_PREFIX=\"\"", | |
| "-DPYTHONPATH=\"..:\"", | |
| "-DANDROID_SKIP_ZIP_PATH", | |
| "-DANDROID_SKIP_EXEC_PREFIX_PATH", | |
| "-DANDROID_LIB_PYTHON_PATH=\"internal/stdlib\"", | |
| "-DDATE=\"Dec 31 1969\"", | |
| "-DTIME=\"23:59:59\"", | |
| ], | |
| static_libs: [ | |
| "libbase", | |
| "libexpat", | |
| "libz", | |
| ], | |
| target: { | |
| linux_glibc_x86_64: { | |
| host_ldlibs: ["-lutil"], | |
| }, | |
| linux: { | |
| // Due to test infra limitations, Python native symbols are linked | |
| // statically to py3-launcher(s). Hence, need this flag to export | |
| // these symbols so that runtime imported native extensions can use | |
| // them (e.g. PyBaseObject_Type) | |
| ldflags: ["-Wl,--export-dynamic"], | |
| }, | |
| darwin: { | |
| host_ldlibs: [ | |
| "-framework SystemConfiguration", | |
| "-framework CoreFoundation", | |
| ], | |
| }, | |
| host: { | |
| static_libs: [ | |
| "libsqlite", | |
| "liblog", | |
| "libopenssl_ssl", | |
| "libopenssl_crypto", | |
| ], | |
| }, | |
| linux_bionic: { | |
| // Linux Bionic doesn't have openssl prebuilts | |
| exclude_static_libs: [ | |
| "libopenssl_ssl", | |
| "libopenssl_crypto", | |
| ], | |
| }, | |
| android: { | |
| shared_libs: [ | |
| // Use shared libsqlite for device side, otherwise | |
| // the executable size will be really huge. | |
| "libsqlite", | |
| // Dependency from libbase | |
| "liblog", | |
| ], | |
| }, | |
| }, | |
| } | |
| cc_library_static { | |
| name: "py3-launcher-lib", | |
| defaults: ["py3-launcher-defaults"], | |
| cflags: ["-DPy_BUILD_CORE"], | |
| srcs: [ | |
| // Makefile.pre.in MODULE_OBJS | |
| "Modules/getpath.c", | |
| "Modules/main.c", | |
| "Modules/gcmodule.c", | |
| // Makefile.pre.in LIBRARY_OBJS_OMIT_FROZEN | |
| "Modules/getbuildinfo.c", | |
| ], | |
| whole_static_libs: [ | |
| "py3-interp", | |
| "py3-c-modules", | |
| ], | |
| target: { | |
| android: { | |
| srcs: ["android/bionic/config.c"], | |
| }, | |
| linux_bionic: { | |
| srcs: ["android/bionic/config.c"], | |
| }, | |
| glibc_x86_64: { | |
| srcs: ["android/linux_x86_64/config.c"], | |
| }, | |
| musl_x86_64: { | |
| srcs: ["android/linux_x86_64/config.c"], | |
| }, | |
| darwin: { | |
| srcs: ["android/darwin_x86_64/config.c"], | |
| }, | |
| }, | |
| } | |
| cc_binary { | |
| name: "py3-launcher", | |
| defaults: ["py3-launcher-defaults"], | |
| srcs: ["android/launcher_main.cpp"], | |
| static_libs: ["py3-launcher-lib"], | |
| } | |
| cc_binary { | |
| name: "py3-launcher-autorun", | |
| defaults: ["py3-launcher-defaults"], | |
| srcs: ["android/launcher_main.cpp"], | |
| static_libs: ["py3-launcher-lib"], | |
| cflags: ["-DANDROID_AUTORUN"], | |
| } | |
| cc_binary_host { | |
| name: "py3-launcher-static", | |
| defaults: ["py3-launcher-defaults"], | |
| srcs: ["android/launcher_main.cpp"], | |
| static_libs: ["py3-launcher-lib"], | |
| static_executable: true, | |
| target: { | |
| glibc: { | |
| enabled: false, | |
| }, | |
| }, | |
| } | |
| cc_binary_host { | |
| name: "py3-launcher-autorun-static", | |
| defaults: ["py3-launcher-defaults"], | |
| srcs: ["android/launcher_main.cpp"], | |
| static_libs: ["py3-launcher-lib"], | |
| static_executable: true, | |
| cflags: ["-DANDROID_AUTORUN"], | |
| target: { | |
| glibc: { | |
| enabled: false, | |
| }, | |
| }, | |
| } | |
| python_binary_host { | |
| name: "py3-cmd", | |
| autorun: false, | |
| version: { | |
| py3: { | |
| embedded_launcher: true, | |
| }, | |
| }, | |
| } | |
| // Enabled extension py3-c-modules. | |
| cc_library_static { | |
| name: "py3-c-modules", | |
| defaults: ["py3-interp-defaults", "cpython3-interp-host-prebuilts"], | |
| cflags: [ | |
| "-DPy_BUILD_CORE_BUILTIN", | |
| "-DUSE_PYEXPAT_CAPI", | |
| ], | |
| static_libs: [ | |
| "libexpat", | |
| "libz", | |
| ], | |
| target: { | |
| android: { | |
| srcs: [":py3-c-modules-bionic"], | |
| }, | |
| linux_bionic: { | |
| srcs: [":py3-c-modules-bionic"], | |
| }, | |
| glibc_x86_64: { | |
| srcs: [":py3-c-modules-linux_x86_64"], | |
| static_libs: [ | |
| "libopenssl_ssl", | |
| "libopenssl_crypto", | |
| ], | |
| }, | |
| musl_x86_64: { | |
| srcs: [":py3-c-modules-linux_x86_64"], | |
| static_libs: [ | |
| "libopenssl_ssl", | |
| "libopenssl_crypto", | |
| ], | |
| }, | |
| darwin: { | |
| cflags: ["-D__APPLE_USE_RFC_3542"], | |
| srcs: [":py3-c-modules-darwin_x86_64"], | |
| static_libs: [ | |
| "libopenssl_ssl", | |
| "libopenssl_crypto", | |
| ], | |
| }, | |
| }, | |
| } |