Skip to content

Commit

Permalink
feat: modify commands to download external package
Browse files Browse the repository at this point in the history
Signed-off-by: Alfi Maulana <alfi.maulana.f@gmail.com>
  • Loading branch information
threeal committed Oct 11, 2024
1 parent fa87cf4 commit 8595d5e
Showing 1 changed file with 27 additions and 14 deletions.
41 changes: 27 additions & 14 deletions cmake/CDeps.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -74,23 +74,36 @@ function(cdeps_download_package NAME URL REF)
endif()
endif()

set(CLONE_COMMAND "${GIT_EXECUTABLE}" clone -b "${REF}" --depth 1)
set(CLONE_COMMAND "${GIT_EXECUTABLE}" clone --no-checkout --depth 1
https://${URL}.git ${CDEPS_DIR}/${NAME}/src)

set(FETCH_COMMAND "${GIT_EXECUTABLE}" -C ${CDEPS_DIR}/${NAME}/src
fetch --depth 1 --tags origin "${REF}")

set(CHECKOUT_COMMAND "${GIT_EXECUTABLE}" -C ${CDEPS_DIR}/${NAME}/src
checkout "${REF}")

set(COMMANDS CLONE_COMMAND FETCH_COMMAND CHECKOUT_COMMAND)

if(ARG_RECURSE_SUBMODULES)
list(APPEND CLONE_COMMAND --recurse-submodules)
set(SUBMODULE_COMMAND "${GIT_EXECUTABLE}" -C ${CDEPS_DIR}/${NAME}/src
submodule update --init --recursive)
list(APPEND COMMANDS SUBMODULE_COMMAND)
endif()
list(APPEND CLONE_COMMAND https://${URL}.git ${CDEPS_DIR}/${NAME}/src)

execute_process(
COMMAND ${CLONE_COMMAND}
ERROR_VARIABLE ERR
RESULT_VARIABLE RES
OUTPUT_QUIET)
if(NOT "${RES}" EQUAL 0)
string(JOIN " " COMMAND ${CLONE_COMMAND})
message(FATAL_ERROR
"CDeps: Failed to execute process:\n ${COMMAND}\n${ERR}")
return()
endif()
foreach(COMMAND IN LISTS COMMANDS)
execute_process(
COMMAND ${${COMMAND}}
ERROR_VARIABLE ERR
RESULT_VARIABLE RES
OUTPUT_QUIET)
if(NOT "${RES}" EQUAL 0)
string(JOIN " " COMMAND ${${COMMAND}})
message(FATAL_ERROR
"CDeps: Failed to execute process:\n ${COMMAND}\n${ERR}")
return()
endif()
endforeach()

file(WRITE ${CDEPS_DIR}/${NAME}/src.lock "${SOURCE_LOCK}")
set(${NAME}_SOURCE_DIR ${CDEPS_DIR}/${NAME}/src PARENT_SCOPE)
Expand Down

0 comments on commit 8595d5e

Please sign in to comment.