Wiring up prefab internal libs to cmake builds

This commit is contained in:
Eric Froemling 2020-10-12 09:40:37 -07:00
parent 6cdc92e39d
commit 0b8e59f478
5 changed files with 56 additions and 7 deletions

View File

@ -3948,8 +3948,8 @@
"build/prefab/lib/linux_x86_64/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/32/03/d4dd9c398eab7c7da62b2e7a4096",
"build/prefab/lib/linux_x86_64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/11/f5/cb2b3a42e4384d6ac4dfe7a98213",
"build/prefab/lib/linux_x86_64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/06/aa/fc55996ce9a1a3e898d1348873ff",
"build/prefab/lib/mac_x86_64/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/6b/16/c058434a86f13606cbd6bec7167c",
"build/prefab/lib/mac_x86_64/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/cc/e2/f1ef7e986d9b3cc9e5f2d392def7",
"build/prefab/lib/mac_x86_64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/bd/b3/3e5c54b74ce8f4d606e766823903",
"build/prefab/lib/mac_x86_64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/5a/5a/077d74f31286ced414f08cbd1f94"
"build/prefab/lib/mac_x86_64/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/7d/48/48c832b29b04ec4ccc261d56603b",
"build/prefab/lib/mac_x86_64/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/ce/5c/d36f3f9da946fbee20c3977b94a4",
"build/prefab/lib/mac_x86_64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/ea/ff/eb2be69f12eca21808614649776b",
"build/prefab/lib/mac_x86_64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/5f/8c/a767dd7cfd77dcef570feab477f1"
}

View File

@ -716,6 +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}
@${STAGE_ASSETS} -cmake build/cmake/$(CM_BT_LC)
@cd build/cmake/$(CM_BT_LC) && test -f Makefile \
|| cmake -DCMAKE_BUILD_TYPE=$(CMAKE_BUILD_TYPE) \
@ -730,6 +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}
@${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 \
@ -811,9 +813,15 @@ ENV_SRC = tools/pcommand tools/batools/build.py
# CMake build-type lowercase
CM_BT_LC = $(shell echo $(CMAKE_BUILD_TYPE) | tr A-Z a-z)
_update-prefab-libs:
@tools/pcommand update_prefab_libs standard ${CM_BT_LC}
_update-prefab-libs-server:
@tools/pcommand update_prefab_libs server ${CM_BT_LC}
# When using CLion, our cmake dir is root. Expose .clang-format there too.
ballisticacore-cmake/.clang-format: .clang-format
@cd ballisticacore-cmake && ln -sf ../.clang-format .
# Tell make which of these targets don't represent files.
.PHONY:
.PHONY: _cmake-prefab-lib

View File

@ -186,5 +186,5 @@ target_include_directories(ballisticacore PRIVATE
# NOTE: seems we need to add 'dl' here for raspberry pi with a manually
# built Python 3.8. Might be able to remove later.
target_link_libraries(ballisticacore PRIVATE
ballisticacore_internal ode pthread ${Python_LIBRARIES}
${CMAKE_CURRENT_BINARY_DIR}/prefablib/libballisticacore_internal.a ode pthread ${Python_LIBRARIES}
${SDL2_LIBRARIES} ${EXTRA_LIBRARIES} dl)

View File

@ -683,6 +683,47 @@ def update_project() -> None:
Updater(check=check, fix=fix).run()
def update_prefab_libs() -> None:
"""Update prefab internal libs for builds."""
import subprocess
import os
from efro.error import CleanError
import batools.build
if len(sys.argv) != 4:
raise CleanError('Expected 2 args (standard/server, debug/release)')
buildtype = sys.argv[2]
mode = sys.argv[3]
if buildtype not in {'standard', 'server'}:
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()
suffix = '_server' if buildtype == 'server' else ''
target = (f'build/prefab/lib/{platform}{suffix}/{mode}/'
f'libballisticacore_internal.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)
prefix = 'server-' if buildtype == 'server' else ''
suffix = '/dist' if buildtype == 'server' else ''
libdir = f'build/cmake/{prefix}{mode}{suffix}/prefablib'
libpath = os.path.join(libdir, 'libballisticacore_internal.a')
update = True
time1 = os.path.getmtime(target)
if os.path.exists(libpath):
time2 = os.path.getmtime(libpath)
if time1 <= time2:
update = False
if update:
if not os.path.exists(libdir):
os.makedirs(libdir, exist_ok=True)
subprocess.run(['cp', target, libdir], check=True)
def cmake_prep_dir() -> None:
"""Create a dir, recreating it when cmake/python/etc. version changes.

View File

@ -37,7 +37,7 @@ 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, cmake_prep_dir)
update_assets_makefile, update_project, update_prefab_libs, cmake_prep_dir)
# pylint: enable=unused-import
if TYPE_CHECKING: