diff options
| author | atkawa7 <atkawa7@yahoo.com> | 2017-06-06 10:37:21 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-06-06 10:37:21 -0700 |
| commit | 3ee46a4bb6fa2efca575ec8dee79c239c802f62a (patch) | |
| tree | 6f1f57f25f8a3d32471d34ee0cd20f8e92643b9f | |
| parent | e3c90826317d4ba6a01afc3d6cfbfcc898f546e4 (diff) | |
| download | vcpkg-3ee46a4bb6fa2efca575ec8dee79c239c802f62a.tar.gz vcpkg-3ee46a4bb6fa2efca575ec8dee79c239c802f62a.zip | |
stop cmake build on a failed download
| -rw-r--r-- | scripts/cmake/vcpkg_acquire_depot_tools.cmake | 48 |
1 files changed, 38 insertions, 10 deletions
diff --git a/scripts/cmake/vcpkg_acquire_depot_tools.cmake b/scripts/cmake/vcpkg_acquire_depot_tools.cmake index 3b206e271..1cc375725 100644 --- a/scripts/cmake/vcpkg_acquire_depot_tools.cmake +++ b/scripts/cmake/vcpkg_acquire_depot_tools.cmake @@ -3,18 +3,46 @@ function(vcpkg_acquire_depot_tools PATH_TO_ROOT_OUT) set(URL "https://storage.googleapis.com/chrome-infra/depot_tools.zip") set(ARCHIVE "depot_tools.zip") set(STAMP "initialized-depot-tools.stamp") + set(downloaded_file_path ${DOWNLOADS}/${ARCHIVE}) if(NOT EXISTS "${TOOLPATH}/${STAMP}") - message(STATUS "Acquiring Depot Tools...") - file(DOWNLOAD ${URL} ${DOWNLOADS}/${ARCHIVE}) - file(REMOVE_RECURSE ${TOOLPATH}) - file(MAKE_DIRECTORY ${TOOLPATH}) - execute_process( - COMMAND ${CMAKE_COMMAND} -E tar xzf ${DOWNLOADS}/${ARCHIVE} - WORKING_DIRECTORY ${TOOLPATH} - ) - file(WRITE "${TOOLPATH}/${STAMP}" "0") - message(STATUS "Acquiring Depot Tools... OK") + + message(STATUS "Acquiring Depot Tools...") + + if(EXISTS ${downloaded_file_path}) + message(STATUS "Using cached ${downloaded_file_path}") + else() + if(_VCPKG_NO_DOWNLOADS) + message(FATAL_ERROR "Downloads are disabled, but '${downloaded_file_path}' does not exist.") + endif() + file(DOWNLOAD ${URL} ${downloaded_file_path} STATUS download_status) + list(GET download_status 0 status_code) + if (NOT "${status_code}" STREQUAL "0") + message(STATUS "Downloading ${URL}... Failed. Status: ${download_status}") + file(REMOVE ${downloaded_file_path}) + set(download_success 0) + else() + message(STATUS "Downloading ${URL}... OK") + set(download_success 1) + endif() + + if (NOT ${download_success}) + message(FATAL_ERROR + "\n" + " Failed to download file.\n" + " Add mirrors or submit an issue at https://github.com/Microsoft/vcpkg/issues\n") + endif() + endif() + + + file(REMOVE_RECURSE ${TOOLPATH}) + file(MAKE_DIRECTORY ${TOOLPATH}) + execute_process( + COMMAND ${CMAKE_COMMAND} -E tar xzf ${DOWNLOADS}/${ARCHIVE} + WORKING_DIRECTORY ${TOOLPATH} + ) + file(WRITE "${TOOLPATH}/${STAMP}" "0") + message(STATUS "Acquiring Depot Tools... OK") endif() set(${PATH_TO_ROOT_OUT} ${TOOLPATH} PARENT_SCOPE) endfunction() |
