diff options
| author | Robert Schumacher <roschuma@microsoft.com> | 2018-01-05 16:48:59 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-01-05 16:48:59 -0800 |
| commit | 2dab9a2576a4f2c03d65abc9ad2668d2f34c6ba5 (patch) | |
| tree | 0c28bc3b280796ebc7cb7609794f6f9171788ab4 /scripts | |
| parent | cf802347a47279e43bb37592437f3632bcdc5374 (diff) | |
| parent | 2b30280c222a6970fa74d05b6f7e106b4776318a (diff) | |
| download | vcpkg-2dab9a2576a4f2c03d65abc9ad2668d2f34c6ba5.tar.gz vcpkg-2dab9a2576a4f2c03d65abc9ad2668d2f34c6ba5.zip | |
Merge pull request #2469 from Mixaill/fix_github_head
[vcpkg] fix --head flag for github-based ports
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/cmake/vcpkg_download_distfile.cmake | 33 | ||||
| -rw-r--r-- | scripts/cmake/vcpkg_from_github.cmake | 9 |
2 files changed, 32 insertions, 10 deletions
diff --git a/scripts/cmake/vcpkg_download_distfile.cmake b/scripts/cmake/vcpkg_download_distfile.cmake index 2055139f5..7a1c95461 100644 --- a/scripts/cmake/vcpkg_download_distfile.cmake +++ b/scripts/cmake/vcpkg_download_distfile.cmake @@ -2,6 +2,8 @@ ## ## Download and cache a file needed for this port. ## +## This helper should always be used instead of CMake's built-in `file(DOWNLOAD)` command. +## ## ## Usage ## ```cmake ## vcpkg_download_distfile( @@ -26,18 +28,24 @@ ## ## If this doesn't match the downloaded version, the build will be terminated with a message describing the mismatch. ## +## ### SKIP_SHA512 +## Skip SHA512 hash check for file. +## +## This switch is only valid when building with the `--head` command line flag. +## ## ## Notes -## The command [`vcpkg_from_github`](vcpkg_from_github.md) should be used instead of this for downloading the main archive for GitHub projects. +## The helper [`vcpkg_from_github`](vcpkg_from_github.md) should be used for downloading from GitHub projects. ## ## ## Examples ## -## * [boost](https://github.com/Microsoft/vcpkg/blob/master/ports/boost/portfile.cmake) +## * [apr](https://github.com/Microsoft/vcpkg/blob/master/ports/apr/portfile.cmake) ## * [fontconfig](https://github.com/Microsoft/vcpkg/blob/master/ports/fontconfig/portfile.cmake) ## * [openssl](https://github.com/Microsoft/vcpkg/blob/master/ports/openssl/portfile.cmake) function(vcpkg_download_distfile VAR) + set(options SKIP_SHA512) set(oneValueArgs FILENAME SHA512) set(multipleValuesArgs URLS) - cmake_parse_arguments(vcpkg_download_distfile "" "${oneValueArgs}" "${multipleValuesArgs}" ${ARGN}) + cmake_parse_arguments(vcpkg_download_distfile "${options}" "${oneValueArgs}" "${multipleValuesArgs}" ${ARGN}) if(NOT DEFINED vcpkg_download_distfile_URLS) message(FATAL_ERROR "vcpkg_download_distfile requires a URLS argument.") @@ -45,8 +53,14 @@ function(vcpkg_download_distfile VAR) if(NOT DEFINED vcpkg_download_distfile_FILENAME) message(FATAL_ERROR "vcpkg_download_distfile requires a FILENAME argument.") endif() - if(NOT _VCPKG_INTERNAL_NO_HASH_CHECK AND NOT DEFINED vcpkg_download_distfile_SHA512) - message(FATAL_ERROR "vcpkg_download_distfile requires a SHA512 argument.") + if(vcpkg_download_distfile_SKIP_SHA512 AND NOT VCPKG_USE_HEAD_VERSION) + message(FATAL_ERROR "vcpkg_download_distfile only allows SKIP_SHA512 when building with --head") + endif() + if(NOT vcpkg_download_distfile_SKIP_SHA512 AND NOT DEFINED vcpkg_download_distfile_SHA512) + message(FATAL_ERROR "vcpkg_download_distfile requires a SHA512 argument. If you do not know the SHA512, add it as 'SHA512 0' and re-run this command.") + endif() + if(vcpkg_download_distfile_SKIP_SHA512 AND DEFINED vcpkg_download_distfile_SHA512) + message(FATAL_ERROR "vcpkg_download_distfile must not be passed both SHA512 and SKIP_SHA512.") endif() set(downloaded_file_path ${DOWNLOADS}/${vcpkg_download_distfile_FILENAME}) @@ -56,7 +70,12 @@ function(vcpkg_download_distfile VAR) file(MAKE_DIRECTORY "${DOWNLOADS}/temp") function(test_hash FILE_KIND CUSTOM_ERROR_ADVICE) - if (_VCPKG_INTERNAL_NO_HASH_CHECK) + if(_VCPKG_INTERNAL_NO_HASH_CHECK) + # When using the internal hash skip, do not output an explicit message. + return() + endif() + if(vcpkg_download_distfile_SKIP_SHA512) + message(STATUS "Skipping hash check for ${downloaded_file_path}.") return() endif() @@ -103,7 +122,7 @@ function(vcpkg_download_distfile VAR) " Failed to download file.\n" " Add mirrors or submit an issue at https://github.com/Microsoft/vcpkg/issues\n") else() - test_hash("downloaded file" "The file may be corrupted.") + test_hash("downloaded file" "The file may have been corrupted in transit.") endif() endif() set(${VAR} ${downloaded_file_path} PARENT_SCOPE) diff --git a/scripts/cmake/vcpkg_from_github.cmake b/scripts/cmake/vcpkg_from_github.cmake index b71ab3838..c6a23cff6 100644 --- a/scripts/cmake/vcpkg_from_github.cmake +++ b/scripts/cmake/vcpkg_from_github.cmake @@ -137,17 +137,17 @@ function(vcpkg_from_github) endif() # Try to download the file and version information from github. - set(_VCPKG_INTERNAL_NO_HASH_CHECK "TRUE") vcpkg_download_distfile(ARCHIVE_VERSION URLS "https://api.github.com/repos/${ORG_NAME}/${REPO_NAME}/git/refs/heads/${_vdud_HEAD_REF}" FILENAME ${downloaded_file_name}.version + SKIP_SHA512 ) vcpkg_download_distfile(ARCHIVE URLS ${URL} FILENAME ${downloaded_file_name} + SKIP_SHA512 ) - set(_VCPKG_INTERNAL_NO_HASH_CHECK "FALSE") endif() vcpkg_extract_source_archive_ex( @@ -162,7 +162,10 @@ function(vcpkg_from_github) string(REGEX REPLACE "\"sha\": \"([a-f0-9]+)\"" "\\1" _version ${x}) # exports VCPKG_HEAD_VERSION to the caller. This will get picked up by ports.cmake after the build. - set(VCPKG_HEAD_VERSION ${_version} PARENT_SCOPE) + # When multiple vcpkg_from_github's are used after each other, only use the version from the first (hopefully the primary one). + if(NOT DEFINED VCPKG_HEAD_VERSION) + set(VCPKG_HEAD_VERSION ${_version} PARENT_SCOPE) + endif() set_SOURCE_PATH(${CURRENT_BUILDTREES_DIR}/src/head ${SANITIZED_HEAD_REF}) endfunction() |
