Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[vcpkg_from_git] new options TAG and X_OUT_REF #15049

Merged
merged 5 commits into from
Jan 11, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/maintainers/vcpkg_from_git.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,18 @@ The url of the git repository.
### REF
The git sha of the commit to download.

### TAG
The git tag to download.

### PATCHES
A list of patches to be applied to the extracted sources.

Relative paths are based on the port directory.

### OUT_REF
Maintainers only. Used for automatic REF updates for ports using a versioned TAG.
Will return early!

## Notes:
`OUT_SOURCE_PATH`, `REF`, and `URL` must be specified.

Expand Down
24 changes: 20 additions & 4 deletions scripts/cmake/vcpkg_from_git.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,18 @@ The url of the git repository.
### REF
The git sha of the commit to download.

### TAG
The git tag to download.

Neumann-A marked this conversation as resolved.
Show resolved Hide resolved
### PATCHES
A list of patches to be applied to the extracted sources.

Relative paths are based on the port directory.

### OUT_REF
Maintainers only. Used for automatic REF updates for ports using a versioned TAG.
Will return early!
Neumann-A marked this conversation as resolved.
Show resolved Hide resolved

## Notes:
`OUT_SOURCE_PATH`, `REF`, and `URL` must be specified.

Expand All @@ -41,7 +48,7 @@ Relative paths are based on the port directory.
include(vcpkg_execute_in_download_mode)

function(vcpkg_from_git)
set(oneValueArgs OUT_SOURCE_PATH URL REF)
set(oneValueArgs OUT_SOURCE_PATH URL REF TAG OUT_REF)
Neumann-A marked this conversation as resolved.
Show resolved Hide resolved
set(multipleValuesArgs PATCHES)
# parse parameters such that semicolons in options arguments to COMMAND don't get erased
cmake_parse_arguments(PARSE_ARGV 0 _vdud "" "${oneValueArgs}" "${multipleValuesArgs}")
Expand All @@ -58,8 +65,12 @@ function(vcpkg_from_git)
message(FATAL_ERROR "The git ref must be specified.")
endif()

if(NOT DEFINED _vdud_TAG)
set(_vdud_TAG ${_vdud_REF})
endif()

# using .tar.gz instead of .zip because the hash of the latter is affected by timezone.
string(REPLACE "/" "-" SANITIZED_REF "${_vdud_REF}")
string(REPLACE "/" "-" SANITIZED_REF "${_vdud_TAG}")
set(TEMP_ARCHIVE "${DOWNLOADS}/temp/${PORT}-${SANITIZED_REF}.tar.gz")
set(ARCHIVE "${DOWNLOADS}/${PORT}-${SANITIZED_REF}.tar.gz")
set(TEMP_SOURCE_PATH "${CURRENT_BUILDTREES_DIR}/src/${SANITIZED_REF}")
Expand All @@ -79,7 +90,7 @@ function(vcpkg_from_git)
)
vcpkg_execute_required_process(
ALLOW_IN_DOWNLOAD_MODE
COMMAND ${GIT} fetch ${_vdud_URL} ${_vdud_REF} --depth 1 -n
COMMAND ${GIT} fetch ${_vdud_URL} ${_vdud_TAG} --depth 1 -n
WORKING_DIRECTORY ${DOWNLOADS}/git-tmp
LOGNAME git-fetch-${TARGET_TRIPLET}
)
Expand All @@ -94,8 +105,13 @@ function(vcpkg_from_git)
message(FATAL_ERROR "unable to determine FETCH_HEAD after fetching git repository")
endif()
string(REGEX REPLACE "\n$" "" REV_PARSE_HEAD "${REV_PARSE_HEAD}")
if(NOT REV_PARSE_HEAD STREQUAL _vdud_REF)
if(NOT REV_PARSE_HEAD STREQUAL _vdud_REF AND NOT DEFINED _vdud_OUT_REF)
message(STATUS "[Expected : ( ${_vdud_REF} )]")
message(STATUS "[ Actual : ( ${REV_PARSE_HEAD} )]")
message(FATAL_ERROR "REF (${_vdud_REF}) does not match FETCH_HEAD (${REV_PARSE_HEAD})")
elseif(DEFINED _vdud_OUT_REF)
set(${_vdud_OUT_REF} ${REV_PARSE_HEAD} PARENT_SCOPE)
return()
endif()

file(MAKE_DIRECTORY "${DOWNLOADS}/temp")
Expand Down