From 762e7c11932cc0b4805f8d170d1d38ac293559b5 Mon Sep 17 00:00:00 2001 From: Eric Froemling Date: Thu, 17 Feb 2022 15:10:14 -0600 Subject: [PATCH] fixed ssl in embedded android python builds --- .efrocachemap | 52 +++++++++---------- .idea/dictionaries/ericf.xml | 2 + CHANGELOG.md | 4 ++ .../.idea/dictionaries/ericf.xml | 2 + src/ballistica/ballistica.cc | 4 +- tools/batools/pcommand.py | 19 +++++++ tools/efrotools/pybuild.py | 39 ++++++++++++-- tools/pcommand | 5 +- 8 files changed, 94 insertions(+), 33 deletions(-) diff --git a/.efrocachemap b/.efrocachemap index 84282397..c5f35717 100644 --- a/.efrocachemap +++ b/.efrocachemap @@ -3971,26 +3971,26 @@ "assets/src/ba_data/python/ba/_generated/__init__.py": "https://files.ballistica.net/cache/ba1/ee/e8/cad05aa531c7faf7ff7b96db7f6e", "assets/src/ba_data/python/ba/_generated/enums.py": "https://files.ballistica.net/cache/ba1/b2/e5/0ee0561e16257a32830645239f34", "ballisticacore-windows/Generic/BallisticaCore.ico": "https://files.ballistica.net/cache/ba1/89/c0/e32c7d2a35dc9aef57cc73b0911a", - "build/prefab/full/linux_arm64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/19/88/bee721cb91b789144af385051a4c", + "build/prefab/full/linux_arm64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/22/91/9788a455078b2c6ae6b0530b376f", "build/prefab/full/linux_arm64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/74/1d/fc9e33e565475daaac80da5252f0", - "build/prefab/full/linux_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/5e/0d/695a9630d7d8e0854677e9cafb11", - "build/prefab/full/linux_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/6a/a3/2342f7b5a6d0cfea8ab8538aeffb", - "build/prefab/full/linux_x86_64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/dc/a9/2a7105e237c54747d9463914250e", + "build/prefab/full/linux_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/c1/4b/87fc75b8f04952794a897fb19fc7", + "build/prefab/full/linux_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/e3/66/afbe79ac0d6fbd593ec1e549d5c0", + "build/prefab/full/linux_x86_64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/e4/73/d07113aab410b1c51090952bfafe", "build/prefab/full/linux_x86_64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/9c/7b/ac1a200be0f37078af0991faca3b", - "build/prefab/full/linux_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/6a/43/d0bc568c5378ef076f8d1f0b8ec4", - "build/prefab/full/linux_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/59/1b/b499905f6e70df7e99611c23f28d", - "build/prefab/full/mac_arm64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/4e/2e/012869ef811141cd2bdeafedcaa7", - "build/prefab/full/mac_arm64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/70/59/01049aa35f003beff73a72baa902", - "build/prefab/full/mac_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/98/d6/0bfc7ac39592f40ac15c13301950", - "build/prefab/full/mac_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/0e/f3/99a76b0325207a06316916a0f6ef", - "build/prefab/full/mac_x86_64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/42/35/b985490f2f3153d0c554378e884e", - "build/prefab/full/mac_x86_64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/36/9e/017ca8c14073eb5ff1d196397063", - "build/prefab/full/mac_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/a2/74/0fd3e925619cb638dae3bb049afc", - "build/prefab/full/mac_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/0f/b4/6054b8c07086fa5cdd1aa452a1c8", - "build/prefab/full/windows_x86_gui/debug/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/18/98/76ab24b86619cdb6f6d9190a2472", - "build/prefab/full/windows_x86_gui/release/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/e9/37/f8604ec9532fcb77de0c47adf4f7", - "build/prefab/full/windows_x86_server/debug/dist/BallisticaCoreHeadless.exe": "https://files.ballistica.net/cache/ba1/14/ae/534de726a92ad41f623c43d93136", - "build/prefab/full/windows_x86_server/release/dist/BallisticaCoreHeadless.exe": "https://files.ballistica.net/cache/ba1/e6/9c/03d5ade7a7ea9dd84ea55fbbee63", + "build/prefab/full/linux_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/c2/7c/0c439110ac2fdbeb5548ad35632b", + "build/prefab/full/linux_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/c1/41/fe950818630506df8fdfd04d674d", + "build/prefab/full/mac_arm64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/e4/a9/59db1426754a1c7716850c17be91", + "build/prefab/full/mac_arm64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/7e/c9/90e3afef7cc1aea9e11a252e3379", + "build/prefab/full/mac_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/6d/f6/41fcb16519bb5257c337749a78ea", + "build/prefab/full/mac_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/e3/f4/27e8aa597a15296c07cb77263451", + "build/prefab/full/mac_x86_64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/35/0c/be285aa08f62ac2420126455357c", + "build/prefab/full/mac_x86_64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/36/69/075a41d69723e230e9ae9ca0f6c7", + "build/prefab/full/mac_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/09/f3/e81bb333811f848a056f2a2d4c92", + "build/prefab/full/mac_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/8d/7b/e5d18bf5d8f78a9c2ac050f17979", + "build/prefab/full/windows_x86_gui/debug/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/5b/6d/1fcbd8637eb1c2d09a0ec042d2f9", + "build/prefab/full/windows_x86_gui/release/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/04/85/c400c05b6b6ea1d41cff444f2608", + "build/prefab/full/windows_x86_server/debug/dist/BallisticaCoreHeadless.exe": "https://files.ballistica.net/cache/ba1/07/1c/7c4e59c63f8a359c179a2a74a802", + "build/prefab/full/windows_x86_server/release/dist/BallisticaCoreHeadless.exe": "https://files.ballistica.net/cache/ba1/fe/37/e82e03fdf5b5396f975ab15cbc71", "build/prefab/lib/linux_arm64_gui/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/f9/29/302b9242929cb49edf898ed1ba7a", "build/prefab/lib/linux_arm64_gui/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/ed/9d/dd639f3199ec5bc1caf901987ff4", "build/prefab/lib/linux_arm64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/d2/f5/848874824f57b67c5b6b3c6a2baa", @@ -4007,14 +4007,14 @@ "build/prefab/lib/mac_x86_64_gui/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/9f/01/cfdeb633d83f043df25405c24e7b", "build/prefab/lib/mac_x86_64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/27/09/8433d1e7e83d80223a47bb6e9e57", "build/prefab/lib/mac_x86_64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/79/12/b247bac22dc3af4ade11f805901a", - "build/prefab/lib/windows/Debug_Win32/BallisticaCoreGenericInternal.lib": "https://files.ballistica.net/cache/ba1/31/b7/c12cb6e376240e5475e46dcfc325", - "build/prefab/lib/windows/Debug_Win32/BallisticaCoreGenericInternal.pdb": "https://files.ballistica.net/cache/ba1/41/72/d88d8c3630aa1e711dc33061ac83", - "build/prefab/lib/windows/Debug_Win32/BallisticaCoreHeadlessInternal.lib": "https://files.ballistica.net/cache/ba1/78/95/1e6a2ad9a8d8cf3915d6f9ed9370", - "build/prefab/lib/windows/Debug_Win32/BallisticaCoreHeadlessInternal.pdb": "https://files.ballistica.net/cache/ba1/8c/1e/72c7db17d8336f334f5513993de2", - "build/prefab/lib/windows/Release_Win32/BallisticaCoreGenericInternal.lib": "https://files.ballistica.net/cache/ba1/1f/cf/e621518d6f2e26a3a6cfbc14e2cb", - "build/prefab/lib/windows/Release_Win32/BallisticaCoreGenericInternal.pdb": "https://files.ballistica.net/cache/ba1/c5/82/0568e01475f020bd546db8061bf4", - "build/prefab/lib/windows/Release_Win32/BallisticaCoreHeadlessInternal.lib": "https://files.ballistica.net/cache/ba1/7c/4e/7ef7b3ddfc3eb9b8dd5633ab0d5a", - "build/prefab/lib/windows/Release_Win32/BallisticaCoreHeadlessInternal.pdb": "https://files.ballistica.net/cache/ba1/db/92/605afe5812c552e89a8aeafd54ee", + "build/prefab/lib/windows/Debug_Win32/BallisticaCoreGenericInternal.lib": "https://files.ballistica.net/cache/ba1/da/a3/75db770dd02eb2049fa84de64a3b", + "build/prefab/lib/windows/Debug_Win32/BallisticaCoreGenericInternal.pdb": "https://files.ballistica.net/cache/ba1/b4/e7/0e6c1bdc7b66093c5613dfbb5c5d", + "build/prefab/lib/windows/Debug_Win32/BallisticaCoreHeadlessInternal.lib": "https://files.ballistica.net/cache/ba1/04/2d/0c5eb518b40c9c31cafad1bab5d5", + "build/prefab/lib/windows/Debug_Win32/BallisticaCoreHeadlessInternal.pdb": "https://files.ballistica.net/cache/ba1/42/f3/ac8ddc452b6380f902f3de61f180", + "build/prefab/lib/windows/Release_Win32/BallisticaCoreGenericInternal.lib": "https://files.ballistica.net/cache/ba1/58/c8/ab5043d41c6bd0d556e037cfca97", + "build/prefab/lib/windows/Release_Win32/BallisticaCoreGenericInternal.pdb": "https://files.ballistica.net/cache/ba1/c6/16/a8a82b70227523b5ee154763468d", + "build/prefab/lib/windows/Release_Win32/BallisticaCoreHeadlessInternal.lib": "https://files.ballistica.net/cache/ba1/36/76/be5b138bcdefd00a033c657b004c", + "build/prefab/lib/windows/Release_Win32/BallisticaCoreHeadlessInternal.pdb": "https://files.ballistica.net/cache/ba1/53/91/c294c4bd174ce28f2546dd9a57b4", "src/ballistica/generated/python_embedded/binding.inc": "https://files.ballistica.net/cache/ba1/c5/18/29d9fe8e483ce222d3263336f7e6", "src/ballistica/generated/python_embedded/bootstrap.inc": "https://files.ballistica.net/cache/ba1/9d/7e/0a5125aa421e722c59d22b8beb19" } \ No newline at end of file diff --git a/.idea/dictionaries/ericf.xml b/.idea/dictionaries/ericf.xml index 32dc7073..f90bcf08 100644 --- a/.idea/dictionaries/ericf.xml +++ b/.idea/dictionaries/ericf.xml @@ -299,6 +299,7 @@ cachefile cachemap cachepath + cafile calced calcing calcs @@ -949,6 +950,7 @@ getcurrency getcwd getdata + getenv gethostbyname getifaddr getinputdevice diff --git a/CHANGELOG.md b/CHANGELOG.md index db9799e9..773b65db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +### 1.6.9 (20461, 2022-02-17) +- Upgraded Android Python to 3.9.10 +- Fixed an issue with SSL in Android builds that was preventing communication with the master-server in 1.6.8 + ### 1.6.8 (20458, 2022-02-16) - Added Filipino language (Thanks David!) - Restored pre-v1.5 jump behaviour. diff --git a/ballisticacore-cmake/.idea/dictionaries/ericf.xml b/ballisticacore-cmake/.idea/dictionaries/ericf.xml index 10be43f6..1ffa37a4 100644 --- a/ballisticacore-cmake/.idea/dictionaries/ericf.xml +++ b/ballisticacore-cmake/.idea/dictionaries/ericf.xml @@ -153,6 +153,7 @@ buttonwidget bwst cacert + cafile calced calcing calcs @@ -451,6 +452,7 @@ getbitshigh getcollidemodel getdata + getenv gethostbyname getifaddr getifaddrs diff --git a/src/ballistica/ballistica.cc b/src/ballistica/ballistica.cc index ab5a9b03..96a921db 100644 --- a/src/ballistica/ballistica.cc +++ b/src/ballistica/ballistica.cc @@ -21,8 +21,8 @@ namespace ballistica { // These are set automatically via script; don't modify them here. -const int kAppBuildNumber = 20459; -const char* kAppVersion = "1.6.8"; +const int kAppBuildNumber = 20461; +const char* kAppVersion = "1.6.9"; // Our standalone globals. // These are separated out for easy access. diff --git a/tools/batools/pcommand.py b/tools/batools/pcommand.py index 9f7bc20b..037cec4b 100644 --- a/tools/batools/pcommand.py +++ b/tools/batools/pcommand.py @@ -1,5 +1,6 @@ # Released under the MIT License. See LICENSE for details. # +# pylint: disable=too-many-lines """A nice collection of ready-to-use pcommands for this package.""" from __future__ import annotations @@ -301,6 +302,18 @@ def gen_fulltest_buildfile_linux() -> None: batools.build.gen_fulltest_buildfile_linux() +def python_version_android() -> None: + """Print Android embedded Python version.""" + from efrotools.pybuild import PY_VER_EXACT_ANDROID + print(PY_VER_EXACT_ANDROID, end='') + + +def python_version_apple() -> None: + """Print Apple embedded Python version.""" + from efrotools.pybuild import PY_VER_EXACT_APPLE + print(PY_VER_EXACT_APPLE, end='') + + def python_build_apple() -> None: """Build an embeddable python for mac/ios/tvos.""" _python_build_apple(debug=False) @@ -360,6 +373,12 @@ def python_android_patch() -> None: pybuild.android_patch() +def python_android_patch_ssl() -> None: + """Patches Python ssl to prep for building for Android.""" + from efrotools import pybuild + pybuild.android_patch_ssl() + + def python_apple_patch() -> None: """Patches Python to prep for building for Apple platforms.""" from efrotools import pybuild diff --git a/tools/efrotools/pybuild.py b/tools/efrotools/pybuild.py index 1c46ab39..4b9f7dab 100644 --- a/tools/efrotools/pybuild.py +++ b/tools/efrotools/pybuild.py @@ -15,7 +15,7 @@ if TYPE_CHECKING: ENABLE_OPENSSL = True NEWER_PY_TEST = True -PY_VER_EXACT_ANDROID = '3.9.7' +PY_VER_EXACT_ANDROID = '3.9.10' PY_VER_EXACT_APPLE = '3.9.6' # Filenames we prune from Python lib dirs in source repo to cut down on size. @@ -177,6 +177,17 @@ def build_android(rootdir: str, arch: str, debug: bool = False) -> None: ftxt, "source = 'https://www.openssl.org/source/openssl-1.1.1h.tar.gz'", "source = 'https://www.openssl.org/source/openssl-1.1.1l.tar.gz'") + + # Give ourselves a handle to patch the OpenSSL build. + ftxt = replace_one( + ftxt, + ' # OpenSSL handles NDK internal paths by itself', + ' # Ericf addition: do some patching:\n' + ' self.run(["../../../../../../../tools/pcommand",' + ' "python_android_patch_ssl"])\n' + ' # OpenSSL handles NDK internal paths by itself', + ) + writefile('Android/build_deps.py', ftxt) # Tweak some things in the base build script; grab the right version @@ -190,8 +201,6 @@ def build_android(rootdir: str, arch: str, debug: bool = False) -> None: writefile('build.sh', ftxt) # Ok, let 'er rip - # (we often run these builds in parallel so limit to 1 job a piece; - # otherwise they each inherit the -j12 or whatever from the top level). exargs = ' --with-pydebug' if debug else '' run(f'ARCH={arch} ANDROID_API=21 ./build.sh{exargs}') print('python build complete! (android/' + arch + ')') @@ -348,6 +357,30 @@ def _patch_setup_file(platform: str, arch: str) -> None: writefile(fname, txt) +def android_patch_ssl() -> None: + """Run necessary patches on an android ssl before building.""" + + # We bundle our own SSL root certificates on various platforms and use + # the OpenSSL 'SSL_CERT_FILE' env var override to get them to be used + # by default. However, OpenSSL is picky about allowing env-vars to be + # used and something about the Android environment makes it disallow + # them. So we need to force the issue. Alternately we could explicitly + # pass 'cafile' args to SSLContexts whenever we do network-y stuff + # but it seems cleaner to just have things work by default. + fname = 'crypto/getenv.c' + txt = readfile(fname) + txt = replace_one( + txt, + ('char *ossl_safe_getenv(const char *name)\n' + '{\n'), + ('char *ossl_safe_getenv(const char *name)\n' + '{\n' + ' // ERICF TWEAK: ALWAYS ALLOW GETENV.\n' + ' return getenv(name);\n'), + ) + writefile(fname, txt) + + def winprune() -> None: """Prune unneeded files from windows python dists.""" for libdir in ('assets/src/windows/Win32/Lib', diff --git a/tools/pcommand b/tools/pcommand index 2928e795..f9fd1aaa 100755 --- a/tools/pcommand +++ b/tools/pcommand @@ -30,8 +30,9 @@ from batools.pcommand import ( get_master_asset_src_dir, androidaddr, push_ipa, printcolors, gen_fulltest_buildfile_android, gen_fulltest_buildfile_windows, gen_fulltest_buildfile_apple, gen_fulltest_buildfile_linux, - python_build_apple, python_build_apple_debug, python_build_android, - python_build_android_debug, python_android_patch, python_apple_patch, + python_version_android, python_version_apple, python_build_apple, + python_build_apple_debug, python_build_android, python_build_android_debug, + python_android_patch, python_android_patch_ssl, python_apple_patch, python_gather, python_winprune, capitalize, upper, efrocache_update, efrocache_get, get_modern_make, warm_start_asset_build, gendocs, update_docs_md, list_pip_reqs, install_pip_reqs, checkenv,