Added CMake build support to Windows WSL

This commit is contained in:
Eric Froemling 2020-10-12 18:43:46 -07:00
parent 3fb6b0ab07
commit bc880a645e
8 changed files with 38 additions and 22 deletions

View File

@ -3948,8 +3948,8 @@
"build/prefab/lib/linux_x86_64/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/4c/a9/568023651355fdd0ce7a865c2872",
"build/prefab/lib/linux_x86_64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/82/80/5c56c9f311d997f73ed3ed41eb39",
"build/prefab/lib/linux_x86_64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/42/be/79eec8bc7b2cc914cc6cb8ed0769",
"build/prefab/lib/mac_x86_64/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/89/3e/7c8a36f1d37195fb8c9bd8088276",
"build/prefab/lib/mac_x86_64/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/b7/a5/2c60483331e391a88ba5cbad31c1",
"build/prefab/lib/mac_x86_64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/69/49/801eb43b86bcce796266a08ae3ab",
"build/prefab/lib/mac_x86_64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/fa/53/cbd657a2f8d5535f830e5424db86"
"build/prefab/lib/mac_x86_64/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/7a/f9/f4e0a049de82210b1a6ce242f51d",
"build/prefab/lib/mac_x86_64/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/a6/74/ccba7f0db9f5a32033e4bd77e183",
"build/prefab/lib/mac_x86_64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/96/b0/88bdf10a9a7cb7ca65b2130ed109",
"build/prefab/lib/mac_x86_64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/f0/09/0c95bbb431fa8c93f1e23d508b37"
}

View File

@ -177,6 +177,7 @@
<w>bcppcompiler</w>
<w>bcyn</w>
<w>bdfl</w>
<w>bdir</w>
<w>belarussian</w>
<w>benboncan</w>
<w>bfiledir</w>
@ -1792,6 +1793,7 @@
<w>scrlw</w>
<w>scrollw</w>
<w>scrollwidget</w>
<w>scsb</w>
<w>scyn</w>
<w>sdata</w>
<w>sdkutils</w>
@ -2258,6 +2260,7 @@
<w>waaah</w>
<w>waittime</w>
<w>wanttype</w>
<w>warntype</w>
<w>wasdead</w>
<w>wavenum</w>
<w>weakref</w>

View File

@ -716,7 +716,7 @@ cmake: cmake-build
# Build but don't run it.
cmake-build: assets-cmake resources code
@tools/pcommand cmake_prep_dir build/cmake/$(CM_BT_LC)
@tools/pcommand update_prefab_libs standard ${CM_BT_LC} build/cmake/${CM_BT_LC}
@tools/pcommand update_cmake_prefab_lib standard ${CM_BT_LC} build/cmake/${CM_BT_LC}
@${STAGE_ASSETS} -cmake build/cmake/$(CM_BT_LC)
@cd build/cmake/$(CM_BT_LC) && test -f Makefile \
|| cmake -DCMAKE_BUILD_TYPE=$(CMAKE_BUILD_TYPE) \
@ -731,7 +731,7 @@ cmake-server: cmake-server-build
cmake-server-build: assets-cmake resources code
@tools/pcommand cmake_prep_dir build/cmake/server-$(CM_BT_LC)/dist
@tools/pcommand update_prefab_libs server ${CM_BT_LC} build/cmake/server-${CM_BT_LC}/dist
@tools/pcommand update_cmake_prefab_lib server ${CM_BT_LC} build/cmake/server-${CM_BT_LC}/dist
@${STAGE_ASSETS} -cmakeserver -${CM_BT_LC} build/cmake/server-$(CM_BT_LC)
@cd build/cmake/server-$(CM_BT_LC)/dist && test -f Makefile \
|| cmake -DCMAKE_BUILD_TYPE=$(CMAKE_BUILD_TYPE) -DHEADLESS=true \
@ -821,7 +821,7 @@ ballisticacore-cmake/.clang-format: .clang-format
_cmake-simple-ci-server-build:
rm -rf build/cmake_scsb
mkdir -p build/cmake_scsb
tools/pcommand update_prefab_libs server debug build/cmake_scsb
tools/pcommand update_cmake_prefab_lib server debug build/cmake_scsb
cd build/cmake_scsb && \
cmake -DCMAKE_BUILD_TYPE=Debug -DHEADLESS=true ${PWD}/ballisticacore-cmake
cd build/cmake_scsb && ${MAKE} -j${CPUS}

View File

@ -1,5 +1,5 @@
<!-- THIS FILE IS AUTO GENERATED; DO NOT EDIT BY HAND -->
<h4><em>last updated on 2020-10-12 for Ballistica version 1.5.26 build 20200</em></h4>
<h4><em>last updated on 2020-10-12 for Ballistica version 1.5.26 build 20201</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

@ -446,7 +446,7 @@ def gen_fulltest_buildfile_linux() -> None:
outfile.write('\n'.join(lines))
def get_current_prefab_platform() -> str:
def get_current_prefab_platform(wsl_gives_windows: bool = True) -> str:
"""Get the name of the running platform.
Throws a RuntimeError on unsupported platforms.
@ -462,13 +462,15 @@ def get_current_prefab_platform() -> str:
f' {machine}.')
if system == 'Linux':
# If it looks like we're in Windows Subsystem for Linux,
# go with the Windows version.
if 'microsoft' in platform.uname().release.lower():
# TODO: add support for arm windows
if machine == 'x86_64':
return 'windows_x86'
raise RuntimeError(f'make_prefab: unsupported win machine type:'
f' {machine}.')
# we may want to operate on Windows versions.
if wsl_gives_windows:
if 'microsoft' in platform.uname().release.lower():
# TODO: add support for arm windows
if machine == 'x86_64':
return 'windows_x86'
raise RuntimeError(
f'make_prefab: unsupported win machine type:'
f' {machine}.')
# TODO: add support for arm linux.
if machine == 'x86_64':

View File

@ -683,14 +683,15 @@ def update_project() -> None:
Updater(check=check, fix=fix).run()
def update_prefab_libs() -> None:
def update_cmake_prefab_lib() -> None:
"""Update prefab internal libs for builds."""
import subprocess
import os
from efro.error import CleanError
import batools.build
if len(sys.argv) != 5:
raise CleanError('Expected 2 args (standard/server, debug/release)')
raise CleanError('Expected 3 args (standard/server,'
' debug/release, build-dir)')
buildtype = sys.argv[2]
mode = sys.argv[3]
builddir = sys.argv[4]
@ -707,9 +708,6 @@ def update_prefab_libs() -> None:
# or the existing one is older than our target.
subprocess.run(['make', target], check=True)
# prefix = 'server-' if buildtype == 'server' else ''
# suffix = '/dist' if buildtype == 'server' else ''
# libdir = f'build/cmake/{prefix}{mode}{suffix}/prefablib'
libdir = os.path.join(builddir, 'prefablib')
libpath = os.path.join(libdir, 'libballisticacore_internal.a')

View File

@ -329,6 +329,18 @@ def checktype(obj: Any, typ: Type[T]) -> T:
return obj
def warntype(obj: Any, typ: Type[T]) -> T:
"""Return an object typed as a given type.
Always checks the type at runtime and simply logs a warning if it is
not what is expected.
"""
if not isinstance(obj, typ):
import logging
logging.warning('warntype: expected a %s, got a %s', typ, type(obj))
return obj # type: ignore
def assert_non_optional(obj: Optional[T]) -> T:
"""Return an object with Optional typing removed.

View File

@ -37,7 +37,8 @@ from batools.pcommand import (
list_pip_reqs, install_pip_reqs, checkenv, ensure_prefab_platform,
prefab_run_var, make_prefab, update_makebob, lazybuild,
android_archive_unstripped_libs, efro_gradle, stage_assets,
update_assets_makefile, update_project, update_prefab_libs, cmake_prep_dir)
update_assets_makefile, update_project, update_cmake_prefab_lib,
cmake_prep_dir)
# pylint: enable=unused-import
if TYPE_CHECKING: