From bc880a645ed361fd22df2cf4a7d068c52f991a20 Mon Sep 17 00:00:00 2001 From: Eric Froemling Date: Mon, 12 Oct 2020 18:43:46 -0700 Subject: [PATCH] Added CMake build support to Windows WSL --- .efrocachemap | 8 ++++---- .idea/dictionaries/ericf.xml | 3 +++ Makefile | 6 +++--- docs/ba_module.md | 2 +- tools/batools/build.py | 18 ++++++++++-------- tools/batools/pcommand.py | 8 +++----- tools/efro/util.py | 12 ++++++++++++ tools/pcommand | 3 ++- 8 files changed, 38 insertions(+), 22 deletions(-) diff --git a/.efrocachemap b/.efrocachemap index ccbfc8a3..0c74cbbc 100644 --- a/.efrocachemap +++ b/.efrocachemap @@ -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" } \ No newline at end of file diff --git a/.idea/dictionaries/ericf.xml b/.idea/dictionaries/ericf.xml index 917d442e..e69f197f 100644 --- a/.idea/dictionaries/ericf.xml +++ b/.idea/dictionaries/ericf.xml @@ -177,6 +177,7 @@ bcppcompiler bcyn bdfl + bdir belarussian benboncan bfiledir @@ -1792,6 +1793,7 @@ scrlw scrollw scrollwidget + scsb scyn sdata sdkutils @@ -2258,6 +2260,7 @@ waaah waittime wanttype + warntype wasdead wavenum weakref diff --git a/Makefile b/Makefile index 3f3d1571..a064852f 100644 --- a/Makefile +++ b/Makefile @@ -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} diff --git a/docs/ba_module.md b/docs/ba_module.md index 423d0bc6..9e071cb9 100644 --- a/docs/ba_module.md +++ b/docs/ba_module.md @@ -1,5 +1,5 @@ -

last updated on 2020-10-12 for Ballistica version 1.5.26 build 20200

+

last updated on 2020-10-12 for Ballistica version 1.5.26 build 20201

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 let me know. Happy modding!


diff --git a/tools/batools/build.py b/tools/batools/build.py index e2527896..70a21fd5 100644 --- a/tools/batools/build.py +++ b/tools/batools/build.py @@ -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': diff --git a/tools/batools/pcommand.py b/tools/batools/pcommand.py index 8000b2da..9d5c76b9 100644 --- a/tools/batools/pcommand.py +++ b/tools/batools/pcommand.py @@ -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') diff --git a/tools/efro/util.py b/tools/efro/util.py index 4cbeb88f..8e3fc278 100644 --- a/tools/efro/util.py +++ b/tools/efro/util.py @@ -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. diff --git a/tools/pcommand b/tools/pcommand index 0e328029..82e80a53 100755 --- a/tools/pcommand +++ b/tools/pcommand @@ -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: