From 50ba2a825f8d31d858f0044c725a6e839b690eb0 Mon Sep 17 00:00:00 2001 From: Eric Date: Mon, 5 Jun 2023 15:13:22 -0700 Subject: [PATCH] cleaning up imports --- .efrocachemap | 59 ++++++++++--------- CHANGELOG.md | 2 +- Makefile | 25 ++++++-- src/assets/Makefile | 40 +++++++++---- src/assets/ba_data/python/babase/__init__.py | 3 + .../ba_data/python/baclassic/__init__.py | 6 ++ src/assets/ba_data/python/baenv.py | 2 +- src/ballistica/base/base.cc | 26 ++++++-- src/ballistica/base/base.h | 8 +++ src/ballistica/base/python/base_python.cc | 17 ++++-- src/ballistica/base/python/base_python.h | 1 + .../base/python/methods/python_methods_app.cc | 21 +++++++ .../python/methods/python_methods_misc.cc | 14 ++--- src/ballistica/shared/ballistica.cc | 2 +- src/ballistica/shared/foundation/exception.cc | 1 + src/meta/.meta_manifest_public.json | 1 + src/meta/Makefile | 5 ++ src/meta/babasemeta/pyembed/binding_base.py | 43 +++++++------- .../babasemeta/pyembed/binding_base_app.py | 16 +++++ tests/test_babase/test_imports.py | 36 +++++++++++ tools/batools/metabuild.py | 2 +- 21 files changed, 241 insertions(+), 89 deletions(-) create mode 100644 src/meta/babasemeta/pyembed/binding_base_app.py create mode 100644 tests/test_babase/test_imports.py diff --git a/.efrocachemap b/.efrocachemap index f171b9d7..60be97ed 100644 --- a/.efrocachemap +++ b/.efrocachemap @@ -4072,26 +4072,26 @@ "build/assets/workspace/ninjafightplug.py": "https://files.ballistica.net/cache/ba1/c5/09/4f10b8a21ba87aa5509cff7a164b", "build/assets/workspace/onslaughtplug.py": "https://files.ballistica.net/cache/ba1/ff/0a/a354984f9c074dab0676ac7e4877", "build/assets/workspace/runaroundplug.py": "https://files.ballistica.net/cache/ba1/2a/1c/9ee5db6d1bceca7fa6638fb8abde", - "build/prefab/full/linux_arm64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/c0/79/2c4deedb2f4ae0605fb23b470e5e", - "build/prefab/full/linux_arm64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/84/53/b2997dafa33a556edf38fb718a64", - "build/prefab/full/linux_arm64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/68/39/967044137522d0f63dad68964121", - "build/prefab/full/linux_arm64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/b1/d9/9bb7d41fb9cef93b337b4130f2c6", - "build/prefab/full/linux_x86_64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/6a/f2/f5a39157492836a8951617cf1c52", - "build/prefab/full/linux_x86_64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/51/6d/c4d30cc9b6a2a2307b5ace1034c7", - "build/prefab/full/linux_x86_64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/f1/b3/cb1337766bdc80e8044301a94684", - "build/prefab/full/linux_x86_64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/75/f1/e920b2dca679bdea3f380c5c3d79", - "build/prefab/full/mac_arm64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/75/ad/6198226b21406baf4ded590d93c3", - "build/prefab/full/mac_arm64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/30/04/8f96290ae08af4aba87dddca1eb1", - "build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/ec/91/922e12835d497541fdd0d1ef0b4e", - "build/prefab/full/mac_arm64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/50/09/59ebde4bf5f04f2ffef0eb996ab3", - "build/prefab/full/mac_x86_64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/06/d6/ce832cdc3190f28044fd126f2484", - "build/prefab/full/mac_x86_64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/57/10/4263803ef2547c767a1c00117362", - "build/prefab/full/mac_x86_64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/8a/40/00e7b3f482a9d18e02b54a987b15", - "build/prefab/full/mac_x86_64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/b9/c7/6eca9bd7f422031d5fb71ec516a5", - "build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "https://files.ballistica.net/cache/ba1/50/af/6f04a9dda5c2159cddc6b86fdb7c", - "build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "https://files.ballistica.net/cache/ba1/79/8b/7e56ca7e472eb16cc092dd5bfaea", - "build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "https://files.ballistica.net/cache/ba1/05/cc/0c39b74a642940c4161d51f18af1", - "build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "https://files.ballistica.net/cache/ba1/9b/4d/0554caf4dc0280ec827f68007e1e", + "build/prefab/full/linux_arm64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/43/64/22e077c0bbbf246e6323259231c9", + "build/prefab/full/linux_arm64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/32/a5/77f989dd565b3197c8f77df4a138", + "build/prefab/full/linux_arm64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/a2/fc/2f3622c8c980e394733b48c98421", + "build/prefab/full/linux_arm64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/b1/2f/dc3a847de05fcc6fdddc6d814ddb", + "build/prefab/full/linux_x86_64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/ec/4b/66a8fd1e680f2cb77f9f4559112c", + "build/prefab/full/linux_x86_64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/b2/55/64d847b58c501c80b4ea53678e9a", + "build/prefab/full/linux_x86_64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/9f/37/b4553f9f9fda9fb07d7f3f3ab2f6", + "build/prefab/full/linux_x86_64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/cf/b4/d955fed8589fd59e0f15e69ab568", + "build/prefab/full/mac_arm64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/65/a3/34afc32ae7905a49621520d7291b", + "build/prefab/full/mac_arm64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/b1/2f/33ad58bdcbcb2ac5de570b7b86d4", + "build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/b9/cf/969aad103e8da47cc2555b27bfba", + "build/prefab/full/mac_arm64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/d4/50/fc305556a2926c5c69004b49a09a", + "build/prefab/full/mac_x86_64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/45/ee/6dd5e336da0f28223a1b9338cb21", + "build/prefab/full/mac_x86_64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/bc/5d/513cbfa9287f138912cb73f61783", + "build/prefab/full/mac_x86_64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/a5/95/d11e6b2f8bcc23c83060a2678ed3", + "build/prefab/full/mac_x86_64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/e3/71/cd19381bd0a9c81f112dd90868ae", + "build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "https://files.ballistica.net/cache/ba1/54/3c/aa7e808f5e7a9fc4830290192f8b", + "build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "https://files.ballistica.net/cache/ba1/0c/73/2bb8dd3c39fcda244ee231b105a2", + "build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "https://files.ballistica.net/cache/ba1/c3/20/6823526bb3053a7d5708b50850b0", + "build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "https://files.ballistica.net/cache/ba1/3f/f7/bde95fd3a0c0f0fe6b4bdfa4ff12", "build/prefab/lib/linux_arm64_gui/debug/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/98/32/43c61f1e11520f764158cf0e76d2", "build/prefab/lib/linux_arm64_gui/release/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/ca/65/cba463f21a8f76c5bbfe27cae124", "build/prefab/lib/linux_arm64_server/debug/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/73/20/119211f1700bb5a410cedf4e76f2", @@ -4108,17 +4108,18 @@ "build/prefab/lib/mac_x86_64_gui/release/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/90/9b/94f733c3a48691e02240e04dc792", "build/prefab/lib/mac_x86_64_server/debug/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/2e/c7/873af48627997b6fab4b2c4ba6bc", "build/prefab/lib/mac_x86_64_server/release/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/3a/94/4780fada10f0fc3f43a54f29c86f", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.lib": "https://files.ballistica.net/cache/ba1/c4/91/26a6577d3b18a3f7969ac2c34e5b", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.pdb": "https://files.ballistica.net/cache/ba1/05/d3/45935dd94690fff9ffc59b66f7cd", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.lib": "https://files.ballistica.net/cache/ba1/56/ca/5f10225d3168b509d5017eca3e7f", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.pdb": "https://files.ballistica.net/cache/ba1/53/8f/f0a21bddc5327dbb6e2c35d1fba5", - "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.lib": "https://files.ballistica.net/cache/ba1/d9/e0/cbf307d586ae14a58d86fe511667", - "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.pdb": "https://files.ballistica.net/cache/ba1/e5/3d/2bc8f7e395279fa84fdaac18e86c", - "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.lib": "https://files.ballistica.net/cache/ba1/bd/51/d1c0bc28c859926ce83c240287c0", - "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.pdb": "https://files.ballistica.net/cache/ba1/20/1b/1ae6a6ce9e4d91842d3d42416007", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.lib": "https://files.ballistica.net/cache/ba1/98/da/0cdcca0ad9a3fa063015e1fe8425", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.pdb": "https://files.ballistica.net/cache/ba1/a0/ad/c9c494e942d2df60ef86f4967aef", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.lib": "https://files.ballistica.net/cache/ba1/46/50/88d144bb1d31fce5a1631df42f11", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.pdb": "https://files.ballistica.net/cache/ba1/5e/17/53028e65a32149b0209510d78895", + "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.lib": "https://files.ballistica.net/cache/ba1/ff/d8/98f7b6b84decd5cc59cd05fe3dc7", + "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.pdb": "https://files.ballistica.net/cache/ba1/62/9c/7e77ca7427670457e35736e094fe", + "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.lib": "https://files.ballistica.net/cache/ba1/e4/a4/9891c46bbdd361fb65d159869d1d", + "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.pdb": "https://files.ballistica.net/cache/ba1/15/4d/56ff31a63d9bf82ba8d6d4a42ee6", "src/assets/ba_data/python/babase/_mgen/__init__.py": "https://files.ballistica.net/cache/ba1/52/c6/c11130af7b10d6c0321add5518fa", "src/assets/ba_data/python/babase/_mgen/enums.py": "https://files.ballistica.net/cache/ba1/38/c3/1dedd5e74f2508efc5974c8815a1", - "src/ballistica/base/mgen/pyembed/binding_base.inc": "https://files.ballistica.net/cache/ba1/d5/4a/0e480a855ce83709bd7f6761107d", + "src/ballistica/base/mgen/pyembed/binding_base.inc": "https://files.ballistica.net/cache/ba1/4e/07/87dd93e7ef29b8b78d0b4791d6f8", + "src/ballistica/base/mgen/pyembed/binding_base_app.inc": "https://files.ballistica.net/cache/ba1/ff/44/8e2528bafe71c7fedda6a1e0ac4a", "src/ballistica/classic/mgen/pyembed/binding_classic.inc": "https://files.ballistica.net/cache/ba1/b2/fd/f5c362e9093b2d0721fb59fc0056", "src/ballistica/core/mgen/pyembed/binding_core.inc": "https://files.ballistica.net/cache/ba1/71/b8/c020cbb7f9a7ce3f347ccadd3df1", "src/ballistica/core/mgen/pyembed/env.inc": "https://files.ballistica.net/cache/ba1/49/37/a092e0e385093479c14d47c86b27", diff --git a/CHANGELOG.md b/CHANGELOG.md index 1616a7e9..45c21c50 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -### 1.7.20 (build 21046, api 8, 2023-06-04) +### 1.7.20 (build 21047, api 8, 2023-06-05) - This seems like a good time for a `refactoring` release in anticipation of changes coming in 1.8. Basically this means that a lot of things will be diff --git a/Makefile b/Makefile index e450bd02..2144276e 100644 --- a/Makefile +++ b/Makefile @@ -62,16 +62,21 @@ assets: prereqs meta @tools/pcommand lazybuild assets_src $(LAZYBUILDDIR)/$@ \ cd src/assets \&\& $(MAKE) -j$(CPUS) -# Build assets required for cmake builds (linux, mac) +# Build assets required for cmake builds (linux, mac). assets-cmake: prereqs meta @tools/pcommand lazybuild assets_src $(LAZYBUILDDIR)/$@ \ cd src/assets \&\& $(MAKE) -j$(CPUS) cmake -# Build only script assets required for cmake builds (linux, mac) +# Build only script assets required for cmake builds (linux, mac). assets-cmake-scripts: prereqs meta @tools/pcommand lazybuild assets_src $(LAZYBUILDDIR)/$@ \ cd src/assets \&\& $(MAKE) -j$(CPUS) scripts-cmake +# Build assets required for server builds. +assets-server: prereqs meta + @tools/pcommand lazybuild assets_src $(LAZYBUILDDIR)/$@ \ + cd src/assets \&\& $(MAKE) -j$(CPUS) server + # Build assets required for WINDOWS_PLATFORM windows builds. assets-windows: prereqs meta @tools/pcommand lazybuild assets_src $(LAZYBUILDDIR)/$@ \ @@ -850,10 +855,22 @@ build/dummymodules/.dummy_modules_state: \ # # ################################################################################ +# Set the following from the command line to influence the build: + +# Override this to run only particular tests. +# Examples: +# tests/test_efro +# tests/test_efro/test_message.py +TEST_TARGET ?= tests + # Run all tests. (live execution verification) test: py_check_prepass @tools/pcommand echo BLU Running all tests... - @tools/pcommand pytest -v tests + @tools/pcommand pytest -v $(TEST_TARGET) + +test-verbose: py_check_prepass + @tools/pcommand echo BLU Running all tests... + @tools/pcommand pytest -o log_cli=true -o log_cli_level=debug -s -vv $(TEST_TARGET) # Run tests with any caching disabled. test-full: test @@ -1071,7 +1088,7 @@ cmake-clean: cmake-server: cmake-server-build @cd build/cmake/server-$(CM_BT_LC) && ./ballisticakit_server -cmake-server-build: assets-cmake resources meta cmake-server-binary +cmake-server-build: assets-server meta cmake-server-binary @$(STAGE_ASSETS) -cmakeserver -$(CM_BT_LC) build/cmake/server-$(CM_BT_LC) @tools/pcommand echo BLD \ Server build complete: BLU build/cmake/server-$(CM_BT_LC) diff --git a/src/assets/Makefile b/src/assets/Makefile index c1f47d98..8c630dfb 100644 --- a/src/assets/Makefile +++ b/src/assets/Makefile @@ -35,6 +35,12 @@ cmake: @$(MAKE) assets-cmake @$(TOOLS_DIR)/pcommand clean_orphaned_assets +# Build everything needed for our server builds. +server: + @echo Note: skipping warm_start_asset_build for server target. + @$(MAKE) assets-server + @$(TOOLS_DIR)/pcommand clean_orphaned_assets + # Build everything needed for x86 windows builds. win-Win32: @$(TOOLS_DIR)/pcommand warm_start_asset_build @@ -71,8 +77,10 @@ MAKE_SCRIPTS = 1 MAKE_FONTS = 1 MAKE_DATA = 1 -ASSET_TARGETS_COMMON = +ASSET_TARGETS_COMMON_GUI = +ASSET_TARGETS_COMMON_SERVER = ASSET_TARGETS_CMAKE = +ASSET_TARGETS_SERVER = ASSET_TARGETS_MAC = ASSET_TARGETS_WIN_WIN32 = ASSET_TARGETS_WIN_X64 = @@ -81,17 +89,18 @@ ASSET_TARGETS_ANDROID = # Audio. ifeq ($(MAKE_AUDIO),1) -ASSET_TARGETS_COMMON += $(AUDIO_TARGETS) +ASSET_TARGETS_COMMON_GUI += $(AUDIO_TARGETS) endif # FontData. ifeq ($(MAKE_FONTS),1) -ASSET_TARGETS_COMMON += $(FONT_TARGETS) +ASSET_TARGETS_COMMON_GUI += $(FONT_TARGETS) endif # Data. ifeq ($(MAKE_DATA),1) -ASSET_TARGETS_COMMON += $(DATA_TARGETS) +ASSET_TARGETS_COMMON_GUI += $(DATA_TARGETS) +ASSET_TARGETS_COMMON_SERVER += $(DATA_TARGETS) endif # Textures. @@ -103,19 +112,21 @@ ASSET_TARGETS_WIN_WIN32 += $(TEXTURE_TARGETS_WIN) ASSET_TARGETS_WIN_X64 += $(TEXTURE_TARGETS_WIN) ASSET_TARGETS_IOS += $(TEXTURE_TARGETS_IOS) ASSET_TARGETS_ANDROID += $(TEXTURE_TARGETS_ANDROID) -ASSET_TARGETS_COMMON += $(TEXTURE_TARGETS_COMMON) +ASSET_TARGETS_COMMON_GUI += $(TEXTURE_TARGETS_COMMON) endif # Textures # Scripts ifeq ($(MAKE_SCRIPTS),1) ASSET_TARGETS_CMAKE += $(SCRIPT_TARGETS_CMAKE) +ASSET_TARGETS_SERVER += $(SCRIPT_TARGETS_SERVER) ASSET_TARGETS_MAC += $(SCRIPT_TARGETS_MAC) ASSET_TARGETS_WIN_WIN32 += $(SCRIPT_TARGETS_WIN_WIN32) ASSET_TARGETS_WIN_X64 += $(SCRIPT_TARGETS_WIN_X64) ASSET_TARGETS_IOS += $(SCRIPT_TARGETS_IOS) ASSET_TARGETS_ANDROID += $(SCRIPT_TARGETS_ANDROID) -ASSET_TARGETS_COMMON += $(SCRIPT_TARGETS_COMMON) +ASSET_TARGETS_COMMON_GUI += $(SCRIPT_TARGETS_COMMON) +ASSET_TARGETS_COMMON_SERVER += $(SCRIPT_TARGETS_COMMON) endif # Extras @@ -7379,7 +7390,7 @@ $(EXTRAS_TARGETS_WIN_X64) : ../../.efrocachemap # __AUTOGENERATED_PRIVATE_END__ -ASSET_TARGETS_COMMON += $(MESH_TARGETS) +ASSET_TARGETS_COMMON_GUI += $(MESH_TARGETS) $(BUILD_DIR)/%.bob : ../../.efrocachemap @cd ../.. && tools/pcommand efrocache_get src/assets/$@ @@ -7462,6 +7473,7 @@ textures-clean: # Script targets needed per-platform (may overlap) SCRIPT_TARGETS_CMAKE = +SCRIPT_TARGETS_SERVER = SCRIPT_TARGETS_WIN_WIN32 = $(SCRIPT_TARGETS_PY_PRIVATE_WIN_WIN32) \ $(SCRIPT_TARGETS_PYC_PRIVATE_WIN_WIN32) SCRIPT_TARGETS_WIN_X64 = $(SCRIPT_TARGETS_PY_PRIVATE_WIN_X64) \ @@ -7481,6 +7493,7 @@ SCRIPT_TARGETS_COMMON = $(SCRIPT_TARGETS_PY_PUBLIC) \ # Build scripts for a specific platform. scripts-cmake: $(SCRIPT_TARGETS_CMAKE) $(SCRIPT_TARGETS_COMMON) +scripts-server: $(SCRIPT_TARGETS_SERVER) $(SCRIPT_TARGETS_COMMON) scripts-win-Win32: $(SCRIPT_TARGETS_WIN_WIN32) $(SCRIPT_TARGETS_COMMON) scripts-win-x64: $(SCRIPT_TARGETS_WIN_X64) $(SCRIPT_TARGETS_COMMON) scripts-mac: $(SCRIPT_TARGETS_MAC) $(SCRIPT_TARGETS_COMMON) @@ -7496,12 +7509,13 @@ scripts-clean: $(BUILD_DIR)/windows/Win32/Lib $(BUILD_DIR)/windows/x64/Lib # Build all required assets for a specific platform. -assets-cmake: $(ASSET_TARGETS_CMAKE) $(ASSET_TARGETS_COMMON) -assets-win-Win32: $(ASSET_TARGETS_WIN_WIN32) $(ASSET_TARGETS_COMMON) -assets-win-x64: $(ASSET_TARGETS_WIN_X64) $(ASSET_TARGETS_COMMON) -assets-mac: $(ASSET_TARGETS_MAC) $(ASSET_TARGETS_COMMON) -assets-ios: $(ASSET_TARGETS_IOS) $(ASSET_TARGETS_COMMON) -assets-android: $(ASSET_TARGETS_ANDROID) $(ASSET_TARGETS_COMMON) +assets-cmake: $(ASSET_TARGETS_CMAKE) $(ASSET_TARGETS_COMMON_GUI) +assets-server: $(ASSET_TARGETS_SERVER) $(ASSET_TARGETS_COMMON_SERVER) +assets-win-Win32: $(ASSET_TARGETS_WIN_WIN32) $(ASSET_TARGETS_COMMON_GUI) +assets-win-x64: $(ASSET_TARGETS_WIN_X64) $(ASSET_TARGETS_COMMON_GUI) +assets-mac: $(ASSET_TARGETS_MAC) $(ASSET_TARGETS_COMMON_GUI) +assets-ios: $(ASSET_TARGETS_IOS) $(ASSET_TARGETS_COMMON_GUI) +assets-android: $(ASSET_TARGETS_ANDROID) $(ASSET_TARGETS_COMMON_GUI) # Build all assets for all platforms. assets: assets-cmake assets-win-Win32 assets-win-x64 assets-mac assets-ios \ diff --git a/src/assets/ba_data/python/babase/__init__.py b/src/assets/ba_data/python/babase/__init__.py index abf4f2e9..f79b5fb5 100644 --- a/src/assets/ba_data/python/babase/__init__.py +++ b/src/assets/ba_data/python/babase/__init__.py @@ -186,6 +186,9 @@ def _simplify_module_names() -> None: _simplify_module_names() del _simplify_module_names +# Allow the native layer to wrap a few things up. +_babase.reached_end_of_babase() + # Marker we pop down at the very end so other modules can run sanity # checks to make sure we aren't importing them reciprocally when they # import us. diff --git a/src/assets/ba_data/python/baclassic/__init__.py b/src/assets/ba_data/python/baclassic/__init__.py index 037c3840..145e272c 100644 --- a/src/assets/ba_data/python/baclassic/__init__.py +++ b/src/assets/ba_data/python/baclassic/__init__.py @@ -18,6 +18,12 @@ directly, it will most likely not work without classic present. # ba_meta require api 8 +# import traceback +# traceback.print_stack() +# sys.stderr.flush() +# sys.stdout.flush() + + # Note: Code relying on classic should import things from here *only* # for type-checking and use the versions in app.classic at runtime; that # way type-checking will cleanly cover the classic-not-present case diff --git a/src/assets/ba_data/python/baenv.py b/src/assets/ba_data/python/baenv.py index 43ea5286..cc9e3b74 100644 --- a/src/assets/ba_data/python/baenv.py +++ b/src/assets/ba_data/python/baenv.py @@ -30,7 +30,7 @@ if TYPE_CHECKING: # Build number and version of the ballistica binary we expect to be # using. -TARGET_BALLISTICA_BUILD = 21046 +TARGET_BALLISTICA_BUILD = 21047 TARGET_BALLISTICA_VERSION = '1.7.20' _g_env_config: EnvConfig | None = None diff --git a/src/ballistica/base/base.cc b/src/ballistica/base/base.cc index a25d860b..de4c7f1c 100644 --- a/src/ballistica/base/base.cc +++ b/src/ballistica/base/base.cc @@ -107,6 +107,7 @@ void BaseFeatureSet::OnModuleExec(PyObject* module) { // This is what allows others to 'import' our C++ front end. g_base->StoreOnPythonModule(module); + // Import all the Python stuff we use. g_base->python->ImportPythonObjs(); // Run some sanity checks/etc. @@ -121,21 +122,32 @@ void BaseFeatureSet::OnModuleExec(PyObject* module) { // that we've been holding on to. g_core->python->EnablePythonLoggingCalls(); - // Read the app config. Should this perhaps go in StartApp or something? - g_base->python->ReadConfig(); - // Marker we pop down at the very end so other modules can run sanity // checks to make sure we aren't importing them reciprocally when they // import us. Python::MarkReachedEndOfModule(module); + assert(!g_base->base_native_import_completed_); + g_base->base_native_import_completed_ = true; g_core->LifecycleLog("_babase exec end"); } +void BaseFeatureSet::OnReachedEndOfBaBaseImport() { + assert(!base_import_completed_); + + g_base->python->ImportPythonAppObjs(); + + base_import_completed_ = true; +} + auto BaseFeatureSet::Import() -> BaseFeatureSet* { return ImportThroughPythonModule("_babase"); } +auto BaseFeatureSet::IsBaseCompletelyImported() -> bool { + return base_import_completed_ && base_native_import_completed_; +} + void BaseFeatureSet::OnScreenAndAssetsReady() { assert(InLogicThread()); assert(console_ == nullptr); @@ -161,6 +173,9 @@ void BaseFeatureSet::StartApp() { LogVersionInfo(); + // Read the app config. + g_base->python->ReadConfig(); + // Allow our subsystems to start doing work in their own threads // and communicating with other subsystems. Note that we may still // want to run some things serially here and ordering may be important @@ -464,7 +479,10 @@ void BaseFeatureSet::V1CloudLog(const std::string& msg) { // to the master server with various other context info included. // We currently need both plus and classic for this system to function. - if (!(HavePlus() && HaveClassic())) { + if (!IsBaseCompletelyImported()) { + printf( + "WARNING: V1CloudLog called before babase import complete; will be " + "ignored.\n"); return; } diff --git a/src/ballistica/base/base.h b/src/ballistica/base/base.h index 2e9cdd65..15b88058 100644 --- a/src/ballistica/base/base.h +++ b/src/ballistica/base/base.h @@ -650,6 +650,11 @@ class BaseFeatureSet : public FeatureSetNativeComponent, /// in reality we are unmodified). auto IsUnmodifiedBlessedBuild() -> bool override; + /// Return true if both babase and _babase modules have completed their + /// import execs. To keep our init order well defined, we want to avoid + /// allowing certain functionality before this time. + auto IsBaseCompletelyImported() -> bool; + auto InAssetsThread() const -> bool override; auto InLogicThread() const -> bool override; auto InGraphicsThread() const -> bool override; @@ -681,6 +686,7 @@ class BaseFeatureSet : public FeatureSetNativeComponent, void DoPushObjCall(const PythonObjectSetBase* objset, int id) override; void DoPushObjCall(const PythonObjectSetBase* objset, int id, const std::string& arg) override; + void OnReachedEndOfBaBaseImport(); /// Called in the logic thread once our screen is up and assets are loading. void OnScreenAndAssetsReady(); @@ -737,6 +743,8 @@ class BaseFeatureSet : public FeatureSetNativeComponent, bool called_start_app_{}; bool app_running_{}; bool called_run_app_to_completion_{}; + bool base_import_completed_{}; + bool base_native_import_completed_{}; }; } // namespace ballistica::base diff --git a/src/ballistica/base/python/base_python.cc b/src/ballistica/base/python/base_python.cc index 53617275..f457e72b 100644 --- a/src/ballistica/base/python/base_python.cc +++ b/src/ballistica/base/python/base_python.cc @@ -66,7 +66,16 @@ void BasePython::ImportPythonObjs() { #include "ballistica/base/mgen/pyembed/binding_base.inc" } +void BasePython::ImportPythonAppObjs() { + // Import and grab all the Python stuff we use from C++. + // Note: Binding .inc files expect 'ObjID' and 'objs_' to be defined. +#include "ballistica/base/mgen/pyembed/binding_base_app.inc" +} + void BasePython::SoftImportPlus() { + // To keep our init order clean, we want to root out any attempted uses + // of plus before _babase has been fully inited. + auto gil{Python::ScopedInterpreterLock()}; auto result = PythonRef::StolenSoft(PyImport_ImportModule("_baplus")); if (!result.Exists()) { @@ -97,6 +106,7 @@ void BasePython::SoftImportUIV1() { } void BasePython::ReadConfig() { + auto gil{Python::ScopedInterpreterLock()}; // Read the config file and store the config dict for easy access. objs().Get(ObjID::kReadConfigCall).Call(); objs_.Store(ObjID::kConfig, *objs().Get(ObjID::kApp).GetAttr("config")); @@ -121,12 +131,7 @@ void BasePython::OnMainThreadStartApp() { } } -void BasePython::OnAppStart() { - assert(g_base->InLogicThread()); - - // FIXME - THIS SHOULD PROBABLY REPLACE LOGIC-COMPLETE-BOOTSTRAPPING - // g_python->InitBallisticaPython(); -} +void BasePython::OnAppStart() { assert(g_base->InLogicThread()); } void BasePython::OnAppPause() { assert(g_base->InLogicThread()); diff --git a/src/ballistica/base/python/base_python.h b/src/ballistica/base/python/base_python.h index 63549daa..321ba332 100644 --- a/src/ballistica/base/python/base_python.h +++ b/src/ballistica/base/python/base_python.h @@ -108,6 +108,7 @@ class BasePython { void AddPythonClasses(PyObject* module); void ImportPythonObjs(); + void ImportPythonAppObjs(); void ReadConfig(); const auto& objs() { return objs_; } diff --git a/src/ballistica/base/python/methods/python_methods_app.cc b/src/ballistica/base/python/methods/python_methods_app.cc index 48585d0b..af19b44f 100644 --- a/src/ballistica/base/python/methods/python_methods_app.cc +++ b/src/ballistica/base/python/methods/python_methods_app.cc @@ -1305,6 +1305,26 @@ static PyMethodDef PyOnInitialAppModeSetDef = { "(internal)\n", }; +// ------------------------- reached_end_of_babase ----------------------------- + +static auto PyReachedEndOfBaBase(PyObject* self) -> PyObject* { + BA_PYTHON_TRY; + BA_PRECONDITION(g_base); + g_base->OnReachedEndOfBaBaseImport(); + Py_RETURN_NONE; + BA_PYTHON_CATCH; +} + +static PyMethodDef PyReachedEndOfBaBaseDef = { + "reached_end_of_babase", // name + (PyCFunction)PyReachedEndOfBaBase, // method + METH_NOARGS, // flags + + "reached_end_of_babase() -> None\n" + "\n" + "(internal)\n", +}; + // ----------------------------------------------------------------------------- auto PythonMethodsApp::GetMethods() -> std::vector { @@ -1346,6 +1366,7 @@ auto PythonMethodsApp::GetMethods() -> std::vector { PyExecArgDef, PyOnAppRunningDef, PyOnInitialAppModeSetDef, + PyReachedEndOfBaBaseDef, }; } diff --git a/src/ballistica/base/python/methods/python_methods_misc.cc b/src/ballistica/base/python/methods/python_methods_misc.cc index 9c5b0a67..9fccda69 100644 --- a/src/ballistica/base/python/methods/python_methods_misc.cc +++ b/src/ballistica/base/python/methods/python_methods_misc.cc @@ -1311,9 +1311,9 @@ static PyMethodDef PyDoOnceDef = { "... print('HelloWorld once from loop!')", }; -// -------------------------------- _app --------------------------------------- +// ------------------------------- getapp -------------------------------------- -static auto PyApp(PyObject* self, PyObject* args, PyObject* keywds) +static auto PyGetApp(PyObject* self, PyObject* args, PyObject* keywds) -> PyObject* { BA_PYTHON_TRY; static const char* kwlist[] = {nullptr}; @@ -1326,12 +1326,12 @@ static auto PyApp(PyObject* self, PyObject* args, PyObject* keywds) BA_PYTHON_CATCH; } -static PyMethodDef PyAppDef = { - "_app", // name - (PyCFunction)PyApp, // method +static PyMethodDef PyGetAppDef = { + "getapp", // name + (PyCFunction)PyGetApp, // method METH_VARARGS | METH_KEYWORDS, // flags - "_app() -> babase.App\n" + "getapp() -> babase.App\n" "\n" "(internal)", }; @@ -1392,7 +1392,7 @@ auto PythonMethodsMisc::GetMethods() -> std::vector { PyClipboardSetTextDef, PyClipboardGetTextDef, PyDoOnceDef, - PyAppDef, + PyGetAppDef, PyAndroidGetExternalFilesDirDef, PyAndroidShowWifiSettingsDef, PySetInternalLanguageKeysDef, diff --git a/src/ballistica/shared/ballistica.cc b/src/ballistica/shared/ballistica.cc index 6a85b0bf..fc424916 100644 --- a/src/ballistica/shared/ballistica.cc +++ b/src/ballistica/shared/ballistica.cc @@ -39,7 +39,7 @@ auto main(int argc, char** argv) -> int { namespace ballistica { // These are set automatically via script; don't modify them here. -const int kEngineBuildNumber = 21046; +const int kEngineBuildNumber = 21047; const char* kEngineVersion = "1.7.20"; auto MonolithicMain(const core::CoreConfig& core_config) -> int { diff --git a/src/ballistica/shared/foundation/exception.cc b/src/ballistica/shared/foundation/exception.cc index ee60233a..23a2277b 100644 --- a/src/ballistica/shared/foundation/exception.cc +++ b/src/ballistica/shared/foundation/exception.cc @@ -24,6 +24,7 @@ Exception::Exception(std::string message_in, PyExcType python_type) stack_trace_ = core::g_core->platform->GetStackTrace(); } } + Exception::Exception(PyExcType python_type) : python_type_(python_type) { thread_name_ = CurrentThreadName(); diff --git a/src/meta/.meta_manifest_public.json b/src/meta/.meta_manifest_public.json index ff96115e..90323cc1 100644 --- a/src/meta/.meta_manifest_public.json +++ b/src/meta/.meta_manifest_public.json @@ -2,6 +2,7 @@ "src/assets/ba_data/python/babase/_mgen/__init__.py", "src/assets/ba_data/python/babase/_mgen/enums.py", "src/ballistica/base/mgen/pyembed/binding_base.inc", + "src/ballistica/base/mgen/pyembed/binding_base_app.inc", "src/ballistica/classic/mgen/pyembed/binding_classic.inc", "src/ballistica/core/mgen/pyembed/binding_core.inc", "src/ballistica/core/mgen/pyembed/env.inc", diff --git a/src/meta/Makefile b/src/meta/Makefile index 7dc98e8b..8514b23a 100644 --- a/src/meta/Makefile +++ b/src/meta/Makefile @@ -25,6 +25,7 @@ sources: \ $(PROJ_SRC_DIR)/assets/ba_data/python/babase/_mgen/__init__.py \ $(PROJ_SRC_DIR)/assets/ba_data/python/babase/_mgen/enums.py \ $(PROJ_SRC_DIR)/ballistica/base/mgen/pyembed/binding_base.inc \ + $(PROJ_SRC_DIR)/ballistica/base/mgen/pyembed/binding_base_app.inc \ $(PROJ_SRC_DIR)/ballistica/classic/mgen/pyembed/binding_classic.inc \ $(PROJ_SRC_DIR)/ballistica/core/mgen/pyembed/binding_core.inc \ $(PROJ_SRC_DIR)/ballistica/core/mgen/pyembed/env.inc \ @@ -39,6 +40,9 @@ $(PROJ_SRC_DIR)/ballistica/core/mgen/python_modules_monolithic.h : $(PROJ_DIR)/c $(PROJ_SRC_DIR)/ballistica/base/mgen/pyembed/binding_base.inc : babasemeta/pyembed/binding_base.py @$(PCOMMAND) gen_binding_code $< $@ +$(PROJ_SRC_DIR)/ballistica/base/mgen/pyembed/binding_base_app.inc : babasemeta/pyembed/binding_base_app.py + @$(PCOMMAND) gen_binding_code $< $@ + $(PROJ_SRC_DIR)/ballistica/classic/mgen/pyembed/binding_classic.inc : baclassicmeta/pyembed/binding_classic.py @$(PCOMMAND) gen_binding_code $< $@ @@ -77,6 +81,7 @@ efrocache-list: @echo "$(PROJ_SRC_DIR)/assets/ba_data/python/babase/_mgen/__init__.py" \ "$(PROJ_SRC_DIR)/assets/ba_data/python/babase/_mgen/enums.py" \ "$(PROJ_SRC_DIR)/ballistica/base/mgen/pyembed/binding_base.inc" \ + "$(PROJ_SRC_DIR)/ballistica/base/mgen/pyembed/binding_base_app.inc" \ "$(PROJ_SRC_DIR)/ballistica/classic/mgen/pyembed/binding_classic.inc" \ "$(PROJ_SRC_DIR)/ballistica/core/mgen/pyembed/binding_core.inc" \ "$(PROJ_SRC_DIR)/ballistica/core/mgen/pyembed/env.inc" \ diff --git a/src/meta/babasemeta/pyembed/binding_base.py b/src/meta/babasemeta/pyembed/binding_base.py index baeb3206..8af68834 100644 --- a/src/meta/babasemeta/pyembed/binding_base.py +++ b/src/meta/babasemeta/pyembed/binding_base.py @@ -4,17 +4,19 @@ # Run make update to update the project after editing this.. # pylint: disable=missing-module-docstring, line-too-long from __future__ import annotations - -import babase -from babase import _language -from babase import _apputils from babase._mgen import enums -from babase import _hooks -from babase import _env +from babase import ( + _language, + _apputils, + _hooks, + _env, + _error, + _general, +) + # The C++ layer looks for this variable: values = [ - babase.app, # kApp _hooks.reset_to_main_menu, # kResetToMainMenuCall _hooks.set_config_fullscreen_on, # kSetConfigFullscreenOnCall _hooks.set_config_fullscreen_off, # kSetConfigFullscreenOffCall @@ -56,22 +58,19 @@ values = [ _hooks.shutdown, # kShutdownCall _hooks.show_post_purchase_message, # kShowPostPurchaseMessageCall _hooks.on_app_bootstrapping_complete, # kOnAppBootstrappingCompleteCall - babase.app.handle_deep_link, # kDeepLinkCall - babase.app.lang.get_resource, # kGetResourceCall - babase.app.lang.translate, # kTranslateCall - babase.Lstr, # kLStrClass - babase.Call, # kCallClass + _language.Lstr, # kLStrClass + _general.Call, # kCallClass _apputils.garbage_collect_session_end, # kGarbageCollectSessionEndCall - babase.ContextError, # kContextError - babase.NotFoundError, # kNotFoundError - babase.NodeNotFoundError, # kNodeNotFoundError - babase.SessionTeamNotFoundError, # kSessionTeamNotFoundError - babase.InputDeviceNotFoundError, # kInputDeviceNotFoundError - babase.DelegateNotFoundError, # kDelegateNotFoundError - babase.SessionPlayerNotFoundError, # kSessionPlayerNotFoundError - babase.WidgetNotFoundError, # kWidgetNotFoundError - babase.ActivityNotFoundError, # kActivityNotFoundError - babase.SessionNotFoundError, # kSessionNotFoundError + _error.ContextError, # kContextError + _error.NotFoundError, # kNotFoundError + _error.NodeNotFoundError, # kNodeNotFoundError + _error.SessionTeamNotFoundError, # kSessionTeamNotFoundError + _error.InputDeviceNotFoundError, # kInputDeviceNotFoundError + _error.DelegateNotFoundError, # kDelegateNotFoundError + _error.SessionPlayerNotFoundError, # kSessionPlayerNotFoundError + _error.WidgetNotFoundError, # kWidgetNotFoundError + _error.ActivityNotFoundError, # kActivityNotFoundError + _error.SessionNotFoundError, # kSessionNotFoundError enums.TimeFormat, # kTimeFormatClass enums.TimeType, # kTimeTypeClass enums.InputType, # kInputTypeClass diff --git a/src/meta/babasemeta/pyembed/binding_base_app.py b/src/meta/babasemeta/pyembed/binding_base_app.py new file mode 100644 index 00000000..40fa0966 --- /dev/null +++ b/src/meta/babasemeta/pyembed/binding_base_app.py @@ -0,0 +1,16 @@ +# Released under the MIT License. See LICENSE for details. +# Where most of our python-c++ binding happens. +# Python objects should be added here along with their associated c++ enum. +# Run make update to update the project after editing this.. +# pylint: disable=missing-module-docstring, line-too-long +from __future__ import annotations +import babase + + +# The C++ layer looks for this variable: +values = [ + babase.app, # kApp + babase.app.handle_deep_link, # kDeepLinkCall + babase.app.lang.get_resource, # kGetResourceCall + babase.app.lang.translate, # kTranslateCall +] diff --git a/tests/test_babase/test_imports.py b/tests/test_babase/test_imports.py new file mode 100644 index 00000000..fccd3e7f --- /dev/null +++ b/tests/test_babase/test_imports.py @@ -0,0 +1,36 @@ +# Released under the MIT License. See LICENSE for details. +# +"""Testing asset manager functionality.""" + +from __future__ import annotations + +from typing import TYPE_CHECKING + + +if TYPE_CHECKING: + pass + + +def test_babase_imports() -> None: + """Testing.""" + import subprocess + + # Put together the headless binary we use for testing. + subprocess.run(['make', 'cmake-server-build'], check=True) + builddir = 'build/cmake/server-debug/dist' + + # Make sure we can cleanly import both our Python package and binary + # module by themselves. + subprocess.run( + f'PYTHONPATH={builddir}/ba_data/python' + f' {builddir}/ballisticakit_headless -c "import babase"', + check=True, + shell=True, + ) + + subprocess.run( + f'PYTHONPATH={builddir}/ba_data/python' + f' {builddir}/ballisticakit_headless -c "import _babase"', + check=True, + shell=True, + ) diff --git a/tools/batools/metabuild.py b/tools/batools/metabuild.py index 46316e8c..0e845ae5 100644 --- a/tools/batools/metabuild.py +++ b/tools/batools/metabuild.py @@ -67,7 +67,7 @@ def gen_binding_code(projroot: str, in_path: str, out_path: str) -> None: entries = [ l.strip().split(', # ') for l in pycode.splitlines() - if l.startswith(' ') + if l.startswith(' ') and '#' in l ] if not all(len(l) == 2 for l in entries): raise RuntimeError('malformatted data.')