making wsl window build conditions more strict

This commit is contained in:
Eric 2024-05-19 20:39:39 -07:00
parent f0b8845dbc
commit 38a3974a3c
No known key found for this signature in database
GPG Key ID: 89C93F0F8D6D5A98
5 changed files with 112 additions and 56 deletions

32
.efrocachemap generated
View File

@ -4046,18 +4046,18 @@
"build/prefab/full/linux_x86_64_gui/release/ballisticakit": "c6e86f716993e4db6d40b387c1887bf9",
"build/prefab/full/linux_x86_64_server/debug/dist/ballisticakit_headless": "fdb8c01b631d5475740f0101b301ff03",
"build/prefab/full/linux_x86_64_server/release/dist/ballisticakit_headless": "8c58b1dff5c711bf8dfe6bcc0c033e02",
"build/prefab/full/mac_arm64_gui/debug/ballisticakit": "474a2b87d36dfb930b8dc7dd49d47cb7",
"build/prefab/full/mac_arm64_gui/debug/ballisticakit": "2a38697e7097b33740af6cd8da8b1ae6",
"build/prefab/full/mac_arm64_gui/release/ballisticakit": "4bd338604cf6288636422ef3b62e5d44",
"build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "bb54dbc392300ee78f33bc2800aee546",
"build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "105b144a26c33ee82548ba7f66f8caf7",
"build/prefab/full/mac_arm64_server/release/dist/ballisticakit_headless": "316e826a593499760060c1c2c09fe278",
"build/prefab/full/mac_x86_64_gui/debug/ballisticakit": "1ef496d1816996878652807805722069",
"build/prefab/full/mac_x86_64_gui/debug/ballisticakit": "b28622b94e3193e73347df19619f88fe",
"build/prefab/full/mac_x86_64_gui/release/ballisticakit": "606f7ed5a63fad5acbdba62b8f2e953f",
"build/prefab/full/mac_x86_64_server/debug/dist/ballisticakit_headless": "89513725bac32ca45365113f0a52e6fe",
"build/prefab/full/mac_x86_64_server/debug/dist/ballisticakit_headless": "febd223d98d2a7dd66588024d9726a84",
"build/prefab/full/mac_x86_64_server/release/dist/ballisticakit_headless": "f98f149307ee2096aa5c82fb666d96b2",
"build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "4d4255c3a6ff19e95a3e2a6d5811b3a7",
"build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "0dfe7d534e684d0d36b7d87b1f017be9",
"build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "e4ebfac891518fc9e4dfc806be42d49d",
"build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "8daea1d15329b662419b1c5606318377",
"build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "c8ff03b720c5c07a46ad33d9b6de3a40",
"build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "7e3c487f558a48828e574f96df894079",
"build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "6214da7d6186d98512d848c29d4396af",
"build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "8725657f87d3654febe0d4176711c2cf",
"build/prefab/lib/linux_arm64_gui/debug/libballisticaplus.a": "9162b53189b80d4e5938cd142acd2a1a",
"build/prefab/lib/linux_arm64_gui/release/libballisticaplus.a": "2226d0e2d34051d962320c86464f3a2d",
"build/prefab/lib/linux_arm64_server/debug/libballisticaplus.a": "9162b53189b80d4e5938cd142acd2a1a",
@ -4074,14 +4074,14 @@
"build/prefab/lib/mac_x86_64_gui/release/libballisticaplus.a": "299b6c4b83966040618b27563b700c2a",
"build/prefab/lib/mac_x86_64_server/debug/libballisticaplus.a": "08c2f91d086e6f3fa73ebc299112358a",
"build/prefab/lib/mac_x86_64_server/release/libballisticaplus.a": "299b6c4b83966040618b27563b700c2a",
"build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.lib": "71f34c5440a6a9163ecd89b7011c111d",
"build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.pdb": "7f01c7b5a30449344d3d75e984fa1dda",
"build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.lib": "9c2ce406b476d6eb1035222e9a814e42",
"build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.pdb": "c130539910a8d495df3f4869723154a9",
"build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.lib": "ce70a22b90984b649ea6710591208099",
"build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.pdb": "7cde4323d9f150942c0234b785d92d1b",
"build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.lib": "6013f50d91d6188e02e25c45176e22ee",
"build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.pdb": "d644f9fc77040378625e7bdc0cba172b",
"build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.lib": "2507494bbe98a16131895f110448c8ea",
"build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.pdb": "61d67e343abf7925dac810e2811b1e10",
"build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.lib": "b19937612b1f9db29d7e758af7915b76",
"build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.pdb": "b73edce181aaffd3d2b5c4af87303bde",
"build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.lib": "cbbd994d39c7297d7779e0a3a1ef0435",
"build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.pdb": "661811a9424219211429d618d8c86d01",
"build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.lib": "e84c108ccd7a9f7d1f0c840d2cc3c108",
"build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.pdb": "ea607325f919e5b375ee4ac41262fa45",
"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",

View File

@ -68,6 +68,12 @@
- The `windows-debug` and `windows-release` Makefile targets should properly run
the game again (these build the Windows version of the game from a WSL
environment).
- WSL Windows builds are now more strict about their locations. Currently this
means they must exist somewhere under /mnt/c/. It is turning out that a
significant number of behavior workarounds (for file permission quirks, etc.)
need to happen to keep these builds behaving, so I'd like to enforce as
limited a set of conditions as possible to give us the best chance at
succeeding there.
- Added a workaround for WSL builds giving permission errors when staging asset
files that already exist. Please holler if you are building with WSL and still
running into any sort of errors, as I would love to make that path as reliable

View File

@ -700,3 +700,24 @@ def docker_build() -> None:
version_num,
build_num,
)
def wsl_windows_build_path_description() -> str:
"""Describe where wsl windows builds need to live."""
return 'anywhere under /mnt/c/'
def is_wsl_windows_build_path(path: str) -> bool:
"""Return whether a path is used for wsl windows builds.
Building Windows Visual Studio builds through WSL is currently only
supported in specific locations; namely anywhere under /mnt/c/. This
is enforced because building on the Linux filesystem errors due to
case-sensitivity issues, and also because a number of workarounds
need to be employed to deal with filesystem/permission quirks, so
we want to keep things as consistent as possible.
Note that said quirk workarounds WILL be applied if this returns
true, so this check should be as specific as possible.
"""
return path.startswith('/mnt/c/')

View File

@ -423,6 +423,10 @@ def wsl_build_check_win_drive() -> None:
import subprocess
import textwrap
from efro.error import CleanError
from batools.build import (
is_wsl_windows_build_path,
wsl_windows_build_path_description,
)
# We use env vars to influence our behavior and thus can't support
# batch.
@ -441,10 +445,12 @@ def wsl_build_check_win_drive() -> None:
if os.environ.get('WSL_BUILD_CHECK_WIN_DRIVE_IGNORE') == '1':
return
nativepath = os.getcwd()
# Get a windows path to the current dir.
path = (
winpath = (
subprocess.run(
['wslpath', '-w', '-a', os.getcwd()],
['wslpath', '-w', '-a', nativepath],
capture_output=True,
check=True,
)
@ -452,47 +458,68 @@ def wsl_build_check_win_drive() -> None:
.strip()
)
# If we're sitting under the linux filesystem, our path will start
# with '\\wsl$' or '\\wsl.localhost' or '\\wsl\'; fail in that case
# and explain why.
if not any(
path.startswith(x) for x in ['\\\\wsl$', '\\\\wsl.', '\\\\wsl\\']
):
return
def _wrap(txt: str) -> str:
return textwrap.fill(txt, 76)
raise CleanError(
'\n\n'.join(
[
_wrap(
'ERROR: This project appears to live'
' on the Linux filesystem.'
),
_wrap(
'Visual Studio compiles will error here for reasons related'
' to Linux filesystem case-sensitivity, and thus are'
' disallowed.'
' Clone the repo to a location that maps to a native'
' Windows drive such as \'/mnt/c/ballistica\''
' and try again.'
),
_wrap(
'Note that WSL2 filesystem performance'
' is poor when accessing'
' native Windows drives, so if Visual Studio builds are not'
' needed it may be best to keep things here'
' on the Linux filesystem.'
' This behavior may differ under WSL1 (untested).'
),
_wrap(
'Set env-var WSL_BUILD_CHECK_WIN_DRIVE_IGNORE=1 to skip'
' this check.'
),
]
# If we're sitting under the linux filesystem, our path will start
# with '\\wsl$' or '\\wsl.localhost' or '\\wsl\'; fail in that case
# and explain why.
if any(
winpath.startswith(x) for x in ['\\\\wsl$', '\\\\wsl.', '\\\\wsl\\']
):
raise CleanError(
'\n\n'.join(
[
_wrap(
'ERROR: This project appears to live'
' on the Linux filesystem.'
),
_wrap(
'Visual Studio compiles will error here'
' for reasons related'
' to Linux filesystem case-sensitivity, and thus are'
' disallowed.'
' Clone the repo to a location that maps to a native'
' Windows drive such as \'/mnt/c/ballistica\''
' and try again.'
),
_wrap(
'Note that WSL2 filesystem performance'
' is poor when accessing'
' native Windows drives,'
' so if Visual Studio builds are not'
' needed it may be best to keep things here'
' on the Linux filesystem.'
' This behavior may differ under WSL1 (untested).'
),
_wrap(
'Set env-var WSL_BUILD_CHECK_WIN_DRIVE_IGNORE=1 to skip'
' this check.'
),
]
)
)
# We also now require this check to be true. We key off this same
# check in other places to introduce various workarounds to deal
# with funky permissions issues/etc.
#
# Note that we could rely on *only* this check, but it might be nice
# to leave the above one in as well to better explain the Linux
# filesystem situation.
if not is_wsl_windows_build_path(nativepath):
reqs = wsl_windows_build_path_description()
raise CleanError(
'\n\n'.join(
[
_wrap(
f'ERROR: This project\'s path ({nativepath})'
f' is not valid for WSL Windows builds.'
f' Path must be: {reqs}.'
)
]
)
)
)
def wsl_path_to_win() -> None:

View File

@ -15,6 +15,8 @@ from efro.terminal import Clr
from efrotools.util import extract_arg, extract_flag
from efrotools.pyver import PYVER
from batools.build import is_wsl_windows_build_path
if TYPE_CHECKING:
pass
@ -232,7 +234,7 @@ class AssetStager:
#
# As a janky workaround, make everything in our dst dir writable
# by us before we do our work.
if self.projroot.startswith('/mnt/c/'):
if is_wsl_windows_build_path(self.projroot):
self.wsl_chmod_workaround = True
def _parse_android_args(self, args: list[str]) -> None: