From 79dbd89c6b3c453b12133417c11ed119547db334 Mon Sep 17 00:00:00 2001 From: Eric Date: Wed, 26 Jun 2024 16:41:11 -0700 Subject: [PATCH] more bacloud work --- .efrocachemap | 56 +++++++++++++-------------- CHANGELOG.md | 11 ++++-- src/assets/ba_data/python/baenv.py | 2 +- src/ballistica/shared/ballistica.cc | 2 +- tools/bacommon/bacloud.py | 10 ++--- tools/batools/bacloud.py | 7 ++-- tools/batools/pcommands.py | 2 +- tools/batools/spinoff/_main.py | 6 +-- tools/batools/spinoff/_test.py | 6 +-- tools/batools/staging.py | 3 +- tools/efro/util.py | 60 ++++++++++++++++++++++++++++- tools/efrotools/pcommands2.py | 2 +- tools/efrotools/util.py | 57 +-------------------------- 13 files changed, 115 insertions(+), 109 deletions(-) diff --git a/.efrocachemap b/.efrocachemap index 92acd3c4..35f60dc3 100644 --- a/.efrocachemap +++ b/.efrocachemap @@ -4038,26 +4038,26 @@ "build/assets/windows/Win32/ucrtbased.dll": "2def5335207d41b21b9823f6805997f1", "build/assets/windows/Win32/vc_redist.x86.exe": "b08a55e2e77623fe657bea24f223a3ae", "build/assets/windows/Win32/vcruntime140d.dll": "865b2af4d1e26a1a8073c89acb06e599", - "build/prefab/full/linux_arm64_gui/debug/ballisticakit": "a92a8552dc768a124023921e2d7c8e4b", - "build/prefab/full/linux_arm64_gui/release/ballisticakit": "4aed94d02131e7387238efb8e8c88517", - "build/prefab/full/linux_arm64_server/debug/dist/ballisticakit_headless": "8b95dbba57e6453070609a8f7c05284e", - "build/prefab/full/linux_arm64_server/release/dist/ballisticakit_headless": "36961e7faa9e949ef714136f6f72ed9d", - "build/prefab/full/linux_x86_64_gui/debug/ballisticakit": "4b96f8141e053abef2796f6970cca7bf", - "build/prefab/full/linux_x86_64_gui/release/ballisticakit": "7d2542c6f789099c37f1c36a004c0532", - "build/prefab/full/linux_x86_64_server/debug/dist/ballisticakit_headless": "2b35512a02c77933cc9d1988761e9907", - "build/prefab/full/linux_x86_64_server/release/dist/ballisticakit_headless": "30fe1c1ac3a70695001a21ceb7b137ec", - "build/prefab/full/mac_arm64_gui/debug/ballisticakit": "633e84b17f8e564c904dc85f1b4fa657", - "build/prefab/full/mac_arm64_gui/release/ballisticakit": "07cd831fee262def54be88ce219207c8", - "build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "ee638b2db04ebcf3889c5cb6ce70c153", - "build/prefab/full/mac_arm64_server/release/dist/ballisticakit_headless": "360cedd219db792e8910544b028b76cf", - "build/prefab/full/mac_x86_64_gui/debug/ballisticakit": "6338e5613990e5df7592109a77f2ce66", - "build/prefab/full/mac_x86_64_gui/release/ballisticakit": "d29b1531d1610c5815071c0f5fd596e9", - "build/prefab/full/mac_x86_64_server/debug/dist/ballisticakit_headless": "6656b4b2bcbc87f94cf573ff9c34648e", - "build/prefab/full/mac_x86_64_server/release/dist/ballisticakit_headless": "8153ea67d0e0bdeb852e656a9ff89505", - "build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "4a5f1dd454ff6e2215d63e24b871b226", - "build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "4a6ba058616fddd1d2f3045e7eba5fef", - "build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "79d13825d258fb365b99e1045cff2607", - "build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "7fcfa30b3aab3ce4c31287b7cd15aeef", + "build/prefab/full/linux_arm64_gui/debug/ballisticakit": "2463d9fec0254150bd385e9ef80d1098", + "build/prefab/full/linux_arm64_gui/release/ballisticakit": "3dc65856b5a30df83ee088428a7ed862", + "build/prefab/full/linux_arm64_server/debug/dist/ballisticakit_headless": "f108ac7b56522e05aa061a43ec0f7ad7", + "build/prefab/full/linux_arm64_server/release/dist/ballisticakit_headless": "0b4ef8f5b00f2917467d6bc3926003ae", + "build/prefab/full/linux_x86_64_gui/debug/ballisticakit": "11495371a0ff7a476b88b715e0d4899c", + "build/prefab/full/linux_x86_64_gui/release/ballisticakit": "e1ffd608a74e1135a74535ef0f24de84", + "build/prefab/full/linux_x86_64_server/debug/dist/ballisticakit_headless": "0df1d668840d11debccf8cd018acf04f", + "build/prefab/full/linux_x86_64_server/release/dist/ballisticakit_headless": "a8c964a36ad22fab92cb003f66e0e463", + "build/prefab/full/mac_arm64_gui/debug/ballisticakit": "24097673630e5b052b383277a260aea2", + "build/prefab/full/mac_arm64_gui/release/ballisticakit": "a85895d48516991dd9a3cd5f3dbd11b0", + "build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "c2764b0cde11a194cad2604fa1d1471f", + "build/prefab/full/mac_arm64_server/release/dist/ballisticakit_headless": "ea55aef603d7998f134bc25567d2e175", + "build/prefab/full/mac_x86_64_gui/debug/ballisticakit": "af07fba782424d77cd143a5b92a9aa8e", + "build/prefab/full/mac_x86_64_gui/release/ballisticakit": "06b5aaf53195021bd21d05ec372fe403", + "build/prefab/full/mac_x86_64_server/debug/dist/ballisticakit_headless": "b26f17d43516f14085628892b73d4023", + "build/prefab/full/mac_x86_64_server/release/dist/ballisticakit_headless": "94dfd167a76d72054ec3f41f2a0b82fa", + "build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "a0d37cea9ada58a27a38b039165160ed", + "build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "7bcc1336a2a123041a8c01924bf237dc", + "build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "d401578a393dce23422773dc38db40c8", + "build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "a5b49b99f94e7750214ebfa22789f083", "build/prefab/lib/linux_arm64_gui/debug/libballisticaplus.a": "f231b10895bdcb542de87b887ca181fd", "build/prefab/lib/linux_arm64_gui/release/libballisticaplus.a": "ae936a119668ede7b36f38c8672f4bf8", "build/prefab/lib/linux_arm64_server/debug/libballisticaplus.a": "f231b10895bdcb542de87b887ca181fd", @@ -4074,14 +4074,14 @@ "build/prefab/lib/mac_x86_64_gui/release/libballisticaplus.a": "efffc4f330e77530accd9a9f82840a6c", "build/prefab/lib/mac_x86_64_server/debug/libballisticaplus.a": "c20363fe2af3d54e666b1c8ee67f6b76", "build/prefab/lib/mac_x86_64_server/release/libballisticaplus.a": "efffc4f330e77530accd9a9f82840a6c", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.lib": "632d0e121545353cc40577b765c156f9", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.pdb": "ffe84e846b294dc8517d9af555dad70f", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.lib": "ef1743ca2035c525e8884129d69fa582", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.pdb": "0d215e98b6440a823809d3d582ae542f", - "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.lib": "359f0e344c2f9d6409b675c2ab600df4", - "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.pdb": "7467cc9095607857b21f5f55518874e0", - "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.lib": "2680d5d44629d8a19857d1c6b87a6fd2", - "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.pdb": "bed37e7b4e1dfcdd31789db7730a388e", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.lib": "15872f211c5469c1c36effbccc175df6", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.pdb": "be9f86b56e673690295bc3ae0e34e4cd", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.lib": "9a66106a77e0850ced1de339e8ea09b3", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.pdb": "aaa392bfda1f92d3ce3478ac833278a3", + "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.lib": "b589b7a0bf5dea29a4e979db7b331fed", + "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.pdb": "6ad1eac0bfd7fe89a7d1be258cc562d2", + "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.lib": "88916d575d6e93fd22f50639d25ceeea", + "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.pdb": "ea9a9af9f29d096abfdc9d9c88f503d4", "src/assets/ba_data/python/babase/_mgen/__init__.py": "f885fed7f2ed98ff2ba271f9dbe3391c", "src/assets/ba_data/python/babase/_mgen/enums.py": "5548f407d97e380069f6c596c4e36cd7", "src/ballistica/base/mgen/pyembed/binding_base.inc": "efa61468cf098f77cc6a234461d8b86d", diff --git a/CHANGELOG.md b/CHANGELOG.md index 914fedb7..479cea0e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,10 @@ -### 1.7.36 (build 21896, api 8, 2024-06-26) -- `bacloud workspace put` is now a bit smarter; you can now do things like - `bacloud workspace put .` and it will work. Previously such cases required - explicitly passing the workspace name as a second argument. +### 1.7.36 (build 21897, api 8, 2024-06-26) +- bacloud workspace commands are now a bit smarter; you can now do things like + `bacloud workspace put .` or even just `bacloud workspace put` and it will + work. Previously such cases required explicitly passing the workspace name + as a second argument. Both `workspace get` and `workspace put` now also have + an optional `--workspace` arg if you want to sync with a workspace different + than the local directory name. ### 1.7.35 (build 21889, api 8, 2024-06-20) - Fixed an issue where the engine would block at exit on some version of Linux diff --git a/src/assets/ba_data/python/baenv.py b/src/assets/ba_data/python/baenv.py index b5a6bdbb..020fbfd2 100644 --- a/src/assets/ba_data/python/baenv.py +++ b/src/assets/ba_data/python/baenv.py @@ -52,7 +52,7 @@ if TYPE_CHECKING: # Build number and version of the ballistica binary we expect to be # using. -TARGET_BALLISTICA_BUILD = 21896 +TARGET_BALLISTICA_BUILD = 21897 TARGET_BALLISTICA_VERSION = '1.7.36' diff --git a/src/ballistica/shared/ballistica.cc b/src/ballistica/shared/ballistica.cc index dabd36b5..96928eec 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 = 21896; +const int kEngineBuildNumber = 21897; const char* kEngineVersion = "1.7.36"; const int kEngineApiVersion = 8; diff --git a/tools/bacommon/bacloud.py b/tools/bacommon/bacloud.py index f293ffcb..e529d1d1 100644 --- a/tools/bacommon/bacloud.py +++ b/tools/bacommon/bacloud.py @@ -14,7 +14,7 @@ if TYPE_CHECKING: # Version is sent to the master-server with all commands. Can be incremented # if we need to change behavior server-side to go along with client changes. -BACLOUD_VERSION = 9 +BACLOUD_VERSION = 11 @ioprepped @@ -49,11 +49,11 @@ class ResponseData: It should be added to end_command args as 'manifest'. uploads: If present, client should upload the requested files (arg1) individually to a server command (arg2) with provided args (arg3). - uploads_inline: If present, a list of pathnames that should be base64 - gzipped and uploaded to an 'uploads_inline' dict in end_command args. + uploads_inline: If present, a list of pathnames that should be gzipped + and uploaded to an 'uploads_inline' bytes dict in end_command args. This should be limited to relatively small files. deletes: If present, file paths that should be deleted on the client. - downloads_inline: If present, pathnames mapped to base64 gzipped data to + downloads_inline: If present, pathnames mapped to gzipped data to be written to the client. This should only be used for relatively small files as they are all included inline as part of the response. dir_prune_empty: If present, all empty dirs under this one should be @@ -88,7 +88,7 @@ class ResponseData: list[str] | None, IOAttrs('dlt', store_default=False) ] = None downloads_inline: Annotated[ - dict[str, str] | None, IOAttrs('dinl', store_default=False) + dict[str, bytes] | None, IOAttrs('dinl', store_default=False) ] = None dir_prune_empty: Annotated[ str | None, IOAttrs('dpe', store_default=False) diff --git a/tools/batools/bacloud.py b/tools/batools/bacloud.py index ec988e6c..a6fe56cc 100755 --- a/tools/batools/bacloud.py +++ b/tools/batools/bacloud.py @@ -253,10 +253,10 @@ class App: def _handle_downloads_inline( self, - downloads_inline: dict[str, str], + downloads_inline: dict[str, bytes], ) -> None: """Handle inline file data to be saved to the client.""" - import base64 + # import base64 for fname, fdata in downloads_inline.items(): # If there's a directory where we want our file to go, clear it @@ -271,7 +271,8 @@ class App: dirname = os.path.dirname(fname) if dirname: os.makedirs(dirname, exist_ok=True) - data_zipped = base64.b64decode(fdata) + # data_zipped = base64.b64decode(fdata) + data_zipped = fdata data = zlib.decompress(data_zipped) # Write to tmp files first and then move into place. This diff --git a/tools/batools/pcommands.py b/tools/batools/pcommands.py index 4d25b965..b064a863 100644 --- a/tools/batools/pcommands.py +++ b/tools/batools/pcommands.py @@ -223,7 +223,7 @@ def androidaddr() -> None: def push_ipa() -> None: """Construct and push ios IPA for testing.""" - from efrotools.util import extract_arg + from efro.util import extract_arg import efrotools.ios pcommand.disallow_in_batch() diff --git a/tools/batools/spinoff/_main.py b/tools/batools/spinoff/_main.py index 90284ec7..3b264f5a 100644 --- a/tools/batools/spinoff/_main.py +++ b/tools/batools/spinoff/_main.py @@ -107,7 +107,7 @@ def _main() -> None: assert_never(cmd) if single_run_mode is not None: - from efrotools.util import extract_flag + from efro.util import extract_flag args = sys.argv[2:] force = extract_flag(args, '--force') @@ -146,7 +146,7 @@ def _main() -> None: def _do_create(src_root: str, dst_root: str | None) -> None: # pylint: disable=too-many-locals, cyclic-import - from efrotools.util import extract_arg, extract_flag + from efro.util import extract_arg, extract_flag from efrotools.code import format_python_str from efrotools.project import getprojectconfig import batools.spinoff @@ -317,7 +317,7 @@ def _do_featureset_delete() -> None: def _do_featureset_copy() -> None: # pylint: disable=too-many-locals - from efrotools.util import extract_flag + from efro.util import extract_flag from batools.featureset import FeatureSet diff --git a/tools/batools/spinoff/_test.py b/tools/batools/spinoff/_test.py index 308a4bd6..bae0cf5f 100644 --- a/tools/batools/spinoff/_test.py +++ b/tools/batools/spinoff/_test.py @@ -19,11 +19,11 @@ def spinoff_test(args: list[str]) -> None: import os import subprocess - from batools.featureset import FeatureSet - from efrotools.util import extract_flag - from efrotools.project import getprojectconfig + from efro.util import extract_flag from efro.terminal import Clr from efro.error import CleanError + from batools.featureset import FeatureSet + from efrotools.project import getprojectconfig submodule_parent = extract_flag(args, '--submodule-parent') shared_test_parent = extract_flag(args, '--shared-test-parent') diff --git a/tools/batools/staging.py b/tools/batools/staging.py index e8af7421..f2d4155b 100755 --- a/tools/batools/staging.py +++ b/tools/batools/staging.py @@ -12,7 +12,8 @@ from functools import partial from typing import TYPE_CHECKING from efro.terminal import Clr -from efrotools.util import extract_arg, extract_flag, is_wsl_windows_build_path +from efro.util import extract_arg, extract_flag +from efrotools.util import is_wsl_windows_build_path from efrotools.pyver import PYVER if TYPE_CHECKING: diff --git a/tools/efro/util.py b/tools/efro/util.py index 14b3d625..d16c1a8c 100644 --- a/tools/efro/util.py +++ b/tools/efro/util.py @@ -10,12 +10,13 @@ import weakref import datetime import functools from enum import Enum -from typing import TYPE_CHECKING, cast, TypeVar, Generic +from typing import TYPE_CHECKING, cast, TypeVar, Generic, overload if TYPE_CHECKING: import asyncio + from typing import Any, Callable, Literal + from efro.call import Call as Call # 'as Call' so we re-export. - from typing import Any, Callable T = TypeVar('T') ValT = TypeVar('ValT') @@ -913,3 +914,58 @@ def split_list(input_list: list[T], max_length: int) -> list[list[T]]: input_list[i : i + max_length] for i in range(0, len(input_list), max_length) ] + + +def extract_flag(args: list[str], name: str) -> bool: + """Given a list of args and a flag name, returns whether it is present. + + The arg flag, if present, is removed from the arg list. + """ + from efro.error import CleanError + + count = args.count(name) + if count > 1: + raise CleanError(f'Flag {name} passed multiple times.') + if not count: + return False + args.remove(name) + return True + + +@overload +def extract_arg( + args: list[str], name: str, required: Literal[False] = False +) -> str | None: ... + + +@overload +def extract_arg(args: list[str], name: str, required: Literal[True]) -> str: ... + + +def extract_arg( + args: list[str], name: str, required: bool = False +) -> str | None: + """Given a list of args and an arg name, returns a value. + + The arg flag and value are removed from the arg list. + raises CleanErrors on any problems. + """ + from efro.error import CleanError + + count = args.count(name) + if not count: + if required: + raise CleanError(f'Required argument {name} not passed.') + return None + + if count > 1: + raise CleanError(f'Arg {name} passed multiple times.') + + argindex = args.index(name) + if argindex + 1 >= len(args): + raise CleanError(f'No value passed after {name} arg.') + + val = args[argindex + 1] + del args[argindex : argindex + 2] + + return val diff --git a/tools/efrotools/pcommands2.py b/tools/efrotools/pcommands2.py index e9469a14..1b1b7214 100644 --- a/tools/efrotools/pcommands2.py +++ b/tools/efrotools/pcommands2.py @@ -121,8 +121,8 @@ def build_pcommandbatch() -> None: def batchserver() -> None: """Run a server for handling pcommands.""" from efro.error import CleanError + from efro.util import extract_arg - from efrotools.util import extract_arg import efrotools.pcommandbatch as pcb pcommand.disallow_in_batch() diff --git a/tools/efrotools/util.py b/tools/efrotools/util.py index 6694ce6f..72b7bc18 100644 --- a/tools/efrotools/util.py +++ b/tools/efrotools/util.py @@ -7,7 +7,7 @@ Ideally the stuff in here should migrate to more descriptive module names. from __future__ import annotations -from typing import TYPE_CHECKING, overload +from typing import TYPE_CHECKING if TYPE_CHECKING: @@ -20,61 +20,6 @@ def explicit_bool(value: bool) -> bool: return value -def extract_flag(args: list[str], name: str) -> bool: - """Given a list of args and a flag name, returns whether it is present. - - The arg flag, if present, is removed from the arg list. - """ - from efro.error import CleanError - - count = args.count(name) - if count > 1: - raise CleanError(f'Flag {name} passed multiple times.') - if not count: - return False - args.remove(name) - return True - - -@overload -def extract_arg( - args: list[str], name: str, required: Literal[False] = False -) -> str | None: ... - - -@overload -def extract_arg(args: list[str], name: str, required: Literal[True]) -> str: ... - - -def extract_arg( - args: list[str], name: str, required: bool = False -) -> str | None: - """Given a list of args and an arg name, returns a value. - - The arg flag and value are removed from the arg list. - raises CleanErrors on any problems. - """ - from efro.error import CleanError - - count = args.count(name) - if not count: - if required: - raise CleanError(f'Required argument {name} not passed.') - return None - - if count > 1: - raise CleanError(f'Arg {name} passed multiple times.') - - argindex = args.index(name) - if argindex + 1 >= len(args): - raise CleanError(f'No value passed after {name} arg.') - - val = args[argindex + 1] - del args[argindex : argindex + 2] - - return val - - def replace_section( text: str, begin_marker: str,