revamping building from WSL

This commit is contained in:
Eric 2024-03-14 10:27:16 -07:00
parent 9362999c1c
commit 4ac7fef7e7
No known key found for this signature in database
GPG Key ID: 89C93F0F8D6D5A98
8 changed files with 188 additions and 113 deletions

56
.efrocachemap generated
View File

@ -4061,26 +4061,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": "ae5d54179a3a0fae2de63332844033ad",
"build/prefab/full/linux_arm64_gui/release/ballisticakit": "6ee081b61d4f2fdbd93486ded4f9a64c",
"build/prefab/full/linux_arm64_server/debug/dist/ballisticakit_headless": "e7407d776c2109ff69a3cb5ba7ee96e3",
"build/prefab/full/linux_arm64_server/release/dist/ballisticakit_headless": "31a2f27c9f96e6514546c2c287e2b02a",
"build/prefab/full/linux_x86_64_gui/debug/ballisticakit": "afe92df503843db897e9d352f0f9d15d",
"build/prefab/full/linux_x86_64_gui/release/ballisticakit": "1c195ea2f0436b0857bcf1f53596c9ed",
"build/prefab/full/linux_x86_64_server/debug/dist/ballisticakit_headless": "cebf710fd74b426078849cfb61ddfe05",
"build/prefab/full/linux_x86_64_server/release/dist/ballisticakit_headless": "70444645dab4201857c281df50c7fbab",
"build/prefab/full/mac_arm64_gui/debug/ballisticakit": "da829cffaeba3688c086706201f3cd9c",
"build/prefab/full/mac_arm64_gui/release/ballisticakit": "3c3dc389b03a8f6b79c0e1cbb5d57c28",
"build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "f4d13a59defe384f095d39c0b8fa0b93",
"build/prefab/full/mac_arm64_server/release/dist/ballisticakit_headless": "281d39c45a22a27a5f936901ad24ad83",
"build/prefab/full/mac_x86_64_gui/debug/ballisticakit": "04a4ee3d2743618f2742e68d715864b3",
"build/prefab/full/mac_x86_64_gui/release/ballisticakit": "046391bb7ddf1a3e76c07a0299211572",
"build/prefab/full/mac_x86_64_server/debug/dist/ballisticakit_headless": "5fe069c4c2f38d8bf5ab7cc90b8719ee",
"build/prefab/full/mac_x86_64_server/release/dist/ballisticakit_headless": "09bd3c5237d9cc020c805252470a05f5",
"build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "abeb51f519cdfc31a00630d5f90c2b87",
"build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "45872369ead35cd0702f645cb0290687",
"build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "d296df575fcbbc4c0d9d10390279b981",
"build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "ab42d76f9ce4d01e84d7b4af20f83a9f",
"build/prefab/full/linux_arm64_gui/debug/ballisticakit": "e02d676254f37e6a6bfc2d992832edc7",
"build/prefab/full/linux_arm64_gui/release/ballisticakit": "b6aae173f0657f98481ad513d9d4cbd5",
"build/prefab/full/linux_arm64_server/debug/dist/ballisticakit_headless": "35fb45c3895174231254aa97ff2d43e5",
"build/prefab/full/linux_arm64_server/release/dist/ballisticakit_headless": "f7bb6bcc1884a692e03f52c58d83bc89",
"build/prefab/full/linux_x86_64_gui/debug/ballisticakit": "42b848cb83e3fee4a56b0f24901c1423",
"build/prefab/full/linux_x86_64_gui/release/ballisticakit": "0af09f79ae95b7d31229e62ef925c283",
"build/prefab/full/linux_x86_64_server/debug/dist/ballisticakit_headless": "1babb2d89a351a48c1318515b23fb256",
"build/prefab/full/linux_x86_64_server/release/dist/ballisticakit_headless": "0ed1b2deda022680096fcc185437b2f5",
"build/prefab/full/mac_arm64_gui/debug/ballisticakit": "e3b96fd440e737d7ee9588aa5517a270",
"build/prefab/full/mac_arm64_gui/release/ballisticakit": "345a3346b1b3b28932b9fc3b6802ba58",
"build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "c4cfd2482416cf9a71a3dcb283dc06cc",
"build/prefab/full/mac_arm64_server/release/dist/ballisticakit_headless": "af6c9def782a7be317a247b0294d2577",
"build/prefab/full/mac_x86_64_gui/debug/ballisticakit": "6537ce8b82230275d3baa495f0b087e2",
"build/prefab/full/mac_x86_64_gui/release/ballisticakit": "18c6239b2284547be3f354a9ab74f65c",
"build/prefab/full/mac_x86_64_server/debug/dist/ballisticakit_headless": "a53872e247c56e1d297c8fc227ad38e9",
"build/prefab/full/mac_x86_64_server/release/dist/ballisticakit_headless": "38607776459217d77b60417a5a9a5fbe",
"build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "fb23a676c5e53441a101499801c5e0ee",
"build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "3bf6afb5a18a95b7a7d7286c6dcc106c",
"build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "8b0d174baa273f6d7921e067fae3316a",
"build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "2f37b65edd1c4eca4c2dd32506977696",
"build/prefab/lib/linux_arm64_gui/debug/libballisticaplus.a": "d9865523059d8cf11b2bef4b9da9a8c9",
"build/prefab/lib/linux_arm64_gui/release/libballisticaplus.a": "56d6440f62c271c4ce9ef520400395a3",
"build/prefab/lib/linux_arm64_server/debug/libballisticaplus.a": "d9865523059d8cf11b2bef4b9da9a8c9",
@ -4097,14 +4097,14 @@
"build/prefab/lib/mac_x86_64_gui/release/libballisticaplus.a": "c2cf0dc227e41a826c913d12e117c316",
"build/prefab/lib/mac_x86_64_server/debug/libballisticaplus.a": "fbdc80e41c5883b4a893d2f0786e377f",
"build/prefab/lib/mac_x86_64_server/release/libballisticaplus.a": "c2cf0dc227e41a826c913d12e117c316",
"build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.lib": "85e804e02022cf07b5cf6e9024b66b71",
"build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.pdb": "8477e27bd6da06fd0cc390aa9b2d49eb",
"build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.lib": "75c2eea1899eb33777c323165e766022",
"build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.pdb": "6dc94f266087d91a399825a57f3fef23",
"build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.lib": "43d912d3b4026d32b9c3fb08481684b1",
"build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.pdb": "d2a64a9724333ccbd32df8a9c8a1c2f8",
"build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.lib": "c13bed7154fdc3e1a83ffcea5756a375",
"build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.pdb": "02e9a86205d9549484c2f5d9a3eaebe8",
"build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.lib": "403d99152d4610ad11ea524772a84ca3",
"build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.pdb": "ce022601dc7ce016fe11ed5092534672",
"build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.lib": "e45a094dba08254cf1ba50bf435f5e8d",
"build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.pdb": "ea38b10f23c2791d92696f17b53f8fa7",
"build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.lib": "5ee3cbfcce6b6cd9bdaf8239c3b78d0d",
"build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.pdb": "aa3b5bd935d8593611f13108af5d9633",
"build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.lib": "1104c4f10bbe25539c1b4e38ba041375",
"build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.pdb": "aa0c1c558389babcaa2166ef9ae4bad0",
"src/assets/ba_data/python/babase/_mgen/__init__.py": "f885fed7f2ed98ff2ba271f9dbe3391c",
"src/assets/ba_data/python/babase/_mgen/enums.py": "b611c090513a21e2fe90e56582724e9d",
"src/ballistica/base/mgen/pyembed/binding_base.inc": "72bfed2cce8ff19741989dec28302f3f",

View File

@ -1,4 +1,4 @@
### 1.7.33 (build 21779, api 8, 2024-03-13)
### 1.7.33 (build 21785, api 8, 2024-03-14)
- Stress test input-devices are now a bit smarter; they won't press any buttons
while UIs are up (this could cause lots of chaos if it happened).
- Added a 'Show Demos When Idle' option in advanced settings. If enabled, the

View File

@ -210,37 +210,50 @@ pcommandbatch_speed_test: prereqs
# Prebuilt binaries for various platforms.
# WSL is Linux but running under Windows, so it can target either. By default
# we want it to yield Windows native builds for these prefab targets but this
# env var can be set to change that.
BA_WSL_TARGETS_WINDOWS ?= 1
# Assemble & run a gui debug build for this platform.
prefab-gui-debug: prefab-gui-debug-build
$($(shell $(PCOMMAND) prefab_run_var gui-debug))
BA_WSL_TARGETS_WINDOWS=$(BA_WSL_TARGETS_WINDOWS) \
$($(shell $(PCOMMAND) prefab_run_var gui-debug))
# Assemble & run a gui release build for this platform.
prefab-gui-release: prefab-gui-release-build
$($(shell $(PCOMMAND) prefab_run_var gui-release))
BA_WSL_TARGETS_WINDOWS=$(BA_WSL_TARGETS_WINDOWS) \
$($(shell $(PCOMMAND) prefab_run_var gui-release))
# Assemble a debug build for this platform.
prefab-gui-debug-build:
@$(PCOMMAND) make_prefab gui-debug
BA_WSL_TARGETS_WINDOWS=$(BA_WSL_TARGETS_WINDOWS) \
@$(PCOMMAND) make_prefab gui-debug
# Assemble a release build for this platform.
prefab-gui-release-build:
@$(PCOMMAND) make_prefab gui-release
BA_WSL_TARGETS_WINDOWS=$(BA_WSL_TARGETS_WINDOWS) \
@$(PCOMMAND) make_prefab gui-release
# Assemble & run a server debug build for this platform.
prefab-server-debug: prefab-server-debug-build
$($(shell $(PCOMMAND) prefab_run_var server-debug))
BA_WSL_TARGETS_WINDOWS=$(BA_WSL_TARGETS_WINDOWS) \
$($(shell $(PCOMMAND) prefab_run_var server-debug))
# Assemble & run a server release build for this platform.
prefab-server-release: prefab-server-release-build
$($(shell $(PCOMMAND) prefab_run_var server-release))
BA_WSL_TARGETS_WINDOWS=$(BA_WSL_TARGETS_WINDOWS) \
$($(shell $(PCOMMAND) prefab_run_var server-release))
# Assemble a server debug build for this platform.
prefab-server-debug-build:
@$(PCOMMAND) make_prefab server-debug
BA_WSL_TARGETS_WINDOWS=$(BA_WSL_TARGETS_WINDOWS) \
@$(PCOMMAND) make_prefab server-debug
# Assemble a server release build for this platform.
prefab-server-release-build:
@$(PCOMMAND) make_prefab server-release
BA_WSL_TARGETS_WINDOWS=$(BA_WSL_TARGETS_WINDOWS) \
@$(PCOMMAND) make_prefab server-release
# Clean all prefab builds.
prefab-clean:

View File

@ -52,7 +52,7 @@ if TYPE_CHECKING:
# Build number and version of the ballistica binary we expect to be
# using.
TARGET_BALLISTICA_BUILD = 21779
TARGET_BALLISTICA_BUILD = 21785
TARGET_BALLISTICA_VERSION = '1.7.33'

View File

@ -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 = 21779;
const int kEngineBuildNumber = 21785;
const char* kEngineVersion = "1.7.33";
const int kEngineApiVersion = 8;

View File

@ -76,6 +76,87 @@ class PrefabTarget(Enum):
GUI_RELEASE = 'gui-release'
SERVER_RELEASE = 'server-release'
@property
def buildtype(self) -> str:
"""Return the build type for this target."""
return self.value.split('-')[0]
@property
def buildmode(self) -> str:
"""Return the build mode for this target."""
return self.value.split('-')[1]
class PrefabPlatform(Enum):
"""Distinct os/cpu-arch/etc. combos we support for prefab builds."""
MAC_X86_64 = 'mac_x86_64'
MAC_ARM64 = 'mac_arm64'
WINDOWS_X86 = 'windows_x86'
LINUX_X86_64 = 'linux_x86_64'
LINUX_ARM64 = 'linux_arm64'
@classmethod
def get_current(
cls, wsl_targets_windows: bool | None = None
) -> PrefabPlatform:
"""Get an identifier for the platform running this build.
Pass a bool `wsl_targets_windows` value to cause WSL to target
either native Windows (True) or Linux (False). If this value is
not passed, the env var BA_WSL_TARGETS_WINDOWS is used, and if that
is not set, the default is False (Linux builds).
Throws a RuntimeError on unsupported platforms.
"""
import platform
if wsl_targets_windows is None:
wsl_targets_windows = (
os.environ.get('BA_WSL_TARGETS_WINDOWS', '0') == '1'
)
system = platform.system()
machine = platform.machine()
if system == 'Darwin':
if machine == 'x86_64':
return cls.MAC_X86_64
if machine == 'arm64':
return cls.MAC_ARM64
raise RuntimeError(
f'PrefabPlatform.get_current:'
f' unsupported mac machine type:'
f' {machine}.'
)
if system == 'Linux':
# If it looks like we're in Windows Subsystem for Linux, we may
# want to operate on Windows versions.
if wsl_targets_windows:
if 'microsoft' in platform.uname().release.lower():
if machine == 'x86_64':
# Currently always targeting 32 bit for prefab stuff.
return cls.WINDOWS_X86
# TODO: add support for arm windows
raise RuntimeError(
f'make_prefab: unsupported win machine type: {machine}.'
)
if machine == 'x86_64':
return cls.LINUX_X86_64
if machine == 'aarch64':
return cls.LINUX_ARM64
raise RuntimeError(
f'PrefabPlatform.get_current:'
f' unsupported linux machine type:'
f' {machine}.'
)
raise RuntimeError(
f'PrefabPlatform.get_current:'
f' unrecognized platform:'
f' {platform.system()}.'
)
class LazyBuildCategory(Enum):
"""Types of sources."""
@ -296,49 +377,6 @@ def archive_old_builds(
)
def get_current_prefab_platform(wsl_gives_windows: bool = True) -> str:
"""Get an identifier for the platform running this build.
Throws a RuntimeError on unsupported platforms.
"""
import platform
system = platform.system()
machine = platform.machine()
if system == 'Darwin':
if machine == 'x86_64':
return 'mac_x86_64'
if machine == 'arm64':
return 'mac_arm64'
raise RuntimeError(
f'make_prefab: unsupported mac machine type:' f' {machine}.'
)
if system == 'Linux':
# If it looks like we're in Windows Subsystem for Linux,
# we may want to operate on Windows versions.
if wsl_gives_windows:
if 'microsoft' in platform.uname().release.lower():
if machine == 'x86_64':
# Currently always targeting 32 bit for prefab stuff.
return 'windows_x86'
# TODO: add support for arm windows
raise RuntimeError(
f'make_prefab: unsupported win machine type: {machine}.'
)
if machine == 'x86_64':
return 'linux_x86_64'
if machine == 'aarch64':
return 'linux_arm64'
raise RuntimeError(
f'make_prefab: unsupported linux machine type:' f' {machine}.'
)
raise RuntimeError(
f'make_prefab: unrecognized platform:' f' {platform.system()}.'
)
def _vstr(nums: Sequence[int]) -> str:
return '.'.join(str(i) for i in nums)

View File

@ -616,60 +616,80 @@ def ensure_prefab_platform() -> None:
the prefab platform may be Windows; not Linux. Also, a 64-bit
os may be targeting a 32-bit platform.
"""
import batools.build
from efro.error import CleanError
from batools.build import PrefabPlatform
args = pcommand.get_args()
if len(args) != 1:
raise CleanError('Expected 1 platform name arg.')
needed = args[0]
current = batools.build.get_current_prefab_platform()
if current != needed:
needed = PrefabPlatform(args[0])
current = PrefabPlatform.get_current()
if current is not needed:
raise CleanError(
f'Incorrect platform: we are {current}, this requires {needed}.'
f'Incorrect platform: we are {current.value},'
f' this requires {needed.value}.'
)
def prefab_run_var() -> None:
"""Print the current platform prefab run target var."""
import batools.build
from batools.build import PrefabPlatform
args = pcommand.get_args()
if len(args) != 1:
raise RuntimeError('Expected 1 arg.')
base = args[0].replace('-', '_').upper()
platform = batools.build.get_current_prefab_platform().upper()
platform = PrefabPlatform.get_current().value.upper()
pcommand.clientprint(f'RUN_PREFAB_{platform}_{base}', end='')
def prefab_binary_path() -> None:
"""Print the current platform prefab binary path."""
import batools.build
"""Print the path to the current prefab binary."""
from typing import assert_never
from efro.error import CleanError
from batools.build import PrefabPlatform, PrefabTarget
pcommand.disallow_in_batch()
if len(sys.argv) != 3:
raise RuntimeError('Expected 1 arg.')
buildtype, buildmode = sys.argv[2].split('-')
platform = batools.build.get_current_prefab_platform()
options = ', '.join(t.value for t in PrefabTarget)
raise CleanError(f'Expected 1 PrefabTarget arg. Options are {options}.')
if platform.startswith('windows_'):
target = PrefabTarget(sys.argv[2])
buildtype = target.buildtype
buildmode = target.buildmode
platform = PrefabPlatform.get_current()
if platform is PrefabPlatform.WINDOWS_X86:
if buildtype == 'gui':
binpath = 'BallisticaKit.exe'
elif buildtype == 'server':
binpath = 'dist/BallisticaKitHeadless.exe'
else:
raise ValueError(f"Invalid buildtype '{buildtype}'.")
else:
elif (
platform is PrefabPlatform.MAC_ARM64
or platform is PrefabPlatform.MAC_X86_64
or platform is PrefabPlatform.LINUX_ARM64
or platform is PrefabPlatform.LINUX_X86_64
):
if buildtype == 'gui':
binpath = 'ballisticakit'
elif buildtype == 'server':
binpath = 'dist/ballisticakit_headless'
else:
raise ValueError(f"Invalid buildtype '{buildtype}'.")
else:
# Make sure we're covering all options.
assert_never(platform)
print(
f'build/prefab/full/{platform}_{buildtype}/{buildmode}/{binpath}',
f'build/prefab/full/{platform.value}_{buildtype}/{buildmode}/{binpath}',
end='',
)
@ -677,20 +697,20 @@ def prefab_binary_path() -> None:
def make_prefab() -> None:
"""Run prefab builds for the current platform."""
import subprocess
import batools.build
from batools.build import PrefabPlatform, PrefabTarget
pcommand.disallow_in_batch()
if len(sys.argv) != 3:
raise RuntimeError('Expected one argument')
target = batools.build.PrefabTarget(sys.argv[2])
platform = batools.build.get_current_prefab_platform()
targetstr = PrefabTarget(sys.argv[2]).value
platformstr = PrefabPlatform.get_current().value
# We use dashes instead of underscores in target names.
platform = platform.replace('_', '-')
platformstr = platformstr.replace('_', '-')
try:
subprocess.run(
['make', f'prefab-{platform}-{target.value}-build'], check=True
['make', f'prefab-{platformstr}-{targetstr}-build'], check=True
)
except (Exception, KeyboardInterrupt) as exc:
if str(exc):

View File

@ -204,7 +204,7 @@ def win_ci_install_prereqs() -> None:
# 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
# targets but we can't use them under raw Windows so we need to just
# hard-code whatever we need here.
lib_dbg_win32 = 'build/prefab/lib/windows/Debug_Win32'
needed_targets: set[str] = {
@ -256,11 +256,11 @@ def win_ci_binary_build() -> None:
def update_cmake_prefab_lib() -> None:
"""Update prefab internal libs for builds."""
"""Update prefab internal libs; run as part of a build."""
import subprocess
import os
from efro.error import CleanError
import batools.build
from batools.build import PrefabPlatform
pcommand.disallow_in_batch()
@ -275,14 +275,18 @@ def update_cmake_prefab_lib() -> None:
raise CleanError(f'Invalid buildtype: {buildtype}')
if mode not in {'debug', 'release'}:
raise CleanError(f'Invalid mode: {mode}')
platform = batools.build.get_current_prefab_platform(
wsl_gives_windows=False
)
suffix = '_server' if buildtype == 'server' else '_gui'
target = f'build/prefab/lib/{platform}{suffix}/{mode}/libballisticaplus.a'
# Build the target and then copy it to dst if it doesn't exist there yet
# or the existing one is older than our target.
# Our 'cmake' build targets use the Linux side of WSL; not native
# Windows.
platform = PrefabPlatform.get_current(wsl_targets_windows=False)
suffix = '_server' if buildtype == 'server' else '_gui'
target = (
f'build/prefab/lib/{platform.value}{suffix}/{mode}/libballisticaplus.a'
)
# Build the target and then copy it to dst if it doesn't exist there
# yet or the existing one is older than our target.
subprocess.run(['make', target], check=True)
libdir = os.path.join(builddir, 'prefablib')
@ -431,7 +435,7 @@ def wsl_build_check_win_drive() -> None:
!= 0
):
raise CleanError(
'wslpath not found; you must run this from a WSL environment'
"'wslpath' not found. This does not seem to be a WSL environment."
)
if os.environ.get('WSL_BUILD_CHECK_WIN_DRIVE_IGNORE') == '1':