moved py enums module generation to meta build

This commit is contained in:
Eric Froemling 2021-06-18 08:49:23 -05:00
parent 4c1bc979f8
commit a3a58a58f6
No known key found for this signature in database
GPG Key ID: 89C93F0F8D6D5A98
48 changed files with 226 additions and 337 deletions

View File

@ -3933,27 +3933,29 @@
"assets/build/windows/Win32/ucrtbased.dll": "https://files.ballistica.net/cache/ba1/f5/8b/14895df9caf46f326a3c939b34a4",
"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",
"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/72/82/86956fae909ac2fe2a1abd84a361",
"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/dc/39/6cd24b42d7422b7d9a2fa447862a",
"build/prefab/full/linux_arm64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/be/90/8fbbd0f4570405372d94a1749312",
"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/a4/5e/12f41945f5e2cd176d68b29e7ddd",
"build/prefab/full/linux_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/ad/55/1f53311aa1a7d3f8932c233f7661",
"build/prefab/full/linux_x86_64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/ee/9c/70939d269276c1e4baaa731b2085",
"build/prefab/full/linux_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/0e/f5/e1585dfa4abb3a24b62c21259196",
"build/prefab/full/linux_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/4e/6b/8012d4bbed6ecee79161866d6078",
"build/prefab/full/linux_x86_64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/a4/c4/0fa36aad74aa15fafc20c73b19ea",
"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/a4/91/8d8a90a2ccd3aa7e51a62dcd7d7a",
"build/prefab/full/linux_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/fb/4f/deef20e32ad1a92c79758cd4252d",
"build/prefab/full/mac_arm64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/57/57/e7c461b3acb74b44ef632d70b038",
"build/prefab/full/mac_arm64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/89/73/9bcb6c8f0a60f6a9c2278c039f58",
"build/prefab/full/mac_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/c8/14/6388483c3095b8837b3c280edc14",
"build/prefab/full/mac_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/1d/61/2700666994aa453c37376288675e",
"build/prefab/full/mac_x86_64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/ce/61/ed63bff8c0c86a6d7983cbb6a9ed",
"build/prefab/full/mac_x86_64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/9c/27/5c3e3eef62e64063b9f217212f33",
"build/prefab/full/mac_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/84/28/43c6e51a3b7b03d21cf905afaa17",
"build/prefab/full/mac_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/ab/23/4f9cfb8e92e80c18116c4e2dd934",
"build/prefab/full/windows_x86_gui/debug/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/19/65/a3c7eab1f7787d43f97db2ee5689",
"build/prefab/full/windows_x86_gui/release/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/20/3e/e61926b902880d81f543151a035b",
"build/prefab/full/windows_x86_server/debug/dist/BallisticaCoreHeadless.exe": "https://files.ballistica.net/cache/ba1/b7/dd/43f65c2f58d3c52dbc76ee5c4b1d",
"build/prefab/full/windows_x86_server/release/dist/BallisticaCoreHeadless.exe": "https://files.ballistica.net/cache/ba1/d0/6a/2b34327d1f009652bd22dceaac9b",
"build/prefab/full/linux_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/34/ff/358a7048f00432e0a1f3f2f6892a",
"build/prefab/full/linux_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/97/3b/576fc32f9ec58ab4dfd83a30c2f3",
"build/prefab/full/mac_arm64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/5f/77/6b483eaaee3360bbf6d4b1c4edfd",
"build/prefab/full/mac_arm64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/0d/bd/017a33857704529facbd1668a3d9",
"build/prefab/full/mac_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/69/8a/9971f043234f42709ba180cacebf",
"build/prefab/full/mac_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/54/d5/a64a1e3b4d07570b8346d3f012b7",
"build/prefab/full/mac_x86_64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/08/04/55e83377e63f6aee5fbb1c0b3e40",
"build/prefab/full/mac_x86_64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/05/55/a1af91dbfbd65c28acfa74bb9195",
"build/prefab/full/mac_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/93/b5/7e6ccee496778a6b59ff2821fdfe",
"build/prefab/full/mac_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/39/7a/d32929d332be578e9ab615775ff0",
"build/prefab/full/windows_x86_gui/debug/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/4c/22/6b9f9f3ad25ee086176b39210b7b",
"build/prefab/full/windows_x86_gui/release/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/8d/5b/48fbb571a3f4c5d92d20a74c1315",
"build/prefab/full/windows_x86_server/debug/dist/BallisticaCoreHeadless.exe": "https://files.ballistica.net/cache/ba1/c1/fb/e16517fbab5ec2d7fcb9bab1a733",
"build/prefab/full/windows_x86_server/release/dist/BallisticaCoreHeadless.exe": "https://files.ballistica.net/cache/ba1/c8/b0/0a05c54cdaff68b90963791021aa",
"build/prefab/lib/linux_arm64_gui/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/9a/32/bda06e355384dac2fc81c8357812",
"build/prefab/lib/linux_arm64_gui/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/34/f6/b4db57144d47cfdb153dd4de6742",
"build/prefab/lib/linux_arm64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/53/44/cf4405c2ebe2695d55858129d3fe",
@ -3970,14 +3972,14 @@
"build/prefab/lib/mac_x86_64_gui/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/b5/5b/0390ee8916f97d302cde3ea356bc",
"build/prefab/lib/mac_x86_64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/7a/ee/8249ede29becc0cd41178924b6dc",
"build/prefab/lib/mac_x86_64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/c0/5f/e89024a87dd092f6e0cc43afb707",
"build/prefab/lib/windows/Debug_Win32/BallisticaCoreGenericInternal.lib": "https://files.ballistica.net/cache/ba1/f3/47/3b999db988c306973ae632578142",
"build/prefab/lib/windows/Debug_Win32/BallisticaCoreGenericInternal.pdb": "https://files.ballistica.net/cache/ba1/b6/e7/4f19d4f194b2ee54d36feb8f0be7",
"build/prefab/lib/windows/Debug_Win32/BallisticaCoreHeadlessInternal.lib": "https://files.ballistica.net/cache/ba1/37/bd/9bf6782278baafda458855addeb2",
"build/prefab/lib/windows/Debug_Win32/BallisticaCoreHeadlessInternal.pdb": "https://files.ballistica.net/cache/ba1/ee/69/054d1f74863dcb4f5aa4e4ca6c93",
"build/prefab/lib/windows/Release_Win32/BallisticaCoreGenericInternal.lib": "https://files.ballistica.net/cache/ba1/d2/19/2b2a8e28a5af1b9b2fd025f8b70f",
"build/prefab/lib/windows/Release_Win32/BallisticaCoreGenericInternal.pdb": "https://files.ballistica.net/cache/ba1/af/f7/d719717515f8d838f6c7ddd232ea",
"build/prefab/lib/windows/Release_Win32/BallisticaCoreHeadlessInternal.lib": "https://files.ballistica.net/cache/ba1/1a/6d/730bae9f73df1d2db402a5657281",
"build/prefab/lib/windows/Release_Win32/BallisticaCoreHeadlessInternal.pdb": "https://files.ballistica.net/cache/ba1/3d/0f/4e38b3571a83cf2db579c7d27d7f",
"src/ballistica/generated/python_embedded/binding.inc": "https://files.ballistica.net/cache/ba1/77/d4/d205bab8219f99b5b24639a389d2",
"build/prefab/lib/windows/Debug_Win32/BallisticaCoreGenericInternal.lib": "https://files.ballistica.net/cache/ba1/bf/30/702511c5151e8c1953d402e91911",
"build/prefab/lib/windows/Debug_Win32/BallisticaCoreGenericInternal.pdb": "https://files.ballistica.net/cache/ba1/d8/44/7e213b937bc99d5ea48786a4bb6b",
"build/prefab/lib/windows/Debug_Win32/BallisticaCoreHeadlessInternal.lib": "https://files.ballistica.net/cache/ba1/96/73/ee9bf0100649d8a8761e3f7384f6",
"build/prefab/lib/windows/Debug_Win32/BallisticaCoreHeadlessInternal.pdb": "https://files.ballistica.net/cache/ba1/b8/35/dbe63ddf903e21e0abf625f00780",
"build/prefab/lib/windows/Release_Win32/BallisticaCoreGenericInternal.lib": "https://files.ballistica.net/cache/ba1/9a/12/acb7aa1d3f99e2ff3290131cad2a",
"build/prefab/lib/windows/Release_Win32/BallisticaCoreGenericInternal.pdb": "https://files.ballistica.net/cache/ba1/b9/70/7be47fa6f8d302c4e8ee4d250a6e",
"build/prefab/lib/windows/Release_Win32/BallisticaCoreHeadlessInternal.lib": "https://files.ballistica.net/cache/ba1/e8/9e/ba039e7a6c842b6cedbe07d21481",
"build/prefab/lib/windows/Release_Win32/BallisticaCoreHeadlessInternal.pdb": "https://files.ballistica.net/cache/ba1/ec/82/f1318f738093caf043baf2de3b1d",
"src/ballistica/generated/python_embedded/binding.inc": "https://files.ballistica.net/cache/ba1/fc/b5/62133319c6df8567aecfd29b1204",
"src/ballistica/generated/python_embedded/bootstrap.inc": "https://files.ballistica.net/cache/ba1/8d/96/c1516dee7d458c9065597e0aede6"
}

2
.gitignore vendored
View File

@ -121,7 +121,7 @@ xcuserdata/
# Generated sources
/src/ballistica/generated
/assets/src/ba_data/python/_generated
/assets/src/ba_data/python/ba/_generated
# Dynamically generated resource files
/ballisticacore-android/BallisticaCore/src/cardboard/res/drawable-*/vr_icon.png

View File

@ -1314,6 +1314,7 @@
<w>malhotra</w>
<w>mallimportedby</w>
<w>mandir</w>
<w>mantype</w>
<w>manualtab</w>
<w>mapdata</w>
<w>mapdef</w>

View File

@ -1,14 +1,27 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Default" />
<inspection_tool class="DuplicatedCode" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
<inspection_tool class="Annotator" enabled="true" level="ERROR" enabled_by_default="true">
<scope name="PyIgnoreProtectedAccess" level="ERROR" enabled="false" />
</inspection_tool>
<inspection_tool class="DuplicatedCode" enabled="false" level="WEAK WARNING" enabled_by_default="false">
<scope name="PyIgnoreProtectedAccess" level="WEAK WARNING" enabled="false" />
</inspection_tool>
<inspection_tool class="GrazieInspection" enabled="false" level="TYPO" enabled_by_default="false" />
<inspection_tool class="HttpUrlsUsage" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
<inspection_tool class="InconsistentLineSeparators" enabled="true" level="WARNING" enabled_by_default="true">
<scope name="NonPython" level="WARNING" enabled="false" />
<scope name="PyIgnoreProtectedAccess" level="WARNING" enabled="false" />
</inspection_tool>
<inspection_tool class="InjectedReferences" enabled="true" level="ERROR" enabled_by_default="true">
<scope name="PyIgnoreProtectedAccess" level="ERROR" enabled="false" />
</inspection_tool>
<inspection_tool class="LongLine" enabled="false" level="WARNING" enabled_by_default="false">
<scope name="PyIgnoreProtectedAccess" level="WARNING" enabled="false" />
</inspection_tool>
<inspection_tool class="ProblematicWhitespace" enabled="true" level="WARNING" enabled_by_default="true">
<scope name="NonPython" level="WARNING" enabled="false" />
<scope name="PyIgnoreProtectedAccess" level="WARNING" enabled="false" />
</inspection_tool>
<inspection_tool class="PyArgumentListInspection" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="PyBroadExceptionInspection" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
@ -40,6 +53,7 @@
</option>
</inspection_tool>
<inspection_tool class="PyProtectedMemberInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
<scope name="PyIgnoreProtectedAccess" level="WEAK WARNING" enabled="false" />
<scope name="UncheckedPython" level="WEAK WARNING" enabled="false" />
</inspection_tool>
<inspection_tool class="PyRedundantParenthesesInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
@ -100,5 +114,14 @@
<inspection_tool class="PyUnusedLocalInspection" enabled="false" level="WEAK WARNING" enabled_by_default="false">
<scope name="UncheckedPython" level="WEAK WARNING" enabled="false" />
</inspection_tool>
<inspection_tool class="RedundantSuppression" enabled="true" level="WARNING" enabled_by_default="true">
<scope name="PyIgnoreProtectedAccess" level="WARNING" enabled="false" />
</inspection_tool>
<inspection_tool class="SyntaxError" enabled="true" level="ERROR" enabled_by_default="true">
<scope name="PyIgnoreProtectedAccess" level="ERROR" enabled="false" />
</inspection_tool>
<inspection_tool class="TodoComment" enabled="false" level="WARNING" enabled_by_default="false">
<scope name="PyIgnoreProtectedAccess" level="WARNING" enabled="false" />
</inspection_tool>
</profile>
</component>

View File

@ -0,0 +1,3 @@
<component name="DependencyValidationManager">
<scope name="PyIgnoreProtectedAccess" pattern="file[ballisticacore]:assets/src/ba_data/python/ba//*" />
</component>

View File

@ -21,7 +21,6 @@
"ba_data/python/ba/__pycache__/_coopsession.cpython-38.opt-1.pyc",
"ba_data/python/ba/__pycache__/_dependency.cpython-38.opt-1.pyc",
"ba_data/python/ba/__pycache__/_dualteamsession.cpython-38.opt-1.pyc",
"ba_data/python/ba/__pycache__/_enums.cpython-38.opt-1.pyc",
"ba_data/python/ba/__pycache__/_error.cpython-38.opt-1.pyc",
"ba_data/python/ba/__pycache__/_freeforallsession.cpython-38.opt-1.pyc",
"ba_data/python/ba/__pycache__/_gameactivity.cpython-38.opt-1.pyc",
@ -83,13 +82,16 @@
"ba_data/python/ba/_coopsession.py",
"ba_data/python/ba/_dependency.py",
"ba_data/python/ba/_dualteamsession.py",
"ba_data/python/ba/_enums.py",
"ba_data/python/ba/_error.py",
"ba_data/python/ba/_freeforallsession.py",
"ba_data/python/ba/_gameactivity.py",
"ba_data/python/ba/_gameresults.py",
"ba_data/python/ba/_gameutils.py",
"ba_data/python/ba/_general.py",
"ba_data/python/ba/_generated/__init__.py",
"ba_data/python/ba/_generated/__pycache__/__init__.cpython-38.opt-1.pyc",
"ba_data/python/ba/_generated/__pycache__/enums.cpython-38.opt-1.pyc",
"ba_data/python/ba/_generated/enums.py",
"ba_data/python/ba/_hooks.py",
"ba_data/python/ba/_input.py",
"ba_data/python/ba/_keyboard.py",

View File

@ -152,13 +152,14 @@ SCRIPT_TARGETS_PY_PUBLIC = \
build/ba_data/python/ba/_coopsession.py \
build/ba_data/python/ba/_dependency.py \
build/ba_data/python/ba/_dualteamsession.py \
build/ba_data/python/ba/_enums.py \
build/ba_data/python/ba/_error.py \
build/ba_data/python/ba/_freeforallsession.py \
build/ba_data/python/ba/_gameactivity.py \
build/ba_data/python/ba/_gameresults.py \
build/ba_data/python/ba/_gameutils.py \
build/ba_data/python/ba/_general.py \
build/ba_data/python/ba/_generated/__init__.py \
build/ba_data/python/ba/_generated/enums.py \
build/ba_data/python/ba/_hooks.py \
build/ba_data/python/ba/_input.py \
build/ba_data/python/ba/_keyboard.py \
@ -396,13 +397,14 @@ SCRIPT_TARGETS_PYC_PUBLIC = \
build/ba_data/python/ba/__pycache__/_coopsession.cpython-38.opt-1.pyc \
build/ba_data/python/ba/__pycache__/_dependency.cpython-38.opt-1.pyc \
build/ba_data/python/ba/__pycache__/_dualteamsession.cpython-38.opt-1.pyc \
build/ba_data/python/ba/__pycache__/_enums.cpython-38.opt-1.pyc \
build/ba_data/python/ba/__pycache__/_error.cpython-38.opt-1.pyc \
build/ba_data/python/ba/__pycache__/_freeforallsession.cpython-38.opt-1.pyc \
build/ba_data/python/ba/__pycache__/_gameactivity.cpython-38.opt-1.pyc \
build/ba_data/python/ba/__pycache__/_gameresults.cpython-38.opt-1.pyc \
build/ba_data/python/ba/__pycache__/_gameutils.cpython-38.opt-1.pyc \
build/ba_data/python/ba/__pycache__/_general.cpython-38.opt-1.pyc \
build/ba_data/python/ba/_generated/__pycache__/__init__.cpython-38.opt-1.pyc \
build/ba_data/python/ba/_generated/__pycache__/enums.cpython-38.opt-1.pyc \
build/ba_data/python/ba/__pycache__/_hooks.cpython-38.opt-1.pyc \
build/ba_data/python/ba/__pycache__/_input.cpython-38.opt-1.pyc \
build/ba_data/python/ba/__pycache__/_keyboard.cpython-38.opt-1.pyc \

View File

@ -1 +1 @@
187820143871408304678286045117862733188
3589099007368754607207796662508579801

View File

@ -32,7 +32,7 @@ from __future__ import annotations
from typing import TYPE_CHECKING, overload, Sequence, TypeVar
from ba._enums import TimeFormat, TimeType
from ba._generated.enums import TimeFormat, TimeType
if TYPE_CHECKING:
from typing import (Any, Dict, Callable, Tuple, List, Optional, Union,

View File

@ -29,8 +29,8 @@ from ba._coopgame import CoopGameActivity
from ba._coopsession import CoopSession
from ba._dependency import (Dependency, DependencyComponent, DependencySet,
AssetPackage)
from ba._enums import (TimeType, Permission, TimeFormat, SpecialChar,
InputType, UIScale)
from ba._generated.enums import (TimeType, Permission, TimeFormat, SpecialChar,
InputType, UIScale)
from ba._error import (
print_exception, print_error, ContextError, NotFoundError,
PlayerNotFoundError, SessionPlayerNotFoundError, NodeNotFoundError,

View File

@ -121,7 +121,7 @@ class AccountSubsystem:
def cache_tournament_info(self, info: Any) -> None:
"""(internal)"""
from ba._enums import TimeType, TimeFormat
from ba._generated.enums import TimeType, TimeFormat
for entry in info:
cache_entry = self.tournament_info[entry['tournamentID']] = (
copy.deepcopy(entry))
@ -206,7 +206,7 @@ class AccountSubsystem:
def show_post_purchase_message(self) -> None:
"""(internal)"""
from ba._language import Lstr
from ba._enums import TimeType
from ba._generated.enums import TimeType
cur_time = _ba.time(TimeType.REAL)
if (self.last_post_purchase_message_time is None
or cur_time - self.last_post_purchase_message_time > 3.0):
@ -237,7 +237,7 @@ class AccountSubsystem:
def add_pending_promo_code(self, code: str) -> None:
"""(internal)"""
from ba._language import Lstr
from ba._enums import TimeType
from ba._generated.enums import TimeType
# If we're not signed in, queue up the code to run the next time we
# are and issue a warning if we haven't signed in within the next

View File

@ -388,7 +388,7 @@ class AchievementSubsystem:
def _test(self) -> None:
"""For testing achievement animations."""
from ba._enums import TimeType
from ba._generated.enums import TimeType
def testcall1() -> None:
self.achievements[0].announce_completion()
@ -489,7 +489,7 @@ class Achievement:
def announce_completion(self, sound: bool = True) -> None:
"""Kick off an announcement for this achievement's completion."""
from ba._enums import TimeType
from ba._generated.enums import TimeType
app = _ba.app
# Even though there are technically achievements when we're not
@ -619,7 +619,7 @@ class Achievement:
"""
# pylint: disable=cyclic-import
from ba._language import Lstr
from ba._enums import SpecialChar
from ba._generated.enums import SpecialChar
from ba._coopsession import CoopSession
from bastd.actor.image import Image
from bastd.actor.text import Text
@ -923,7 +923,7 @@ class Achievement:
from ba._general import WeakCall
from ba._language import Lstr
from ba._messages import DieMessage
from ba._enums import TimeType, SpecialChar
from ba._generated.enums import TimeType, SpecialChar
app = _ba.app
app.ach.last_achievement_display_time = _ba.time(TimeType.REAL)

View File

@ -275,7 +275,7 @@ class Activity(DependencyComponent, Generic[PlayerType, TeamType]):
(internal)
"""
from ba._enums import TimeType
from ba._generated.enums import TimeType
# Create a real-timer that watches a weak-ref of this activity
# and reports any lingering references keeping it alive.

View File

@ -8,7 +8,7 @@ from typing import TYPE_CHECKING
import _ba
from ba._activity import Activity
from ba._music import setmusic, MusicType
from ba._enums import InputType, UIScale
from ba._generated.enums import InputType, UIScale
# False-positive from pylint due to our class-generics-filter.
from ba._player import EmptyPlayer # pylint: disable=W0611
from ba._team import EmptyTeam # pylint: disable=W0611

View File

@ -33,7 +33,7 @@ class AdsSubsystem:
def do_remove_in_game_ads_message(self) -> None:
"""(internal)"""
from ba._language import Lstr
from ba._enums import TimeType
from ba._generated.enums import TimeType
# Print this message once every 10 minutes at most.
tval = _ba.time(TimeType.REAL)
@ -70,7 +70,7 @@ class AdsSubsystem:
# pylint: disable=too-many-statements
# pylint: disable=too-many-branches
# pylint: disable=too-many-locals
from ba._enums import TimeType
from ba._generated.enums import TimeType
app = _ba.app
show = True

View File

@ -290,7 +290,7 @@ class App:
from bastd import appdelegate
from bastd import maps as stdmaps
from bastd.actor import spazappearance
from ba._enums import TimeType
from ba._generated.enums import TimeType
cfg = self.config

View File

@ -97,7 +97,7 @@ def read_config() -> Tuple[AppConfig, bool]:
"""Read the game config."""
import os
import json
from ba._enums import TimeType
from ba._generated.enums import TimeType
config_file_healthy = False

View File

@ -57,7 +57,7 @@ def handle_log() -> None:
after a short bit if desired.
"""
from ba._net import master_server_post
from ba._enums import TimeType
from ba._generated.enums import TimeType
app = _ba.app
app.log_have_new = True
if not app.log_upload_timer_started:
@ -225,7 +225,7 @@ def print_live_object_warnings(when: Any,
def print_corrupt_file_error() -> None:
"""Print an error if a corrupt file is found."""
from ba._general import Call
from ba._enums import TimeType
from ba._generated.enums import TimeType
_ba.timer(2.0,
lambda: _ba.screenmessage(
_ba.app.lang.get_resource('internal.corruptFileText').

View File

@ -57,7 +57,7 @@ def run_stress_test(playlist_type: str = 'Random',
"""Run a stress test."""
from ba import modutils
from ba._general import Call
from ba._enums import TimeType
from ba._generated.enums import TimeType
_ba.screenmessage(
'Beginning stress test.. use '
"'End Game' to stop testing.",
@ -93,7 +93,7 @@ def start_stress_test(args: Dict[str, Any]) -> None:
from ba._general import Call
from ba._dualteamsession import DualTeamSession
from ba._freeforallsession import FreeForAllSession
from ba._enums import TimeType, TimeFormat
from ba._generated.enums import TimeType, TimeFormat
appconfig = _ba.app.config
playlist_type = args['playlist_type']
if playlist_type == 'Random':
@ -127,7 +127,7 @@ def start_stress_test(args: Dict[str, Any]) -> None:
def _reset_stress_test(args: Dict[str, Any]) -> None:
from ba._general import Call
from ba._enums import TimeType
from ba._generated.enums import TimeType
_ba.set_stress_testing(False, args['player_count'])
_ba.screenmessage('Resetting stress test...')
session = _ba.get_foreground_host_session()
@ -144,7 +144,7 @@ def run_gpu_benchmark() -> None:
def run_media_reload_benchmark() -> None:
"""Kick off a benchmark to test media reloading speeds."""
from ba._general import Call
from ba._enums import TimeType
from ba._generated.enums import TimeType
_ba.reload_media()
_ba.show_progress_bar()

View File

@ -70,7 +70,7 @@ class CoopGameActivity(GameActivity[PlayerType, TeamType]):
from efro.util import asserttype
from ba._gameutils import timestring, animate
from ba._nodeactor import NodeActor
from ba._enums import TimeFormat
from ba._generated.enums import TimeFormat
display_type = self.get_score_type()
if scores is not None:

View File

@ -1,198 +0,0 @@
# Released under the MIT License. See LICENSE for details.
"""Enum vals generated by batools.pythonenumsmodule; do not edit by hand."""
from enum import Enum
class InputType(Enum):
"""Types of input a controller can send to the game.
Category: Enums
"""
UP_DOWN = 2
LEFT_RIGHT = 3
JUMP_PRESS = 4
JUMP_RELEASE = 5
PUNCH_PRESS = 6
PUNCH_RELEASE = 7
BOMB_PRESS = 8
BOMB_RELEASE = 9
PICK_UP_PRESS = 10
PICK_UP_RELEASE = 11
RUN = 12
FLY_PRESS = 13
FLY_RELEASE = 14
START_PRESS = 15
START_RELEASE = 16
HOLD_POSITION_PRESS = 17
HOLD_POSITION_RELEASE = 18
LEFT_PRESS = 19
LEFT_RELEASE = 20
RIGHT_PRESS = 21
RIGHT_RELEASE = 22
UP_PRESS = 23
UP_RELEASE = 24
DOWN_PRESS = 25
DOWN_RELEASE = 26
class UIScale(Enum):
"""The overall scale the UI is being rendered for. Note that this is
independent of pixel resolution. For example, a phone and a desktop PC
might render the game at similar pixel resolutions but the size they
display content at will vary significantly.
Category: Enums
'large' is used for devices such as desktop PCs where fine details can
be clearly seen. UI elements are generally smaller on the screen
and more content can be seen at once.
'medium' is used for devices such as tablets, TVs, or VR headsets.
This mode strikes a balance between clean readability and amount of
content visible.
'small' is used primarily for phones or other small devices where
content needs to be presented as large and clear in order to remain
readable from an average distance.
"""
LARGE = 0
MEDIUM = 1
SMALL = 2
class TimeType(Enum):
"""Specifies the type of time for various operations to target/use.
Category: Enums
'sim' time is the local simulation time for an activity or session.
It can proceed at different rates depending on game speed, stops
for pauses, etc.
'base' is the baseline time for an activity or session. It proceeds
consistently regardless of game speed or pausing, but may stop during
occurrences such as network outages.
'real' time is mostly based on clock time, with a few exceptions. It may
not advance while the app is backgrounded for instance. (the engine
attempts to prevent single large time jumps from occurring)
"""
SIM = 0
BASE = 1
REAL = 2
class TimeFormat(Enum):
"""Specifies the format time values are provided in.
Category: Enums
"""
SECONDS = 0
MILLISECONDS = 1
class Permission(Enum):
"""Permissions that can be requested from the OS.
Category: Enums
"""
STORAGE = 0
class SpecialChar(Enum):
"""Special characters the game can print.
Category: Enums
"""
DOWN_ARROW = 0
UP_ARROW = 1
LEFT_ARROW = 2
RIGHT_ARROW = 3
TOP_BUTTON = 4
LEFT_BUTTON = 5
RIGHT_BUTTON = 6
BOTTOM_BUTTON = 7
DELETE = 8
SHIFT = 9
BACK = 10
LOGO_FLAT = 11
REWIND_BUTTON = 12
PLAY_PAUSE_BUTTON = 13
FAST_FORWARD_BUTTON = 14
DPAD_CENTER_BUTTON = 15
OUYA_BUTTON_O = 16
OUYA_BUTTON_U = 17
OUYA_BUTTON_Y = 18
OUYA_BUTTON_A = 19
OUYA_LOGO = 20
LOGO = 21
TICKET = 22
GOOGLE_PLAY_GAMES_LOGO = 23
GAME_CENTER_LOGO = 24
DICE_BUTTON1 = 25
DICE_BUTTON2 = 26
DICE_BUTTON3 = 27
DICE_BUTTON4 = 28
GAME_CIRCLE_LOGO = 29
PARTY_ICON = 30
TEST_ACCOUNT = 31
TICKET_BACKING = 32
TROPHY1 = 33
TROPHY2 = 34
TROPHY3 = 35
TROPHY0A = 36
TROPHY0B = 37
TROPHY4 = 38
LOCAL_ACCOUNT = 39
ALIBABA_LOGO = 40
FLAG_UNITED_STATES = 41
FLAG_MEXICO = 42
FLAG_GERMANY = 43
FLAG_BRAZIL = 44
FLAG_RUSSIA = 45
FLAG_CHINA = 46
FLAG_UNITED_KINGDOM = 47
FLAG_CANADA = 48
FLAG_INDIA = 49
FLAG_JAPAN = 50
FLAG_FRANCE = 51
FLAG_INDONESIA = 52
FLAG_ITALY = 53
FLAG_SOUTH_KOREA = 54
FLAG_NETHERLANDS = 55
FEDORA = 56
HAL = 57
CROWN = 58
YIN_YANG = 59
EYE_BALL = 60
SKULL = 61
HEART = 62
DRAGON = 63
HELMET = 64
MUSHROOM = 65
NINJA_STAR = 66
VIKING_HELMET = 67
MOON = 68
SPIDER = 69
FIREBALL = 70
FLAG_UNITED_ARAB_EMIRATES = 71
FLAG_QATAR = 72
FLAG_EGYPT = 73
FLAG_KUWAIT = 74
FLAG_ALGERIA = 75
FLAG_SAUDI_ARABIA = 76
FLAG_MALAYSIA = 77
FLAG_CZECH_REPUBLIC = 78
FLAG_AUSTRALIA = 79
FLAG_SINGAPORE = 80
OCULUS_LOGO = 81
STEAM_LOGO = 82
NVIDIA_LOGO = 83
FLAG_IRAN = 84
FLAG_POLAND = 85
FLAG_ARGENTINA = 86
FLAG_PHILIPPINES = 87
FLAG_CHILE = 88
MIKIROG = 89

View File

@ -385,7 +385,7 @@ class GameActivity(Activity[PlayerType, TeamType]):
# pylint: disable=cyclic-import
from bastd.ui.continues import ContinuesWindow
from ba._coopsession import CoopSession
from ba._enums import TimeType
from ba._generated.enums import TimeType
try:
if _ba.get_account_misc_read_val('enableContinues', False):
@ -653,7 +653,7 @@ class GameActivity(Activity[PlayerType, TeamType]):
def _show_tip(self) -> None:
# pylint: disable=too-many-locals
from ba._gameutils import animate, GameTip
from ba._enums import SpecialChar
from ba._generated.enums import SpecialChar
# If there's any tips left on the list, display one.
if self.tips:
@ -1009,7 +1009,7 @@ class GameActivity(Activity[PlayerType, TeamType]):
If the time-limit expires, end_game() will be called.
"""
from ba._nodeactor import NodeActor
from ba._enums import TimeType
from ba._generated.enums import TimeType
if duration <= 0.0:
return
self._tournament_time_limit = int(duration)

View File

@ -107,7 +107,7 @@ class GameResults:
"""
from ba._gameutils import timestring
from ba._language import Lstr
from ba._enums import TimeFormat
from ba._generated.enums import TimeFormat
from ba._score import ScoreType
if not self._game_set:
raise RuntimeError("Can't get team-score-str until game is set.")

View File

@ -8,7 +8,7 @@ from dataclasses import dataclass
from typing import TYPE_CHECKING
import _ba
from ba._enums import TimeType, TimeFormat, SpecialChar, UIScale
from ba._generated.enums import TimeType, TimeFormat, SpecialChar, UIScale
from ba._error import ActivityNotFoundError
if TYPE_CHECKING:

View File

@ -13,7 +13,7 @@ from typing import TYPE_CHECKING, TypeVar, Protocol
from efro.terminal import Clr
import _ba
from ba._error import print_error, print_exception
from ba._enums import TimeType
from ba._generated.enums import TimeType
if TYPE_CHECKING:
from types import FrameType

View File

@ -12,7 +12,7 @@ import _ba
from ba._error import print_exception, print_error, NotFoundError
from ba._gameutils import animate, animate_array
from ba._language import Lstr
from ba._enums import SpecialChar, InputType
from ba._generated.enums import SpecialChar, InputType
from ba._profile import get_player_profile_colors
if TYPE_CHECKING:

View File

@ -30,7 +30,7 @@ def get_player_profile_icon(profilename: str) -> str:
(non-account profiles only)
"""
from ba._enums import SpecialChar
from ba._generated.enums import SpecialChar
appconfig = _ba.app.config
icon: str

View File

@ -13,7 +13,7 @@ from bacommon.servermanager import (ServerCommand, StartServerModeCommand,
ChatMessageCommand, ScreenMessageCommand,
ClientListCommand, KickCommand)
import _ba
from ba._enums import TimeType
from ba._generated.enums import TimeType
from ba._freeforallsession import FreeForAllSession
from ba._dualteamsession import DualTeamSession

View File

@ -334,7 +334,7 @@ class Session:
def _launch_end_session_activity(self) -> None:
"""(internal)"""
from ba._activitytypes import EndSessionActivity
from ba._enums import TimeType
from ba._generated.enums import TimeType
with _ba.Context(self):
curtime = _ba.time(TimeType.REAL)
if self._ending:
@ -367,7 +367,7 @@ class Session:
will replace the old.
"""
from ba._general import Call
from ba._enums import TimeType
from ba._generated.enums import TimeType
# Only pay attention if this is coming from our current activity.
if activity is not self._activity_retained:
@ -431,7 +431,7 @@ class Session:
(on_transition_in, etc) to get it. (so you can't do
session.setactivity(foo) and then ba.newnode() to add a node to foo)
"""
from ba._enums import TimeType
from ba._generated.enums import TimeType
# Make sure we don't get called recursively.
_rlock = self._SetActivityScopedLock(self)

View File

@ -61,7 +61,7 @@ def get_store_items() -> Dict[str, Dict]:
(internal)
"""
# pylint: disable=cyclic-import
from ba._enums import SpecialChar
from ba._generated.enums import SpecialChar
from bastd import maps
if _ba.app.store_items is None:
from bastd.game import ninjafight
@ -440,7 +440,7 @@ def get_available_sale_time(tab: str) -> Optional[int]:
# pylint: disable=too-many-locals
try:
import datetime
from ba._enums import TimeType, TimeFormat
from ba._generated.enums import TimeType, TimeFormat
app = _ba.app
sale_times: List[Optional[int]] = []

View File

@ -15,7 +15,7 @@ if TYPE_CHECKING:
def get_tournament_prize_strings(entry: Dict[str, Any]) -> List[str]:
"""Given a tournament entry, return strings for its prize levels."""
# pylint: disable=too-many-locals
from ba._enums import SpecialChar
from ba._generated.enums import SpecialChar
from ba._gameutils import get_trophy_string
range1 = entry.get('prizeRange1')
range2 = entry.get('prizeRange2')

View File

@ -7,7 +7,7 @@ from __future__ import annotations
from typing import TYPE_CHECKING
import _ba
from ba._enums import UIScale
from ba._generated.enums import UIScale
if TYPE_CHECKING:
from typing import Optional, Dict, Any, Callable, List, Type
@ -70,7 +70,7 @@ class UISubsystem:
def on_app_launch(self) -> None:
"""Should be run on app launch."""
from ba.ui import UIController, ui_upkeep
from ba._enums import TimeType
from ba._generated.enums import TimeType
# IMPORTANT: If tweaking UI stuff, make sure it behaves for small,
# medium, and large UI modes. (doesn't run off screen, etc).
@ -107,7 +107,7 @@ class UISubsystem:
def set_main_menu_window(self, window: ba.Widget) -> None:
"""Set the current 'main' window, replacing any existing."""
existing = self._main_menu_window
from ba._enums import TimeType
from ba._generated.enums import TimeType
from inspect import currentframe, getframeinfo
# Let's grab the location where we were called from to report

View File

@ -69,7 +69,7 @@ class _MacMusicAppThread(threading.Thread):
"""Run the Music.app thread."""
from ba._general import Call
from ba._language import Lstr
from ba._enums import TimeType
from ba._generated.enums import TimeType
_ba.set_thread_name('BA_MacMusicAppThread')
_ba.mac_music_app_init()

View File

@ -40,7 +40,7 @@ def get_human_readable_user_scripts_path() -> str:
def _request_storage_permission() -> bool:
"""If needed, requests storage permission from the user (& return true)."""
from ba._language import Lstr
from ba._enums import Permission
from ba._generated.enums import Permission
if not _ba.have_permission(Permission.STORAGE):
_ba.playsound(_ba.getsound('error'))
_ba.screenmessage(Lstr(resource='storagePermissionAccessText'),

View File

@ -10,7 +10,7 @@ from dataclasses import dataclass
from typing import TYPE_CHECKING, cast, Type
import _ba
from ba._enums import TimeType
from ba._generated.enums import TimeType
from ba._general import print_active_refs
if TYPE_CHECKING:

View File

@ -452,6 +452,7 @@
<w>hacky</w>
<w>haha</w>
<w>halign</w>
<w>handfull</w>
<w>handlemessage</w>
<w>hatmotion</w>
<w>haveint</w>
@ -597,6 +598,7 @@
<w>makelevel</w>
<w>malhotra</w>
<w>mallocs</w>
<w>mantype</w>
<w>manualtab</w>
<w>maskhigh</w>
<w>maskuv</w>

View File

@ -1,5 +1,5 @@
<!-- THIS FILE IS AUTO GENERATED; DO NOT EDIT BY HAND -->
<h4><em>last updated on 2021-06-17 for Ballistica version 1.6.4 build 20387</em></h4>
<h4><em>last updated on 2021-06-18 for Ballistica version 1.6.4 build 20387</em></h4>
<p>This page documents the Python classes and functions in the 'ba' module,
which are the ones most relevant to modding in Ballistica. If you come across something you feel should be included here or could be better explained, please <a href="mailto:support@froemling.net">let me know</a>. Happy modding!</p>
<hr>

View File

@ -1,4 +1,6 @@
[
"assets/src/ba_data/python/ba/_generated/__init__.py",
"assets/src/ba_data/python/ba/_generated/enums.py",
"src/ballistica/generated/python_embedded/binding.inc",
"src/ballistica/generated/python_embedded/bootstrap.inc"
]

View File

@ -12,6 +12,8 @@ clean:
#__AUTOGENERATED_PUBLIC_BEGIN__
sources: \
../../assets/src/ba_data/python/ba/_generated/__init__.py \
../../assets/src/ba_data/python/ba/_generated/enums.py \
../ballistica/generated/python_embedded/binding.inc \
../ballistica/generated/python_embedded/bootstrap.inc
@ -21,6 +23,12 @@ sources: \
../ballistica/generated/python_embedded/bootstrap.inc : bameta/python_embedded/bootstrap.py ../../tools/batools/meta.py
@$(PCOMMAND) gen_flat_data_code $< $@ bootstrap_code
../../assets/src/ba_data/python/ba/_generated/__init__.py : ../../tools/batools/pcommand.py
@$(PCOMMAND) gen_python_init_module $@
../../assets/src/ba_data/python/ba/_generated/enums.py : ../ballistica/core/types.h ../../tools/batools/pythonenumsmodule.py
@$(PCOMMAND) gen_python_enums_module $< $@
#__AUTOGENERATED_PUBLIC_END__
# This section is autogenerated; do not edit by hand.
@ -32,7 +40,9 @@ sources: \
# cases where we can't use our full Makefiles.
efrocache-list:
@echo "../ballistica/generated/python_embedded/binding.inc" \
@echo "../../assets/src/ba_data/python/ba/_generated/__init__.py" \
"../../assets/src/ba_data/python/ba/_generated/enums.py" \
"../ballistica/generated/python_embedded/binding.inc" \
"../ballistica/generated/python_embedded/bootstrap.inc"
efrocache-build: sources

View File

@ -16,7 +16,7 @@ from ba import _music
from ba import _input
from ba import _apputils
from ba import _dependency
from ba import _enums
from ba._generated import enums
from ba import _player
from ba import _hooks
import _ba
@ -126,11 +126,11 @@ def get_binding_values() -> Tuple[Any, ...]:
ba.ActivityNotFoundError, # kActivityNotFoundError
ba.SessionNotFoundError, # kSessionNotFoundError
_dependency.AssetPackage, # kAssetPackageClass
_enums.TimeFormat, # kTimeFormatClass
_enums.TimeType, # kTimeTypeClass
_enums.InputType, # kInputTypeClass
_enums.Permission, # kPermissionClass
_enums.SpecialChar, # kSpecialCharClass
enums.TimeFormat, # kTimeFormatClass
enums.TimeType, # kTimeTypeClass
enums.InputType, # kInputTypeClass
enums.Permission, # kPermissionClass
enums.SpecialChar, # kSpecialCharClass
_player.Player, # kPlayerClass
_hooks.get_player_icon, # kGetPlayerIconCall
_language.Lstr.from_json, # kLstrFromJsonCall

View File

@ -53,12 +53,12 @@ def _get_py_targets(src: str, dst: str, py_targets: List[str],
subset: str) -> None:
# pylint: disable=too-many-branches
# Create py and pyc targets for all scripts in src.
for root, _dname, fnames in os.walk(src):
py_generated_root = 'assets/src/ba_data/python/ba/_generated'
def _do_get_targets(root: str, fnames: List[str]) -> None:
# Special case: ignore temp py files in data src.
if root == 'assets/src/ba_data/data/maps':
continue
return
assert root.startswith(src)
dstrootvar = dst[len('assets') + 1:] + root[len(src):]
dstfin = dst + root[len(src):]
@ -108,6 +108,33 @@ def _get_py_targets(src: str, dst: str, py_targets: List[str],
pyc_targets.append(
os.path.join(dstrootvar, '__pycache__', fname_pyc))
# Create py and pyc targets for all physical scripts in src, with
# the exception of our dynamically generated stuff.
for physical_root, _dname, physical_fnames in os.walk(src):
# Skip any generated files; we'll add those from the meta manifest.
# (dont want our results to require a meta build beforehand)
if (physical_root == py_generated_root
or physical_root.startswith(py_generated_root + '/')):
continue
_do_get_targets(physical_root, physical_fnames)
# Now create targets for any of our dynamically generated stuff that
# lives under this dir.
meta_targets: List[str] = []
for mantype in ['public', 'private']:
with open(f'src/meta/.meta_manifest_{mantype}.json') as infile:
meta_targets += json.loads(infile.read())
meta_targets = [
t for t in meta_targets
if t.startswith(src + '/') and t.startswith(py_generated_root + '/')
]
for target in meta_targets:
_do_get_targets(root=os.path.dirname(target),
fnames=[os.path.basename(target)])
def _get_py_targets_subset(all_targets: Set[str], subset: str,
suffix: str) -> str:
@ -146,6 +173,7 @@ def _get_py_targets_subset(all_targets: Set[str], subset: str,
# We transform all non-public targets into efrocache-fetches in public.
efc = '' if subset.startswith('public') else '#__EFROCACHE_TARGET__\n'
out += ('\n# Rule to copy src asset scripts to dst.\n'
'# (and make non-writable so I\'m less likely to '
'accidentally edit them there)\n'

View File

@ -176,7 +176,9 @@ def lazybuild(target: str, category: SourceCategory, command: str) -> None:
if category is SourceCategory.META:
paths = [
'Makefile', 'tools/batoolsinternal/meta.py',
'tools/batools/meta.py', 'src/meta'
'tools/batoolsinternal/pcommand.py', 'tools/batools/meta.py',
'tools/batools/pcommand.py', 'src/meta',
'tools/batools/pythonenumsmodule.py'
]
# Everything possibly affecting asset builds.

View File

@ -623,7 +623,7 @@ def generate(sources_hash: str, outfilename: str) -> None:
'\n'
'from typing import TYPE_CHECKING, overload, Sequence, TypeVar\n'
'\n'
'from ba._enums import TimeFormat, TimeType\n'
'from ba._generated.enums import TimeFormat, TimeType\n'
'\n'
'if TYPE_CHECKING:\n'
' from typing import (Any, Dict, Callable, Tuple, '

View File

@ -25,6 +25,7 @@ if TYPE_CHECKING:
TOOLS_DIR = '../../tools'
ROOT_DIR = '../..'
OUT_DIR_CPP = '../ballistica/generated'
OUT_DIR_PYTHON = '../../assets/src/ba_data/python/ba/_generated'
@dataclass
@ -80,6 +81,27 @@ def _emit_group_efrocache_lines(targets: List[Target]) -> List[str]:
return out
def _add_enums_module_target(targets: List[Target]) -> None:
targets.append(
Target(
src=[
'../ballistica/core/types.h',
os.path.join(TOOLS_DIR, 'batools', 'pythonenumsmodule.py')
],
dst=os.path.join(OUT_DIR_PYTHON, 'enums.py'),
cmd='$(PCOMMAND) gen_python_enums_module $< $@',
))
def _add_init_module_target(targets: List[Target]) -> None:
targets.append(
Target(
src=[os.path.join(TOOLS_DIR, 'batools', 'pcommand.py')],
dst=os.path.join(OUT_DIR_PYTHON, '__init__.py'),
cmd='$(PCOMMAND) gen_python_init_module $@',
))
def _add_python_embedded_targets(targets: List[Target]) -> None:
pkg = 'bameta'
# Note: sort to keep things deterministic.
@ -179,6 +201,8 @@ def update(projroot: str, check: bool) -> None:
pubtargets = targets
basename = 'public'
_add_python_embedded_targets(targets)
_add_init_module_target(targets)
_add_enums_module_target(targets)
our_lines_public = (_empty_line_if(bool(targets)) +
_emit_group_build_lines(targets, basename) +
[t.emit() for t in targets])

View File

@ -851,7 +851,7 @@ def win_ci_binary_build() -> None:
import subprocess
from efrotools.efrocache import get_target
# We'll need to pull a handfull of things out of efrocache for the
# We'll need to pull a handful of things out of efrocache for the
# build to succeed. Normally this would happen through our Makefile
# targets but we can't use them under raw window so we need to just
# hard-code whatever we need here.
@ -931,10 +931,27 @@ def xcode_build_path() -> None:
print(path)
def update_python_enums_module() -> None:
def gen_python_enums_module() -> None:
"""Update our procedurally generated python enums."""
from batools.pythonenumsmodule import update
update(projroot=str(PROJROOT), check='--check' in sys.argv)
from batools.pythonenumsmodule import generate
if len(sys.argv) != 4:
raise Exception('Expected infile and outfile args.')
generate(infilename=sys.argv[2], outfilename=sys.argv[3])
def gen_python_init_module() -> None:
"""Generate a basic __init__.py."""
import os
from efro.terminal import Clr
if len(sys.argv) != 3:
raise Exception('Expected an outfile arg.')
outfilename = sys.argv[2]
os.makedirs(os.path.dirname(outfilename), exist_ok=True)
print(f'Meta-building {Clr.BLD}{outfilename}{Clr.RST}')
with open(outfilename, 'w') as outfile:
outfile.write('# Released under the MIT License.'
' See LICENSE for details.\n'
'#\n')
def update_dummy_module() -> None:

View File

@ -65,8 +65,8 @@ class Updater:
if not os.path.isdir('config') or not os.path.isdir('tools'):
raise Exception('This must be run from a project root.')
# NOTE: Do py-enums before updating asset deps since it *is* an asset.
self._update_python_enums_module()
# Note: we need to update the meta Makefile first since its output
# manifest may be used when generating asset/resource targets.
self._update_meta_makefile()
self._update_resources_makefile()
self._update_assets_makefile()
@ -646,18 +646,6 @@ class Updater:
raise CleanError(
'Error checking/updating resources Makefile.') from exc
def _update_python_enums_module(self) -> None:
# FIXME: should support running this in public too.
if not self._public:
try:
subprocess.run(
['tools/pcommand', 'update_python_enums_module'] +
self._checkarglist,
check=True)
except Exception as exc:
raise CleanError(
'Error checking/updating python enums module.') from exc
def _update_dummy_module(self) -> None:
# Update our dummy _ba module.
# Note: This should happen near the end because it may run the cmake

View File

@ -1,4 +1,3 @@
#!/usr/bin/env python3.8
# Released under the MIT License. See LICENSE for details.
#
"""Procedurally regenerates our python enums module.
@ -8,9 +7,8 @@ python enums for them.
"""
from __future__ import annotations
import os
import re
import sys
import os
from typing import TYPE_CHECKING
from efro.terminal import Clr
@ -19,8 +17,6 @@ from efrotools import get_public_license
if TYPE_CHECKING:
from typing import Optional, List, Tuple
OUTPUT_FILENAME = 'assets/src/ba_data/python/ba/_enums.py'
def camel_case_convert(name: str) -> str:
"""Convert camel-case text to upcase-with-underscores."""
@ -28,10 +24,10 @@ def camel_case_convert(name: str) -> str:
return re.sub('([a-z0-9])([A-Z])', r'\1_\2', str1).upper()
def _gen_enums() -> str:
def _gen_enums(infilename: str) -> str:
out = ''
enum_lnums: List[int] = []
with open('src/ballistica/core/types.h') as infile:
with open(infilename) as infile:
lines = infile.read().splitlines()
# Tally up all places tagged for exporting python enums.
@ -141,32 +137,16 @@ def _parse_doc_lines(lines: List[str], lnum: int) -> Tuple[List[str], int]:
return doclines, lnum
def update(projroot: str, check: bool) -> None:
def generate(infilename: str, outfilename: str) -> None:
"""Main script entry point."""
# Operate out of root dist dir for consistency.
os.chdir(projroot)
fname = OUTPUT_FILENAME
existing: Optional[str]
try:
with open(fname, 'r') as infile:
existing = infile.read()
except Exception:
existing = None
out = (get_public_license('python') +
f'\n"""Enum vals generated by {__name__}; do not edit by hand."""'
f'\n\nfrom enum import Enum\n')
out += _gen_enums()
out += _gen_enums(infilename)
if out == existing:
print('Python enums module is up to date.')
else:
if check:
print(Clr.SRED + 'ERROR: file out of date: ' + fname + Clr.RST)
sys.exit(255)
print(Clr.SBLU + 'Generating: ' + fname + Clr.RST)
with open(fname, 'w') as outfile:
outfile.write(out)
print(f'Meta-building {Clr.BLD}{outfilename}{Clr.RST}')
os.makedirs(os.path.dirname(outfilename), exist_ok=True)
with open(outfilename, 'w') as outfile:
outfile.write(out)

View File

@ -41,7 +41,8 @@ from batools.pcommand import (
cmake_prep_dir, gen_binding_code, gen_flat_data_code, wsl_path_to_win,
wsl_build_check_win_drive, win_ci_binary_build, genchangelog,
android_sdk_utils, update_resources_makefile, update_meta_makefile,
xcode_build_path, update_python_enums_module, update_dummy_module)
xcode_build_path, gen_python_enums_module, gen_python_init_module,
update_dummy_module)
# pylint: enable=unused-import
if TYPE_CHECKING: