From a994831e77129328657c22a5133e12a01d154075 Mon Sep 17 00:00:00 2001 From: Eric Date: Tue, 20 Jun 2023 12:02:23 -0700 Subject: [PATCH] hopefully fixing issues with precompiled plus lib in spinoff projects --- .efrocachemap | 32 ++++++++++++------------ tools/batools/spinoff/_context.py | 41 ++++++++++++++++++++++++++++++- 2 files changed, 56 insertions(+), 17 deletions(-) diff --git a/.efrocachemap b/.efrocachemap index 7041dc69..1128f8e9 100644 --- a/.efrocachemap +++ b/.efrocachemap @@ -4080,18 +4080,18 @@ "build/prefab/full/linux_x86_64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/1a/b6/9196bf7553c8380ddd37c8aba83f", "build/prefab/full/linux_x86_64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/24/56/34bbdafa6ed8d8505fa50b40e10a", "build/prefab/full/linux_x86_64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/0c/9b/6dbedf9c32a5591fbc0724a7b050", - "build/prefab/full/mac_arm64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/29/a3/32a6f6eaa811627ab7903243288a", + "build/prefab/full/mac_arm64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/73/88/fbbf37e501035577f8d7cb831693", "build/prefab/full/mac_arm64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/16/3e/5a02a80c844ea71c3ce1f229ff25", - "build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/ad/5a/ee514a1edeba59f6a2a57691781e", + "build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/70/55/4193d7db70ccd79538e1e3746ca4", "build/prefab/full/mac_arm64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/c3/d0/4fc44285b21e6b3dc4d9b3c30a28", - "build/prefab/full/mac_x86_64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/94/f4/e92a82cd5b74df65386dd00b58d8", + "build/prefab/full/mac_x86_64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/e8/02/9e3569c9b3fdbb1c7b645fd44c66", "build/prefab/full/mac_x86_64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/a5/5f/1c69d9dab37d811da0cdde48d09f", - "build/prefab/full/mac_x86_64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/2e/4f/86fa037ee8d9899ce9c7b490d06b", + "build/prefab/full/mac_x86_64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/d9/3c/55bed47fb11287ae44d69cb4d94f", "build/prefab/full/mac_x86_64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/b8/3b/b2f787a50ed7a2271b0c65f0ab3e", - "build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "https://files.ballistica.net/cache/ba1/b6/f6/945d3031ffd5112fa925366fc2e6", - "build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "https://files.ballistica.net/cache/ba1/ab/05/b93b5e9d547cacd4b47fb79d6022", - "build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "https://files.ballistica.net/cache/ba1/d8/3e/14b4ba0ee4d62520b5e809b9fea6", - "build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "https://files.ballistica.net/cache/ba1/c6/fb/a894f1c2445628fcfe3d95bbb908", + "build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "https://files.ballistica.net/cache/ba1/d4/e0/328fba6fd87ac4edc90cedf8cbb3", + "build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "https://files.ballistica.net/cache/ba1/cc/de/67965af8c1236c0d65ad5d9af9a9", + "build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "https://files.ballistica.net/cache/ba1/15/55/a6760b4a180e46f947d4c71e316e", + "build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "https://files.ballistica.net/cache/ba1/40/34/e85cd258290f34b79e9b97226f49", "build/prefab/lib/linux_arm64_gui/debug/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/8a/39/82acd22444cdde966df4838b3235", "build/prefab/lib/linux_arm64_gui/release/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/82/23/3da9e812f6d9d83e9c4678645792", "build/prefab/lib/linux_arm64_server/debug/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/8a/39/82acd22444cdde966df4838b3235", @@ -4108,14 +4108,14 @@ "build/prefab/lib/mac_x86_64_gui/release/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/2b/1d/067ca5d1bc54339f2b8682ef1aed", "build/prefab/lib/mac_x86_64_server/debug/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/65/49/cdbaca8ea343d79992618514438c", "build/prefab/lib/mac_x86_64_server/release/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/2b/1d/067ca5d1bc54339f2b8682ef1aed", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.lib": "https://files.ballistica.net/cache/ba1/dc/2e/2c3cd9cb11f8def5bb82b776708c", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.pdb": "https://files.ballistica.net/cache/ba1/41/8f/17d9b796e1b2dcd3d10372a5a239", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.lib": "https://files.ballistica.net/cache/ba1/7b/d1/a173f7d45eee76bfa0f0324d6b11", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.pdb": "https://files.ballistica.net/cache/ba1/69/e2/f9b659c214b720b823cfa30137e8", - "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.lib": "https://files.ballistica.net/cache/ba1/7b/87/90863866f7402fbfbf386e2d1898", - "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.pdb": "https://files.ballistica.net/cache/ba1/4a/b0/7bf4e032cd3b6510c6eb2eb25044", - "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.lib": "https://files.ballistica.net/cache/ba1/8c/48/5a8e5335043aca743e7a03901522", - "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.pdb": "https://files.ballistica.net/cache/ba1/d6/51/26c2f8c6aba2736ee9947ce00e48", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.lib": "https://files.ballistica.net/cache/ba1/4d/83/a8afed3f00bd33be23a2f7b3eb78", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.pdb": "https://files.ballistica.net/cache/ba1/be/20/95c9eea8f49bd2648877ea7b677c", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.lib": "https://files.ballistica.net/cache/ba1/bf/ac/70be2b0f035907cd1e4c352e6d95", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.pdb": "https://files.ballistica.net/cache/ba1/1f/2a/2f93f0206d29d5a856f61049e572", + "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.lib": "https://files.ballistica.net/cache/ba1/99/44/410a363149624bc3c48de32f5ea9", + "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.pdb": "https://files.ballistica.net/cache/ba1/72/08/6aae7324f5b33f14acff6c8f9569", + "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.lib": "https://files.ballistica.net/cache/ba1/2c/3e/5c464e7594d73f73c5314e833764", + "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.pdb": "https://files.ballistica.net/cache/ba1/c1/ac/320ecc613ca3c37c0ea4517d2df7", "src/assets/ba_data/python/babase/_mgen/__init__.py": "https://files.ballistica.net/cache/ba1/f8/85/fed7f2ed98ff2ba271f9dbe3391c", "src/assets/ba_data/python/babase/_mgen/enums.py": "https://files.ballistica.net/cache/ba1/48/4b/e6974f0a4d14be8213dc00d971c3", "src/ballistica/base/mgen/pyembed/binding_base.inc": "https://files.ballistica.net/cache/ba1/3e/7a/203e2a5d2b5bb42cfe3fd2fe16c2", diff --git a/tools/batools/spinoff/_context.py b/tools/batools/spinoff/_context.py index 60673db7..4772ca9c 100644 --- a/tools/batools/spinoff/_context.py +++ b/tools/batools/spinoff/_context.py @@ -15,9 +15,11 @@ from pathlib import Path from typing import TYPE_CHECKING, assert_never from efrotools.code import format_python_str, format_cpp_str +from efrotools import getconfig, replace_exact from efro.error import CleanError from efro.terminal import Clr from efro.util import timedelta_str + from batools.featureset import FeatureSet from batools.spinoff._state import ( EntityType, @@ -95,7 +97,7 @@ class SpinoffContext: if not os.path.isdir(dst_root): raise CleanError(f"Spinoff dst dir not found: '{dst_root}'.") - # FeatureSet names we should include + # The requested set of FeatureSet names (or None to include all). self.src_feature_sets: set[str] | None = None # Just to be safe, make sure we're working with abs paths. @@ -111,6 +113,9 @@ class SpinoffContext: self._src_name = 'BallisticaKit' + self._public: bool = getconfig(Path(self._src_root))['public'] + assert isinstance(self._public, bool) + self._src_all_feature_sets = { f.name: f for f in FeatureSet.get_all_for_project(self._src_root) } @@ -285,6 +290,7 @@ class SpinoffContext: self._generate_env_hash() def _calc_src_omit_feature_sets(self) -> set[str]: + # If they want everything, omit nothing. if self.src_feature_sets is None: return set() @@ -772,6 +778,39 @@ class SpinoffContext: return sort_jetbrains_dict(self.default_filter_text(text)) + # In our public repo, if the plus featureset is not included, we don't + # want to link against the precompiled plus library. + # (pylint false positive) + assert 'plus' in self._src_all_feature_sets + if ( + self._public + and 'plus' in self._src_omit_feature_sets + and src_path == 'ballisticakit-cmake/CMakeLists.txt' + ): + # Strip precompiled plus library out of the cmake file. + replace_exact( + text, + '${CMAKE_CURRENT_BINARY_DIR}/prefablib/libballistica_plus.a' + ' ode ', + 'ode ', + ) + if ( + self._public + and 'plus' in self._src_omit_feature_sets + and src_path.startswith('ballisticakit-windows/') + and src_path.endswith('.vcxproj') + ): + # Strip precompiled plus library out of visual studio projects. + replace_exact( + text, + ' \n' + ' \n' + ' \n', + '', + ) + return self.default_filter_text(text) def _encoding_for_file(self, path: str) -> str: