From 6c515672adee86ecd7e5b0711ecc433eda1736d8 Mon Sep 17 00:00:00 2001 From: Eric Froemling Date: Wed, 24 Feb 2021 10:11:41 -0600 Subject: [PATCH] Added optional config-file arg to server script --- .efrocachemap | 56 +++++++++---------- .idea/dictionaries/ericf.xml | 3 + assets/src/server/ballisticacore_server.py | 38 +++++++++++-- .../.idea/dictionaries/ericf.xml | 3 + src/ballistica/ballistica.cc | 2 +- tools/efrotools/pybuild.py | 6 +- 6 files changed, 73 insertions(+), 35 deletions(-) diff --git a/.efrocachemap b/.efrocachemap index 579e71fc..efdc030f 100644 --- a/.efrocachemap +++ b/.efrocachemap @@ -3932,26 +3932,26 @@ "assets/build/windows/Win32/ucrtbased.dll": "https://files.ballistica.net/cache/ba1/b5/85/f8b6d0558ddb87267f34254b1450", "assets/build/windows/Win32/vc_redist.x86.exe": "https://files.ballistica.net/cache/ba1/1c/e1/4a1a2eddda2f4aebd5f8b64ab08e", "assets/build/windows/Win32/vcruntime140d.dll": "https://files.ballistica.net/cache/ba1/50/8d/bc2600ac9491f1b14d659709451f", - "build/prefab/full/linux_arm64/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/ea/05/68b74f30e981933bbae03755e4de", - "build/prefab/full/linux_arm64/release/ballisticacore": "https://files.ballistica.net/cache/ba1/31/a6/b3ddf128be7d13840e069f827044", - "build/prefab/full/linux_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/d9/1e/850d020b72dacf7183db2235eae6", - "build/prefab/full/linux_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/af/e0/c1e1eef9db322ac19764a1c3c064", - "build/prefab/full/linux_x86_64/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/81/c7/93bdab4190e62d6a362dda017bbd", - "build/prefab/full/linux_x86_64/release/ballisticacore": "https://files.ballistica.net/cache/ba1/be/26/8b6a414b673401e6e4e3fdb7c8c7", - "build/prefab/full/linux_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/2a/68/72899e9f3026dae42206415dd28a", - "build/prefab/full/linux_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/e4/bc/c5ac53cdc69c2d289ee96a017ead", - "build/prefab/full/mac_arm64/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/33/44/526fc5ce4e143d870e3036e7810e", - "build/prefab/full/mac_arm64/release/ballisticacore": "https://files.ballistica.net/cache/ba1/aa/60/af50b46a92dfcd4d99450f0ea90a", - "build/prefab/full/mac_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/52/b9/419f3cff40380d5c9de94b9cd5bc", - "build/prefab/full/mac_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/77/cc/27f3e0187c85a966a53d8846b773", - "build/prefab/full/mac_x86_64/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/67/d1/bf1a09c11b5d395eca2480091d82", - "build/prefab/full/mac_x86_64/release/ballisticacore": "https://files.ballistica.net/cache/ba1/7b/20/c7ba7aff67a80900985869160266", - "build/prefab/full/mac_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/83/34/4792d67ee44693f8a79d0e45b693", - "build/prefab/full/mac_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/86/be/8b9603cbee7660f861ac099075cf", - "build/prefab/full/windows_x86/debug/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/8e/b6/d1a042ebce63ac649fbc71faeeb4", - "build/prefab/full/windows_x86/release/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/ba/02/e4d54f002ee5a741e87c9e31a353", - "build/prefab/full/windows_x86_server/debug/dist/ballisticacore_headless.exe": "https://files.ballistica.net/cache/ba1/db/01/88065479393a44de2f4203c849b4", - "build/prefab/full/windows_x86_server/release/dist/ballisticacore_headless.exe": "https://files.ballistica.net/cache/ba1/bc/83/e79ec5372197af6c23bf80060480", + "build/prefab/full/linux_arm64/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/b0/41/1773777bea8220fb532b02207bd8", + "build/prefab/full/linux_arm64/release/ballisticacore": "https://files.ballistica.net/cache/ba1/7a/aa/7db23036581440bd28d245f7b6b0", + "build/prefab/full/linux_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/e2/ef/7254a413f4bb7618b9d7898d6a7f", + "build/prefab/full/linux_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/7b/64/71ddea075764913a51b13c331d88", + "build/prefab/full/linux_x86_64/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/ee/bf/5aa9ef09d3adf56836c0370e587e", + "build/prefab/full/linux_x86_64/release/ballisticacore": "https://files.ballistica.net/cache/ba1/91/b6/f323561fb316ba15a3f5d7d45858", + "build/prefab/full/linux_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/bc/a6/88edc1066bc69f967a924e84fc5b", + "build/prefab/full/linux_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/96/b6/2ba6d3b0ef4dff3a0a1e1fb7b5da", + "build/prefab/full/mac_arm64/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/4b/af/8a1214609ee5f0d207905e384394", + "build/prefab/full/mac_arm64/release/ballisticacore": "https://files.ballistica.net/cache/ba1/2a/90/f7532756dd8a21f1a07c1ed12ccc", + "build/prefab/full/mac_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/86/86/a0506a90f1a5845843affb842e09", + "build/prefab/full/mac_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/a3/2b/3127e1a79e6e3aece248ef41ec8c", + "build/prefab/full/mac_x86_64/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/ae/31/3542167c07e9abd5f1df07d08181", + "build/prefab/full/mac_x86_64/release/ballisticacore": "https://files.ballistica.net/cache/ba1/94/5a/e3b3c60976be78d1728660c638b3", + "build/prefab/full/mac_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/7a/b2/ca6ad8142f08e81d63d65f52e0ce", + "build/prefab/full/mac_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/c9/62/4b17a374c663c730e091a1695911", + "build/prefab/full/windows_x86/debug/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/75/11/0bbb84a7d2f285e97d5f6e8b8c5e", + "build/prefab/full/windows_x86/release/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/d9/89/1d495c48545be16152915c5933ab", + "build/prefab/full/windows_x86_server/debug/dist/ballisticacore_headless.exe": "https://files.ballistica.net/cache/ba1/77/71/570b0118c6e2fe3603b9832a2991", + "build/prefab/full/windows_x86_server/release/dist/ballisticacore_headless.exe": "https://files.ballistica.net/cache/ba1/29/dd/2646ab0b39c07c541ad80a7b4727", "build/prefab/lib/linux_arm64/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/4c/bf/393694ea67f3d590dd2706c9955e", "build/prefab/lib/linux_arm64/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/78/cb/bb9ae4f896f862074057c8e36e1d", "build/prefab/lib/linux_arm64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/ae/bd/39d7b885f7f01e81d0e96f0f85ce", @@ -3960,12 +3960,12 @@ "build/prefab/lib/linux_x86_64/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/52/d9/563a6949d2c4db5a915c54460fbc", "build/prefab/lib/linux_x86_64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/d0/6a/42fe8d2e34f95e1b3282e8422344", "build/prefab/lib/linux_x86_64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/50/cf/bad44b07a4022aee3001002086b5", - "build/prefab/lib/mac_arm64/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/5a/42/aa563542dce1ac737ffeb7876ee0", - "build/prefab/lib/mac_arm64/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/e5/31/a045a08a8db23dfe4e9da0b5b1fa", - "build/prefab/lib/mac_arm64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/f3/a5/741584cb2f6897d9f11b1a60ab62", - "build/prefab/lib/mac_arm64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/58/90/07fd566cc337337e3e622d86c613", - "build/prefab/lib/mac_x86_64/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/c6/cb/ed41a99350ec3c21184688eacdfa", - "build/prefab/lib/mac_x86_64/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/2f/dc/4761b6be13320fdf8ba733b10570", - "build/prefab/lib/mac_x86_64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/71/88/46aa34701da4196d5e53083bf1bb", - "build/prefab/lib/mac_x86_64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/e0/c4/cbcc32a20a5cdb038c33d6f992c0" + "build/prefab/lib/mac_arm64/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/84/d0/d46d2ce177f1ce6bc0304ce673c9", + "build/prefab/lib/mac_arm64/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/09/b7/e094fdfa54fa38751f0caa1c9e68", + "build/prefab/lib/mac_arm64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/69/6f/c99b2718ac104de79337e35414f7", + "build/prefab/lib/mac_arm64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/d7/76/eecf9cc91f73e3cae73291215216", + "build/prefab/lib/mac_x86_64/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/77/0f/0ef7575b11fd70a1d897ab261813", + "build/prefab/lib/mac_x86_64/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/45/62/8267446a6c71bcc34234ec5e119a", + "build/prefab/lib/mac_x86_64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/78/9b/a5a29e1baa7d5d9d2eaabc9412f9", + "build/prefab/lib/mac_x86_64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/ab/67/4c447ca41efd957bce227a34887c" } \ No newline at end of file diff --git a/.idea/dictionaries/ericf.xml b/.idea/dictionaries/ericf.xml index 5034db82..c3954b6d 100644 --- a/.idea/dictionaries/ericf.xml +++ b/.idea/dictionaries/ericf.xml @@ -176,6 +176,7 @@ baseurl baseval basew + basn bastd batools bbbb @@ -320,6 +321,7 @@ charname charstr chatmessage + chdir cheadersline checkarg checkboxwidget @@ -1381,6 +1383,7 @@ mywidget namedarg nametext + nameval nboxes ncpu ndbm diff --git a/assets/src/server/ballisticacore_server.py b/assets/src/server/ballisticacore_server.py index 1a22fe7a..b8ad800a 100755 --- a/assets/src/server/ballisticacore_server.py +++ b/assets/src/server/ballisticacore_server.py @@ -32,9 +32,11 @@ if TYPE_CHECKING: from types import FrameType from bacommon.servermanager import ServerCommand -VERSION_STR = '1.1.1' +VERSION_STR = '1.1.2' # Version history: +# 1.1.2: +# Now accepts config path as sole optional argument. # 1.1.1: # Switched config reading to use efro.dataclasses.dataclass_from_dict() # 1.1.0: @@ -56,7 +58,8 @@ class ServerManagerApp: managing BallisticaCore operating in server mode. """ - def __init__(self) -> None: + def __init__(self, config_path: Optional[str] = None) -> None: + self._config_path = config_path try: self._config = self._load_config() except Exception as exc: @@ -274,7 +277,8 @@ class ServerManagerApp: IMMEDIATE_SHUTDOWN_TIME_LIMIT) def _load_config(self) -> ServerConfig: - user_config_path = 'config.yaml' + user_config_path = (self._config_path if self._config_path is not None + else 'config.yaml') if os.path.exists(user_config_path): import yaml @@ -284,6 +288,12 @@ class ServerManagerApp: # An empty config file will yield None, and that's ok. if user_config_raw is not None: return dataclass_from_dict(ServerConfig, user_config_raw) + else: + print( + f"Warning: config file not found at '{user_config_path}'" + f'; will use default config.', + file=sys.stderr, + flush=True) # Go with defaults if we weren't able to load anything. return ServerConfig() @@ -518,16 +528,36 @@ class ServerManagerApp: print(f'{Clr.CYN}Subprocess stopped.{Clr.RST}') +def _parse_args() -> Optional[str]: + """Parse command line args; return optional config path.""" + if len(sys.argv) > 2: + raise CleanError('Expected no more than 1 arg (config path)') + if len(sys.argv) > 1: + configpath = sys.argv[1] + if not os.path.exists(configpath): + raise CleanError( + f"Supplied config path does not exist: '{configpath}'.") + + # Note that we chdir before running the app so we need an abs path + # to this to be safe. + return os.path.abspath(configpath) + return None + + def main() -> None: """Run a BallisticaCore server manager in interactive mode.""" try: + # User can optionally supply a config path. + # (need to get this before we chdir). + config_path = _parse_args() + # ServerManager expects cwd to be the server dir (containing # dist/, config.yaml, etc.) # Let's change our working directory to the location of this file # so we can run this script from anywhere and it'll work. os.chdir(os.path.abspath(os.path.dirname(__file__))) - ServerManagerApp().run_interactive() + ServerManagerApp(config_path=config_path).run_interactive() except CleanError as exc: # For clean errors, do a simple print and fail; no tracebacks/etc. exc.pretty_print() diff --git a/ballisticacore-cmake/.idea/dictionaries/ericf.xml b/ballisticacore-cmake/.idea/dictionaries/ericf.xml index f337f6d1..e4c2c9ba 100644 --- a/ballisticacore-cmake/.idea/dictionaries/ericf.xml +++ b/ballisticacore-cmake/.idea/dictionaries/ericf.xml @@ -68,6 +68,7 @@ barebones basetype basicsize + basn bastd bbbb bbbbb @@ -149,6 +150,7 @@ charnum charstr chatmessage + chdir checkboxwidget checkchisel chrono @@ -577,6 +579,7 @@ mynode mystatspage mywidget + nameval ndebug nearbytab nearval diff --git a/src/ballistica/ballistica.cc b/src/ballistica/ballistica.cc index 452569ff..5027608e 100644 --- a/src/ballistica/ballistica.cc +++ b/src/ballistica/ballistica.cc @@ -21,7 +21,7 @@ namespace ballistica { // These are set automatically via script; don't change here. -const int kAppBuildNumber = 20280; +const int kAppBuildNumber = 20300; const char* kAppVersion = "1.6.0"; // Our standalone globals. diff --git a/tools/efrotools/pybuild.py b/tools/efrotools/pybuild.py index 4762fbc7..1a4a8b7b 100644 --- a/tools/efrotools/pybuild.py +++ b/tools/efrotools/pybuild.py @@ -445,8 +445,10 @@ def android_patch() -> None: # change it back to that for now. fname = 'src/cpython/Modules/makesetup' txt = readfile(fname) - txt = replace_one(txt, ' *=*) DEFS="$line$NL$DEFS"; continue;;', - ' [A-Z]*=*) DEFS="$line$NL$DEFS"; continue;;') + txt = replace_one(txt, ' *=*)' + ' DEFS="$line$NL$DEFS"; continue;;', + ' [A-Z]*=*) DEFS="$line$NL$DEFS";' + ' continue;;') writefile(fname, txt) # Add custom callbacks to Python's PyParser_ParseFileObject