From 79bc519a3749c0687af0bc2ca148a3ff6bf845cb Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Tue, 24 Sep 2024 09:38:01 -0400 Subject: [PATCH] Check for a matching bext version branch before cloning RELEASE Avoid older releases pulling dependencies that might be too new or changed by first looking for a bext branch that matches the current BRL-CAD release. --- misc/CMake/BRLCAD_EXT_Setup.cmake | 43 ++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/misc/CMake/BRLCAD_EXT_Setup.cmake b/misc/CMake/BRLCAD_EXT_Setup.cmake index 425aa1f2e3..d8613eb402 100644 --- a/misc/CMake/BRLCAD_EXT_Setup.cmake +++ b/misc/CMake/BRLCAD_EXT_Setup.cmake @@ -46,6 +46,16 @@ function(brlcad_ext_setup) set(BEXT_SRC_CLEANUP FALSE) if (NOT DEFINED BRLCAD_EXT_SOURCE_DIR) + # In most cases we'll need to know the current version + file(READ ${CMAKE_SOURCE_DIR}/include/conf/MAJOR VMAJOR) + file(READ ${CMAKE_SOURCE_DIR}/include/conf/MINOR VMINOR) + file(READ ${CMAKE_SOURCE_DIR}/include/conf/PATCH VPATCH) + string(STRIP "${VMAJOR}" VMAJOR) + string(STRIP "${VMINOR}" VMINOR) + string(STRIP "${VPATCH}" VPATCH) + set(BRLCAD_REL "rel-${VMAJOR}-${VMINOR}-${VPATCH}") + + # If we have a bext copy in src/bext, use that. if (EXISTS "${CMAKE_SOURCE_DIR}/src/bext/README.md") @@ -96,15 +106,8 @@ function(brlcad_ext_setup) # Development branches should be keeping up with bext RELEASE, but a # tagged release should point to its equivalent rel-X-Y-Z in bext. # In case this is a release, also check for that SHA1 - file(READ ${CMAKE_SOURCE_DIR}/include/conf/MAJOR VMAJOR) - file(READ ${CMAKE_SOURCE_DIR}/include/conf/MINOR VMINOR) - file(READ ${CMAKE_SOURCE_DIR}/include/conf/PATCH VPATCH) - string(STRIP "${VMAJOR}" VMAJOR) - string(STRIP "${VMINOR}" VMINOR) - string(STRIP "${VPATCH}" VPATCH) - set(REL "rel-${VMAJOR}-${VMINOR}-${VPATCH}") execute_process( - COMMAND ${GIT_EXEC} ls-remote https://github.com/BRL-CAD/bext.git ${REL} + COMMAND ${GIT_EXEC} ls-remote https://github.com/BRL-CAD/bext.git ${BRLCAD_REL} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} RESULT_VARIABLE LS_REL_STATUS OUTPUT_VARIABLE LS_REL_STR @@ -128,17 +131,27 @@ function(brlcad_ext_setup) # If not, next up is a bext dir in the build directory. If # one doesn't already exist, try to clone it - - # TODO - need to use the ls-remote trick from above to first check for a branch - # in bext that corresponds to the current release - if we have one, we should - # be using that. As it stands, old releases will pull the very latest release's - # dependencies with this clone, which may not work. We want this only if there - # isn't a matching versioned release branch. set(BRLCAD_EXT_SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/bext) if (NOT EXISTS ${BRLCAD_EXT_SOURCE_DIR}) + # Development branches should be keeping up with bext RELEASE, but a + # tagged release should clone its equivalent rel-X-Y-Z in bext. + # Check for a matching branch in bext + execute_process( + COMMAND ${GIT_EXEC} ls-remote https://github.com/BRL-CAD/bext.git ${BRLCAD_REL} + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + RESULT_VARIABLE LS_REL_STATUS + OUTPUT_VARIABLE LS_REL_STR + ERROR_VARIABLE LS_REL_STR + ) + if (NOT LS_REL_STATUS AND LS_REL_STR) + set(CBRANCH "${BRLCAD_REL}") + else (NOT LS_REL_STATUS AND LS_REL_STR) + set(CBRANCH "RELEASE") + endif (NOT LS_REL_STATUS AND LS_REL_STR) + find_program(GIT_EXEC git REQUIRED) execute_process( - COMMAND ${GIT_EXEC} clone -b RELEASE https://github.com/BRL-CAD/bext.git + COMMAND ${GIT_EXEC} clone -b ${CBRANCH} https://github.com/BRL-CAD/bext.git WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) set(BEXT_SRC_CLEANUP TRUE)