Make syncing script capable of setting up new worktrees and clones
For missing dependencies, create worktrees from existing clones if found, otherwise clone from the same remote. Change-Id: Ie624e6c1b3f621dce43ee8cc7f06ce469851285b Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
parent
f8b8a9a59f
commit
c47432eda3
@ -144,6 +144,67 @@ function(qt_internal_checkout module revision)
|
|||||||
)
|
)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
|
# clones or creates a worktree for $dependency, using the source of $dependent
|
||||||
|
function(qt_internal_get_dependency dependent dependency)
|
||||||
|
set(gitdir "")
|
||||||
|
set(remote "")
|
||||||
|
|
||||||
|
# try to read the worktree source
|
||||||
|
execute_process(
|
||||||
|
COMMAND "git" "rev-parse" "--git-dir"
|
||||||
|
WORKING_DIRECTORY "./${dependent}"
|
||||||
|
RESULT_VARIABLE git_result
|
||||||
|
OUTPUT_VARIABLE git_stdout
|
||||||
|
ERROR_VARIABLE git_stderr
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
|
)
|
||||||
|
string(FIND "${git_stdout}" "${module}" index)
|
||||||
|
string(SUBSTRING "${git_stdout}" 0 ${index} gitdir)
|
||||||
|
message(DEBUG "Will look for clones in ${gitdir}")
|
||||||
|
|
||||||
|
execute_process(
|
||||||
|
COMMAND "git" "remote" "get-url" "origin"
|
||||||
|
WORKING_DIRECTORY "./${dependent}"
|
||||||
|
RESULT_VARIABLE git_result
|
||||||
|
OUTPUT_VARIABLE git_stdout
|
||||||
|
ERROR_VARIABLE git_stderr
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
|
)
|
||||||
|
string(FIND "${git_stdout}" "${dependent}.git" index)
|
||||||
|
string(SUBSTRING "${git_stdout}" 0 ${index} remote)
|
||||||
|
message(DEBUG "Will clone from ${remote}")
|
||||||
|
|
||||||
|
if(EXISTS "${gitdir}${dependency}")
|
||||||
|
# for the module we want, there seems to be a clone parallel to what we have
|
||||||
|
message(DEBUG "Adding worktree for ${dependency} from ${gitdir}${dependency}")
|
||||||
|
execute_process(
|
||||||
|
COMMAND "git" "worktree" "add" "${CMAKE_CURRENT_SOURCE_DIR}/${dependency}"
|
||||||
|
WORKING_DIRECTORY "${gitdir}/${dependency}"
|
||||||
|
RESULT_VARIABLE git_result
|
||||||
|
OUTPUT_VARIABLE git_stdout
|
||||||
|
ERROR_VARIABLE git_stderr
|
||||||
|
)
|
||||||
|
if (git_result)
|
||||||
|
message(WARNING "${git_stdout}")
|
||||||
|
message(FATAL_ERROR "Failed to create worktree for '${dependency}': ${git_stderr}")
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
# we don't find the existing clone, so clone from the saame remote
|
||||||
|
message(DEBUG "Cloning ${dependency} from ${remote}${dependency}.git")
|
||||||
|
execute_process(
|
||||||
|
COMMAND "git" "clone" "${remote}${dependency}.git"
|
||||||
|
WORKING_DIRECTORY "."
|
||||||
|
RESULT_VARIABLE git_result
|
||||||
|
OUTPUT_VARIABLE git_stdout
|
||||||
|
ERROR_VARIABLE git_stderr
|
||||||
|
)
|
||||||
|
if (git_result)
|
||||||
|
message(WARNING "${git_stdout}")
|
||||||
|
message(FATAL_ERROR "Failed to clone '${dependency}': ${git_stderr}")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
# evaluates the dependencies for $module, and checks all dependencies
|
# evaluates the dependencies for $module, and checks all dependencies
|
||||||
# out so that it is a consistent set
|
# out so that it is a consistent set
|
||||||
function(qt_internal_sync_to module)
|
function(qt_internal_sync_to module)
|
||||||
@ -192,6 +253,11 @@ function(qt_internal_sync_to module)
|
|||||||
continue()
|
continue()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(NOT EXISTS "./${dependency}")
|
||||||
|
message(DEBUG "No worktree for '${dependency}' found in '${CMAKE_CURRENT_SOURCE_DIR}'")
|
||||||
|
qt_internal_get_dependency("${module}" "${dependency}")
|
||||||
|
endif()
|
||||||
|
|
||||||
execute_process(
|
execute_process(
|
||||||
COMMAND "git" "rev-parse" "HEAD"
|
COMMAND "git" "rev-parse" "HEAD"
|
||||||
WORKING_DIRECTORY "./${dependency}"
|
WORKING_DIRECTORY "./${dependency}"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user