Skip to content

Commit c02644b

Browse files
committed
[#1474] Record build toolchain and ABI metadata
Add a generated build-info path that records the compiler, target, runtime, Python ABI, SWIG runtime, Eigen settings, and selected C/C++ layout canaries for an installed Basilisk package. The metadata is exposed through Basilisk.getBuildInfo() and Basilisk.printBuildInfo() so users and future BSK-SDK compatibility checks can inspect the binary that was actually built. Add architecture/utilities/bskAbiDescriptor.h as the public ABI descriptor contract shared by Basilisk and SDK-side probes. The header owns the descriptor version, plugin ABI version, canary types, and C/C++ extraction helpers so the two sides do not need to maintain parallel ABI-detection logic. Generate the runtime ABI payload with a small compiled C/C++ probe. The probe uses the same public descriptor header and shared bskPluginAbiSettings interface as native Basilisk targets, so it observes the same C++ standard, Python limited API definition, Eigen include/link settings, and compiler behavior. Wire metadata generation into the CMake build and refresh it for loadable module targets. Keep the generation dependency off internal static/shared libraries to avoid multi-config generated-source dependency issues, while still applying the shared ABI settings interface to native targets. Pass relevant Conan and Python build settings into CMake, including the selected Basilisk version, Conan version, C++ standard/library/runtime settings, build type, and invoking Python executable. Add tests covering the public descriptor contract, compiled ABI payload shape, C layout canaries, platform-specific C++ ABI fields, defensive copy behavior, and human-readable build-info formatting.
1 parent b845f0d commit c02644b

9 files changed

Lines changed: 1754 additions & 0 deletions

File tree

conanfile.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,16 @@ def generate(self):
380380
tc.cache_variables["BUILD_OPNAV"] = bool(self.options.get_safe("opNav"))
381381
tc.cache_variables["BUILD_VIZINTERFACE"] = bool(self.options.get_safe("vizInterface"))
382382
tc.cache_variables["BUILD_MUJOCO"] = bool(self.options.get_safe("mujoco"))
383+
tc.cache_variables["BSK_CONAN_BUILD_TYPE"] = str(self.settings.build_type)
384+
tc.cache_variables["BSK_VERSION"] = str(self.version).strip()
385+
tc.cache_variables["BSK_CONAN_VERSION"] = importlib.metadata.version("conan")
386+
tc.cache_variables["BSK_CONAN_CXX_STANDARD"] = str(self.settings.get_safe("compiler.cppstd") or "")
387+
tc.cache_variables["BSK_CONAN_CXX_STANDARD_LIBRARY"] = str(self.settings.get_safe("compiler.libcxx") or "")
388+
tc.cache_variables["BSK_CONAN_COMPILER_RUNTIME"] = str(self.settings.get_safe("compiler.runtime") or "")
389+
tc.cache_variables["BSK_CONAN_COMPILER_RUNTIME_TYPE"] = str(
390+
self.settings.get_safe("compiler.runtime_type") or ""
391+
)
392+
tc.cache_variables["Python3_EXECUTABLE"] = Path(sys.executable).as_posix()
383393
if self.options.get_safe("pathToExternalModules"):
384394
tc.cache_variables["EXTERNAL_MODULES_PATH"] = Path(str(self.options.pathToExternalModules)).resolve().as_posix()
385395
tc.cache_variables["PYTHON_VERSION"] = f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}"

src/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ list(APPEND CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
2222
list(APPEND CMAKE_PREFIX_PATH "${CMAKE_BINARY_DIR}/conan")
2323

2424
include(bskTargetExcludeBuildOptions)
25+
include(bskBuildInfo)
2526

2627
# Find necessary packages
2728
find_package(Python3 ${PYTHON_VERSION} EXACT REQUIRED COMPONENTS Interpreter Development.Module OPTIONAL_COMPONENTS Development.SABIModule)
@@ -695,10 +696,13 @@ file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/Basilisk/moduleTemplates")
695696
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/Basilisk/topLevelModules")
696697
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/Basilisk/ExternalModules")
697698

699+
bsk_generate_build_info("${CMAKE_BINARY_DIR}/Basilisk")
700+
698701
if(WIN32)
699702
file(WRITE "${CMAKE_BINARY_DIR}/Basilisk/__init__.py"
700703
"#init file written by the build\n" "import sys, os\n" "from Basilisk import __path__\n"
701704
"bskPath = __path__[0]\n" "os.add_dll_directory(bskPath)\n"
705+
"from Basilisk._buildInfo import getBuildInfo, printBuildInfo\n"
702706
"from Basilisk.architecture import messaging\n"
703707
"try:\n"
704708
" from importlib.metadata import version as _pkg_version\n"
@@ -707,6 +711,7 @@ if(WIN32)
707711
" __version__ = '0.0.0'\n")
708712
else()
709713
file(WRITE "${CMAKE_BINARY_DIR}/Basilisk/__init__.py"
714+
"from Basilisk._buildInfo import getBuildInfo, printBuildInfo\n"
710715
"from Basilisk.architecture import messaging # ensure recorders() work without first importing messaging\n"
711716
"try:\n"
712717
" from importlib.metadata import version as _pkg_version\n"

0 commit comments

Comments
 (0)