From 2d2863ba21e11bfa859ce53b107cf7d3928af627 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Thu, 10 Dec 2020 21:02:21 +0100 Subject: [PATCH 1/4] [vcpkg_from_git] new options TAG and OUT_REF - TAG github tag to checkout - OUT_REF github commit id related to tag or ref (useable for automatic updates of ports if used with a version tag) --- docs/maintainers/vcpkg_from_git.md | 7 +++++++ scripts/cmake/vcpkg_from_git.cmake | 24 ++++++++++++++++++++---- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/docs/maintainers/vcpkg_from_git.md b/docs/maintainers/vcpkg_from_git.md index 2feed49aa361d2..161d469498799a 100644 --- a/docs/maintainers/vcpkg_from_git.md +++ b/docs/maintainers/vcpkg_from_git.md @@ -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. diff --git a/scripts/cmake/vcpkg_from_git.cmake b/scripts/cmake/vcpkg_from_git.cmake index 54f93996a9650d..b0fb9db1c1744b 100644 --- a/scripts/cmake/vcpkg_from_git.cmake +++ b/scripts/cmake/vcpkg_from_git.cmake @@ -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. + ### 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. @@ -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) 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}") @@ -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}") @@ -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} ) @@ -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") From 9dfcf66296844ec568b0d8977bdc9e28f4861693 Mon Sep 17 00:00:00 2001 From: Alexander Neumann <30894796+Neumann-A@users.noreply.github.com> Date: Thu, 7 Jan 2021 12:18:36 +0100 Subject: [PATCH 2/4] Apply suggestions from code review Co-authored-by: Robert Schumacher --- scripts/cmake/vcpkg_from_git.cmake | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/scripts/cmake/vcpkg_from_git.cmake b/scripts/cmake/vcpkg_from_git.cmake index b0fb9db1c1744b..ee77e1dffde5a3 100644 --- a/scripts/cmake/vcpkg_from_git.cmake +++ b/scripts/cmake/vcpkg_from_git.cmake @@ -26,16 +26,15 @@ The url of the git repository. The git sha of the commit to download. ### TAG -The git tag to download. +An optional git tag to be verified against the `REF`. If the remote repository's tag does not match the specified `REF`, the build will fail. ### 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! +### X_OUT_REF (internal only) +This parameter is used for automatic REF updates for certain ports in the central vcpkg catalog. It should not be used by any ports outside the central catalog and within the central catalog it should not be used on any user path. This parameter may change behavior incompatibly or be removed at any time. ## Notes: `OUT_SOURCE_PATH`, `REF`, and `URL` must be specified. @@ -48,7 +47,7 @@ Will return early! include(vcpkg_execute_in_download_mode) function(vcpkg_from_git) - set(oneValueArgs OUT_SOURCE_PATH URL REF TAG OUT_REF) + set(oneValueArgs OUT_SOURCE_PATH URL REF TAG X_OUT_REF) 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}") From d4b592510269eb5d03dd9f15b6e3089d2a7c6716 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Thu, 7 Jan 2021 12:21:18 +0100 Subject: [PATCH 3/4] additional changes due to CR --- scripts/cmake/vcpkg_from_git.cmake | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/cmake/vcpkg_from_git.cmake b/scripts/cmake/vcpkg_from_git.cmake index ee77e1dffde5a3..d2055f82e07311 100644 --- a/scripts/cmake/vcpkg_from_git.cmake +++ b/scripts/cmake/vcpkg_from_git.cmake @@ -9,6 +9,7 @@ vcpkg_from_git( OUT_SOURCE_PATH URL REF <59f7335e4d...> + [TAG ] [PATCHES ...] ) ``` @@ -104,12 +105,12 @@ 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 AND NOT DEFINED _vdud_OUT_REF) + if(NOT REV_PARSE_HEAD STREQUAL _vdud_REF AND NOT DEFINED _vdud_X_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) + elseif(DEFINED _vdud_X_OUT_REF) + set(${_vdud_X_OUT_REF} ${REV_PARSE_HEAD} PARENT_SCOPE) return() endif() From 640b29cec84eaaabf2783e00da1d6224e3173f88 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Thu, 7 Jan 2021 12:23:05 +0100 Subject: [PATCH 4/4] regenerate docs --- docs/maintainers/vcpkg_from_git.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/maintainers/vcpkg_from_git.md b/docs/maintainers/vcpkg_from_git.md index 161d469498799a..cb3b9c67f98c89 100644 --- a/docs/maintainers/vcpkg_from_git.md +++ b/docs/maintainers/vcpkg_from_git.md @@ -8,6 +8,7 @@ vcpkg_from_git( OUT_SOURCE_PATH URL REF <59f7335e4d...> + [TAG ] [PATCHES ...] ) ``` @@ -25,16 +26,15 @@ The url of the git repository. The git sha of the commit to download. ### TAG -The git tag to download. +An optional git tag to be verified against the `REF`. If the remote repository's tag does not match the specified `REF`, the build will fail. ### 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! +### X_OUT_REF (internal only) +This parameter is used for automatic REF updates for certain ports in the central vcpkg catalog. It should not be used by any ports outside the central catalog and within the central catalog it should not be used on any user path. This parameter may change behavior incompatibly or be removed at any time. ## Notes: `OUT_SOURCE_PATH`, `REF`, and `URL` must be specified.