diff options
| author | Barath Kannan <barathsotd@gmail.com> | 2017-11-06 00:33:04 +1100 |
|---|---|---|
| committer | Barath Kannan <barathsotd@gmail.com> | 2017-11-06 00:33:04 +1100 |
| commit | b959f70a9969551a132d691fbd12046d5ea0702e (patch) | |
| tree | d15d129bd480b1ba173322a0e50140ccf1ff487a /scripts | |
| parent | 3a5b383bbec74dbaf0f1056e1a5d315e43d79375 (diff) | |
| parent | 330b8d8bab6a3d07165bf7c05fea09a8e0d56348 (diff) | |
| download | vcpkg-b959f70a9969551a132d691fbd12046d5ea0702e.tar.gz vcpkg-b959f70a9969551a132d691fbd12046d5ea0702e.zip | |
merge from master
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/bootstrap.ps1 | 10 | ||||
| -rw-r--r-- | scripts/buildsystems/msbuild/vcpkg.targets | 11 | ||||
| -rw-r--r-- | scripts/cmake/vcpkg_acquire_depot_tools.cmake | 48 | ||||
| -rw-r--r-- | scripts/cmake/vcpkg_acquire_msys.cmake | 10 | ||||
| -rw-r--r-- | scripts/cmake/vcpkg_common_functions.cmake | 2 | ||||
| -rw-r--r-- | scripts/cmake/vcpkg_download_distfile.cmake | 13 | ||||
| -rw-r--r-- | scripts/cmake/vcpkg_find_acquire_program.cmake | 22 | ||||
| -rw-r--r-- | scripts/cmake/vcpkg_fixup_cmake_targets.cmake | 20 | ||||
| -rw-r--r-- | scripts/cmake/vcpkg_from_bitbucket.cmake | 38 | ||||
| -rw-r--r-- | scripts/cmake/vcpkg_from_github.cmake | 34 | ||||
| -rw-r--r-- | scripts/cmake/vcpkg_get_windows_sdk.cmake | 4 | ||||
| -rw-r--r-- | scripts/fetchDependency.ps1 | 168 | ||||
| -rw-r--r-- | scripts/findAnyMSBuildWithCppPlatformToolset.ps1 | 3 | ||||
| -rw-r--r-- | scripts/findVisualStudioInstallationInstances.ps1 | 6 | ||||
| -rw-r--r-- | scripts/internalCI.ps1 | 5 | ||||
| -rw-r--r-- | scripts/ports.cmake | 10 |
16 files changed, 220 insertions, 184 deletions
diff --git a/scripts/bootstrap.ps1 b/scripts/bootstrap.ps1 index b874afd8c..b14dbbe4a 100644 --- a/scripts/bootstrap.ps1 +++ b/scripts/bootstrap.ps1 @@ -13,7 +13,7 @@ $gitHash = "unknownhash" $oldpath = $env:path try { - $env:path += ";$vcpkgRootDir\downloads\MinGit-2.14.1-32-bit\cmd" + $env:path += ";$vcpkgRootDir\downloads\MinGit-2.15.0-32-bit\cmd" if (Get-Command "git" -ErrorAction SilentlyContinue) { $gitHash = git log HEAD -n 1 --format="%cd-%H" --date=short @@ -32,7 +32,8 @@ $vcpkgSourcesPath = "$vcpkgRootDir\toolsrc" if (!(Test-Path $vcpkgSourcesPath)) { - New-Item -ItemType directory -Path $vcpkgSourcesPath -force | Out-Null + Write-Error "Unable to determine vcpkg sources directory. '$vcpkgSourcesPath' does not exist." + return } try @@ -43,6 +44,11 @@ try $platformToolset = $msbuildExeWithPlatformToolset[1] $windowsSDK = & $scriptsDir\getWindowsSDK.ps1 & $msbuildExe "/p:VCPKG_VERSION=-$gitHash" "/p:DISABLE_METRICS=$disableMetrics" /p:Configuration=Release /p:Platform=x86 /p:PlatformToolset=$platformToolset /p:TargetPlatformVersion=$windowsSDK /m dirs.proj + if ($LASTEXITCODE -ne 0) + { + Write-Error "Building vcpkg.exe failed. Please ensure you have installed the Desktop C++ workload and the Windows SDK for Desktop C++." + return + } Write-Verbose("Placing vcpkg.exe in the correct location") diff --git a/scripts/buildsystems/msbuild/vcpkg.targets b/scripts/buildsystems/msbuild/vcpkg.targets index 1cb338237..ad1dde89b 100644 --- a/scripts/buildsystems/msbuild/vcpkg.targets +++ b/scripts/buildsystems/msbuild/vcpkg.targets @@ -36,15 +36,17 @@ <PropertyGroup Condition="'$(VcpkgEnabled)' == 'true'"> <VcpkgConfiguration Condition="'$(VcpkgConfiguration)' == ''">$(Configuration)</VcpkgConfiguration> + <VcpkgNormalizedConfiguration Condition="$(VcpkgConfiguration.StartsWith('Debug'))">Debug</VcpkgNormalizedConfiguration> + <VcpkgNormalizedConfiguration Condition="$(VcpkgConfiguration.StartsWith('Release')) or '$(VcpkgConfiguration)' == 'RelWithDebInfo' or '$(VcpkgConfiguration)' == 'MinSizeRel'">Release</VcpkgNormalizedConfiguration> <VcpkgRoot Condition="'$(VcpkgRoot)' == ''">$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), .vcpkg-root))\installed\$(VcpkgTriplet)\</VcpkgRoot> </PropertyGroup> <ItemDefinitionGroup Condition="'$(VcpkgEnabled)' == 'true'"> <Link> - <AdditionalDependencies Condition="$(VcpkgConfiguration.StartsWith('Debug')) and '$(VcpkgAutoLink)' != 'false'">%(AdditionalDependencies);$(VcpkgRoot)debug\lib\*.lib</AdditionalDependencies> - <AdditionalDependencies Condition="$(VcpkgConfiguration.StartsWith('Release')) and '$(VcpkgAutoLink)' != 'false'">%(AdditionalDependencies);$(VcpkgRoot)lib\*.lib</AdditionalDependencies> - <AdditionalLibraryDirectories Condition="$(VcpkgConfiguration.StartsWith('Release'))">%(AdditionalLibraryDirectories);$(VcpkgRoot)lib;$(VcpkgRoot)lib\manual-link</AdditionalLibraryDirectories> - <AdditionalLibraryDirectories Condition="$(VcpkgConfiguration.StartsWith('Debug'))">%(AdditionalLibraryDirectories);$(VcpkgRoot)debug\lib;$(VcpkgRoot)debug\lib\manual-link</AdditionalLibraryDirectories> + <AdditionalDependencies Condition="'$(VcpkgNormalizedConfiguration)' == 'Debug' and '$(VcpkgAutoLink)' != 'false'">%(AdditionalDependencies);$(VcpkgRoot)debug\lib\*.lib</AdditionalDependencies> + <AdditionalDependencies Condition="'$(VcpkgNormalizedConfiguration)' == 'Release' and '$(VcpkgAutoLink)' != 'false'">%(AdditionalDependencies);$(VcpkgRoot)lib\*.lib</AdditionalDependencies> + <AdditionalLibraryDirectories Condition="'$(VcpkgNormalizedConfiguration)' == 'Release'">%(AdditionalLibraryDirectories);$(VcpkgRoot)lib;$(VcpkgRoot)lib\manual-link</AdditionalLibraryDirectories> + <AdditionalLibraryDirectories Condition="'$(VcpkgNormalizedConfiguration)' == 'Debug'">%(AdditionalLibraryDirectories);$(VcpkgRoot)debug\lib;$(VcpkgRoot)debug\lib\manual-link</AdditionalLibraryDirectories> </Link> <ClCompile> <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(VcpkgRoot)include</AdditionalIncludeDirectories> @@ -57,6 +59,7 @@ <Target Name="VcpkgTripletSelection" BeforeTargets="ClCompile"> <Message Text="Using triplet "$(VcpkgTriplet)" from "$(VcpkgRoot)"" Importance="Normal" Condition="'$(VcpkgEnabled)' == 'true'"/> <Message Text="Not using Vcpkg because VcpkgEnabled is "$(VcpkgEnabled)"" Importance="Normal" Condition="'$(VcpkgEnabled)' != 'true'"/> + <Message Text="Vcpkg is unable to link because we cannot decide between Release and Debug libraries. Please define the property VcpkgConfiguration to be 'Release' or 'Debug' (currently '$(VcpkgConfiguration)')." Importance="High" Condition="'$(VcpkgEnabled)' == 'true' and '$(VcpkgNormalizedConfiguration)' == ''"/> </Target> <Target Name="AppLocalFromInstalled" AfterTargets="CopyFilesToOutputDirectory" BeforeTargets="CopyLocalFilesOutputGroup;RegisterOutput" Condition="'$(VcpkgEnabled)' == 'true'"> diff --git a/scripts/cmake/vcpkg_acquire_depot_tools.cmake b/scripts/cmake/vcpkg_acquire_depot_tools.cmake deleted file mode 100644 index 009ba40f1..000000000 --- a/scripts/cmake/vcpkg_acquire_depot_tools.cmake +++ /dev/null @@ -1,48 +0,0 @@ -function(vcpkg_acquire_depot_tools PATH_TO_ROOT_OUT) - set(TOOLPATH ${DOWNLOADS}/tools/depot_tools) - 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...") - - 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() diff --git a/scripts/cmake/vcpkg_acquire_msys.cmake b/scripts/cmake/vcpkg_acquire_msys.cmake index 830022906..80a30bf2b 100644 --- a/scripts/cmake/vcpkg_acquire_msys.cmake +++ b/scripts/cmake/vcpkg_acquire_msys.cmake @@ -70,14 +70,18 @@ function(vcpkg_acquire_msys PATH_TO_ROOT_OUT) set(PATH_TO_ROOT ${TOOLPATH}/${TOOLSUBPATH}) if(NOT EXISTS "${TOOLPATH}/${STAMP}") + message(STATUS "Acquiring MSYS2...") - file(DOWNLOAD ${URL} ${DOWNLOADS}/${ARCHIVE} - EXPECTED_HASH SHA512=${HASH} + vcpkg_download_distfile(ARCHIVE_PATH + URLS ${URL} + FILENAME ${ARCHIVE} + SHA512 ${HASH} ) + file(REMOVE_RECURSE ${TOOLPATH}/${TOOLSUBPATH}) file(MAKE_DIRECTORY ${TOOLPATH}) execute_process( - COMMAND ${CMAKE_COMMAND} -E tar xzf ${DOWNLOADS}/${ARCHIVE} + COMMAND ${CMAKE_COMMAND} -E tar xzf ${ARCHIVE_PATH} WORKING_DIRECTORY ${TOOLPATH} ) execute_process( diff --git a/scripts/cmake/vcpkg_common_functions.cmake b/scripts/cmake/vcpkg_common_functions.cmake index 40111542d..258b8f64a 100644 --- a/scripts/cmake/vcpkg_common_functions.cmake +++ b/scripts/cmake/vcpkg_common_functions.cmake @@ -25,4 +25,4 @@ include(vcpkg_copy_tool_dependencies) include(vcpkg_get_program_files_32_bit) include(vcpkg_get_program_files_platform_bitness) include(vcpkg_get_windows_sdk) -include(vcpkg_replace_string) +include(vcpkg_replace_string)
\ No newline at end of file diff --git a/scripts/cmake/vcpkg_download_distfile.cmake b/scripts/cmake/vcpkg_download_distfile.cmake index b8acfc823..b22d82a16 100644 --- a/scripts/cmake/vcpkg_download_distfile.cmake +++ b/scripts/cmake/vcpkg_download_distfile.cmake @@ -38,9 +38,18 @@ function(vcpkg_download_distfile VAR) set(oneValueArgs FILENAME SHA512) set(multipleValuesArgs URLS) cmake_parse_arguments(vcpkg_download_distfile "" "${oneValueArgs}" "${multipleValuesArgs}" ${ARGN}) + set(downloaded_file_path ${DOWNLOADS}/${vcpkg_download_distfile_FILENAME}) + set(download_file_path_part "${DOWNLOADS}/temp/${vcpkg_download_distfile_FILENAME}") + + file(REMOVE_RECURSE "${DOWNLOADS}/temp") + file(MAKE_DIRECTORY "${DOWNLOADS}/temp") function(test_hash FILE_KIND CUSTOM_ERROR_ADVICE) + if (_VCPKG_INTERNAL_NO_HASH_CHECK) + return() + endif() + message(STATUS "Testing integrity of ${FILE_KIND}...") file(SHA512 ${downloaded_file_path} FILE_HASH) if(NOT "${FILE_HASH}" STREQUAL "${vcpkg_download_distfile_SHA512}") @@ -65,13 +74,13 @@ function(vcpkg_download_distfile VAR) # Tries to download the file. foreach(url IN LISTS vcpkg_download_distfile_URLS) message(STATUS "Downloading ${url}...") - file(DOWNLOAD ${url} ${downloaded_file_path} STATUS download_status) + file(DOWNLOAD ${url} "${download_file_path_part}" 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() + file(RENAME ${download_file_path_part} ${downloaded_file_path}) message(STATUS "Downloading ${url}... OK") set(download_success 1) break() diff --git a/scripts/cmake/vcpkg_find_acquire_program.cmake b/scripts/cmake/vcpkg_find_acquire_program.cmake index b81675c13..e6a37e328 100644 --- a/scripts/cmake/vcpkg_find_acquire_program.cmake +++ b/scripts/cmake/vcpkg_find_acquire_program.cmake @@ -110,10 +110,10 @@ function(vcpkg_find_acquire_program VAR) set(PROGNAME meson) set(REQUIRED_INTERPRETER PYTHON3) set(SCRIPTNAME meson.py) - set(PATHS ${DOWNLOADS}/tools/meson/meson-0.40.1) - set(URL "https://github.com/mesonbuild/meson/archive/0.40.1.zip") - set(ARCHIVE "meson-0.40.1.zip") - set(HASH 4c1d07f32d527859f762c34de74d31d569573fc833335ab9652ed38d1f9e64b49869e826527c28a6a07cb8e594fd5c647b34aa95e626236a2707f75df0a2d435) + set(PATHS ${DOWNLOADS}/tools/meson/meson-0.43.0) + set(URL "https://github.com/mesonbuild/meson/archive/0.43.0.zip") + set(ARCHIVE "meson-0.43.0.zip") + set(HASH dde4de72eff37046731224f32aa5f4618d45bdf148cec2d1af6e25e7522ebc2b04aedc9eceed483dfa93823a0ea7ea472d0c0c9380061bf3ee2f16b87dd1425e) elseif(VAR MATCHES "FLEX") set(PROGNAME win_flex) set(PATHS ${DOWNLOADS}/tools/win_flex) @@ -164,18 +164,20 @@ function(vcpkg_find_acquire_program VAR) do_find() if("${${VAR}}" MATCHES "-NOTFOUND") - file(DOWNLOAD ${URL} ${DOWNLOADS}/${ARCHIVE} - EXPECTED_HASH SHA512=${HASH} - SHOW_PROGRESS + vcpkg_download_distfile(ARCHIVE_PATH + URLS ${URL} + SHA512 ${HASH} + FILENAME ${ARCHIVE} ) + file(MAKE_DIRECTORY ${DOWNLOADS}/tools/${PROGNAME}/${SUBDIR}) if(DEFINED NOEXTRACT) - file(COPY ${DOWNLOADS}/${ARCHIVE} DESTINATION ${DOWNLOADS}/tools/${PROGNAME}/${SUBDIR}) + file(COPY ${ARCHIVE_PATH} DESTINATION ${DOWNLOADS}/tools/${PROGNAME}/${SUBDIR}) else() get_filename_component(ARCHIVE_EXTENSION ${ARCHIVE} EXT) string(TOLOWER "${ARCHIVE_EXTENSION}" ARCHIVE_EXTENSION) if(ARCHIVE_EXTENSION STREQUAL ".msi") - file(TO_NATIVE_PATH "${DOWNLOADS}/${ARCHIVE}" ARCHIVE_NATIVE_PATH) + file(TO_NATIVE_PATH "${ARCHIVE_PATH}" ARCHIVE_NATIVE_PATH) file(TO_NATIVE_PATH "${DOWNLOADS}/tools/${PROGNAME}/${SUBDIR}" DESTINATION_NATIVE_PATH) execute_process( COMMAND msiexec /a ${ARCHIVE_NATIVE_PATH} /qn TARGETDIR=${DESTINATION_NATIVE_PATH} @@ -183,7 +185,7 @@ function(vcpkg_find_acquire_program VAR) ) else() execute_process( - COMMAND ${CMAKE_COMMAND} -E tar xzf ${DOWNLOADS}/${ARCHIVE} + COMMAND ${CMAKE_COMMAND} -E tar xzf ${ARCHIVE_PATH} WORKING_DIRECTORY ${DOWNLOADS}/tools/${PROGNAME}/${SUBDIR} ) endif() diff --git a/scripts/cmake/vcpkg_fixup_cmake_targets.cmake b/scripts/cmake/vcpkg_fixup_cmake_targets.cmake index eaf3bb966..22c2245c8 100644 --- a/scripts/cmake/vcpkg_fixup_cmake_targets.cmake +++ b/scripts/cmake/vcpkg_fixup_cmake_targets.cmake @@ -23,7 +23,7 @@ function(vcpkg_fixup_cmake_targets) set(DEBUG_SHARE ${CURRENT_PACKAGES_DIR}/debug/share/${PORT}) set(RELEASE_SHARE ${CURRENT_PACKAGES_DIR}/share/${PORT}) - if(_vfct_CONFIG_PATH) + if(_vfct_CONFIG_PATH AND NOT RELEASE_SHARE STREQUAL "${CURRENT_PACKAGES_DIR}/${_vfct_CONFIG_PATH}") set(DEBUG_CONFIG ${CURRENT_PACKAGES_DIR}/debug/${_vfct_CONFIG_PATH}) set(RELEASE_CONFIG ${CURRENT_PACKAGES_DIR}/${_vfct_CONFIG_PATH}) @@ -31,10 +31,14 @@ function(vcpkg_fixup_cmake_targets) message(FATAL_ERROR "'${DEBUG_CONFIG}' does not exist.") endif() - file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/debug/share) - file(RENAME ${DEBUG_CONFIG} ${DEBUG_SHARE}) - file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/share) - file(RENAME ${RELEASE_CONFIG} ${RELEASE_SHARE}) + file(MAKE_DIRECTORY ${DEBUG_SHARE}) + file(GLOB FILES ${DEBUG_CONFIG}/*) + file(COPY ${FILES} DESTINATION ${DEBUG_SHARE}) + file(REMOVE_RECURSE ${DEBUG_CONFIG}) + + file(GLOB FILES ${RELEASE_CONFIG}/*) + file(COPY ${FILES} DESTINATION ${RELEASE_SHARE}) + file(REMOVE_RECURSE ${RELEASE_CONFIG}) get_filename_component(DEBUG_CONFIG_DIR_NAME ${DEBUG_CONFIG} NAME) string(TOLOWER "${DEBUG_CONFIG_DIR_NAME}" DEBUG_CONFIG_DIR_NAME) @@ -83,6 +87,7 @@ function(vcpkg_fixup_cmake_targets) ) foreach(RELEASE_TARGET ${RELEASE_TARGETS}) file(READ ${RELEASE_TARGET} _contents) + string(REPLACE "${CURRENT_INSTALLED_DIR}" "\${_IMPORT_PREFIX}" _contents "${_contents}") string(REGEX REPLACE "\\\${_IMPORT_PREFIX}/bin/([^ \"]+\\.exe)" "\${_IMPORT_PREFIX}/tools/${PORT}/\\1" _contents "${_contents}") file(WRITE ${RELEASE_TARGET} "${_contents}") endforeach() @@ -95,6 +100,7 @@ function(vcpkg_fixup_cmake_targets) get_filename_component(DEBUG_TARGET_NAME ${DEBUG_TARGET} NAME) file(READ ${DEBUG_TARGET} _contents) + string(REPLACE "${CURRENT_INSTALLED_DIR}" "\${_IMPORT_PREFIX}" _contents "${_contents}") string(REGEX REPLACE "\\\${_IMPORT_PREFIX}/bin/([^ \"]+\\.exe)" "\${_IMPORT_PREFIX}/tools/${PORT}/\\1" _contents "${_contents}") string(REPLACE "\${_IMPORT_PREFIX}/lib" "\${_IMPORT_PREFIX}/debug/lib" _contents "${_contents}") string(REPLACE "\${_IMPORT_PREFIX}/bin" "\${_IMPORT_PREFIX}/debug/bin" _contents "${_contents}") @@ -110,6 +116,10 @@ function(vcpkg_fixup_cmake_targets) "get_filename_component\\(_IMPORT_PREFIX \"\\\${CMAKE_CURRENT_LIST_FILE}\" PATH\\)(\nget_filename_component\\(_IMPORT_PREFIX \"\\\${_IMPORT_PREFIX}\" PATH\\))*" "get_filename_component(_IMPORT_PREFIX \"\${CMAKE_CURRENT_LIST_FILE}\" PATH)\nget_filename_component(_IMPORT_PREFIX \"\${_IMPORT_PREFIX}\" PATH)\nget_filename_component(_IMPORT_PREFIX \"\${_IMPORT_PREFIX}\" PATH)" _contents "${_contents}") + string(REPLACE "${CURRENT_INSTALLED_DIR}" "_INVALID_ROOT_" _contents "${_contents}") + string(REGEX REPLACE ";_INVALID_ROOT_/[^\";]*" "" _contents "${_contents}") + string(REGEX REPLACE "_INVALID_ROOT_/[^\";]*;" "" _contents "${_contents}") + string(REGEX REPLACE "\"_INVALID_ROOT_/[^\";]*\"" "\"\"" _contents "${_contents}") file(WRITE ${MAIN_TARGET} "${_contents}") endforeach() diff --git a/scripts/cmake/vcpkg_from_bitbucket.cmake b/scripts/cmake/vcpkg_from_bitbucket.cmake index 227de5141..26600f013 100644 --- a/scripts/cmake/vcpkg_from_bitbucket.cmake +++ b/scripts/cmake/vcpkg_from_bitbucket.cmake @@ -92,13 +92,13 @@ function(vcpkg_from_bitbucket) message(STATUS "Package does not specify HEAD_REF. Falling back to non-HEAD version.") set(VCPKG_USE_HEAD_VERSION OFF) endif() - + # Handle --no-head scenarios if(NOT VCPKG_USE_HEAD_VERSION) if(NOT _vdud_REF) message(FATAL_ERROR "Package does not specify REF. It must built using --head.") endif() - + set(URL "https://bitbucket.com/${ORG_NAME}/${REPO_NAME}/get/${_vdud_REF}.tar.gz") set(downloaded_file_path "${DOWNLOADS}/${ORG_NAME}-${REPO_NAME}-${_vdud_REF}.tar.gz") @@ -117,7 +117,7 @@ function(vcpkg_from_bitbucket) else() set(_version ${_vdud_REF}) endif() - + vcpkg_download_distfile(ARCHIVE URLS "https://bitbucket.com/${ORG_NAME}/${REPO_NAME}/get/${_vdud_REF}.tar.gz" SHA512 "${_vdud_SHA512}" @@ -150,39 +150,31 @@ function(vcpkg_from_bitbucket) endif() # Try to download the file and version information from bitbucket. - message(STATUS "Downloading ${URL}...") - file(DOWNLOAD "https://api.bitbucket.com/2.0/repositories/${ORG_NAME}/${REPO_NAME}/refs/branches/${_vdud_HEAD_REF}" - ${downloaded_file_path}.version - STATUS download_status + set(_VCPKG_INTERNAL_NO_HASH_CHECK "TRUE") + vcpkg_download_distfile(ARCHIVE_VERSION + URLS "https://api.bitbucket.com/2.0/repositories/${ORG_NAME}/${REPO_NAME}/refs/branches/${_vdud_HEAD_REF}" + FILENAME ${downloaded_file_name}.version ) - list(GET download_status 0 status_code) - if (NOT "${status_code}" STREQUAL "0") - file(REMOVE ${downloaded_file_path}.version) - message(FATAL_ERROR "Downloading version info for ${URL}... Failed. Status: ${download_status}") - endif() - file(DOWNLOAD ${URL} ${downloaded_file_path} STATUS download_status) - list(GET download_status 0 status_code) - if (NOT "${status_code}" STREQUAL "0") - file(REMOVE ${downloaded_file_path}) - message(FATAL_ERROR "Downloading ${URL}... Failed. Status: ${download_status}") - else() - message(STATUS "Downloading ${URL}... OK") - endif() + vcpkg_download_distfile(ARCHIVE + URLS ${URL} + FILENAME ${downloaded_file_name} + ) + set(_VCPKG_INTERNAL_NO_HASH_CHECK "FALSE") endif() vcpkg_extract_source_archive_ex( - ARCHIVE "${downloaded_file_path}" + ARCHIVE "${ARCHIVE}" WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}/src/head" ) # Parse the github refs response with regex. # TODO: use some JSON swiss-army-knife utility instead. - file(READ "${downloaded_file_path}.version" _contents) + file(READ "${ARCHIVE_VERSION}" _contents) string(REGEX MATCH "\"hash\": \"[a-f0-9]+\"" x "${_contents}") string(REGEX REPLACE "\"hash\": \"([a-f0-9]+)\"" "\\1" _version ${x}) string(SUBSTRING ${_version} 0 12 _vdud_HEAD_REF) # Get the 12 first numbers from commit hash - + # 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) diff --git a/scripts/cmake/vcpkg_from_github.cmake b/scripts/cmake/vcpkg_from_github.cmake index 645690353..1ede43fd8 100644 --- a/scripts/cmake/vcpkg_from_github.cmake +++ b/scripts/cmake/vcpkg_from_github.cmake @@ -80,6 +80,7 @@ function(vcpkg_from_github) else() # Sometimes GitHub strips a leading 'v' off the REF. string(REGEX REPLACE "^v" "" REF ${BASEREF}) + string(REPLACE "/" "-" REF ${REF}) set(SOURCE_PATH "${BASE}/${REPO_NAME}-${REF}") if(EXISTS ${SOURCE_PATH}) set(${_vdud_OUT_SOURCE_PATH} "${SOURCE_PATH}" PARENT_SCOPE) @@ -112,7 +113,8 @@ function(vcpkg_from_github) # The following is for --head scenarios set(URL "https://github.com/${ORG_NAME}/${REPO_NAME}/archive/${_vdud_HEAD_REF}.tar.gz") - set(downloaded_file_path "${DOWNLOADS}/${ORG_NAME}-${REPO_NAME}-${_vdud_HEAD_REF}.tar.gz") + set(downloaded_file_name "${ORG_NAME}-${REPO_NAME}-${_vdud_HEAD_REF}.tar.gz") + set(downloaded_file_path "${DOWNLOADS}/${downloaded_file_name}") if(_VCPKG_NO_DOWNLOADS) if(NOT EXISTS ${downloaded_file_path} OR NOT EXISTS ${downloaded_file_path}.version) @@ -132,35 +134,27 @@ function(vcpkg_from_github) endif() # Try to download the file and version information from github. - message(STATUS "Downloading ${URL}...") - file(DOWNLOAD "https://api.github.com/repos/${ORG_NAME}/${REPO_NAME}/git/refs/heads/${_vdud_HEAD_REF}" - ${downloaded_file_path}.version - STATUS download_status + 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 ) - list(GET download_status 0 status_code) - if (NOT "${status_code}" STREQUAL "0") - file(REMOVE ${downloaded_file_path}.version) - message(FATAL_ERROR "Downloading version info for ${URL}... Failed. Status: ${download_status}") - endif() - file(DOWNLOAD ${URL} ${downloaded_file_path} STATUS download_status) - list(GET download_status 0 status_code) - if (NOT "${status_code}" STREQUAL "0") - file(REMOVE ${downloaded_file_path}) - message(FATAL_ERROR "Downloading ${URL}... Failed. Status: ${download_status}") - else() - message(STATUS "Downloading ${URL}... OK") - endif() + vcpkg_download_distfile(ARCHIVE + URLS ${URL} + FILENAME ${downloaded_file_name} + ) + set(_VCPKG_INTERNAL_NO_HASH_CHECK "FALSE") endif() vcpkg_extract_source_archive_ex( - ARCHIVE "${downloaded_file_path}" + ARCHIVE "${ARCHIVE}" WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}/src/head" ) # Parse the github refs response with regex. # TODO: use some JSON swiss-army-knife utility instead. - file(READ "${downloaded_file_path}.version" _contents) + file(READ "${ARCHIVE_VERSION}" _contents) string(REGEX MATCH "\"sha\": \"[a-f0-9]+\"" x "${_contents}") string(REGEX REPLACE "\"sha\": \"([a-f0-9]+)\"" "\\1" _version ${x}) diff --git a/scripts/cmake/vcpkg_get_windows_sdk.cmake b/scripts/cmake/vcpkg_get_windows_sdk.cmake index 64d8838e7..a8aad64a9 100644 --- a/scripts/cmake/vcpkg_get_windows_sdk.cmake +++ b/scripts/cmake/vcpkg_get_windows_sdk.cmake @@ -10,7 +10,7 @@ function(vcpkg_get_windows_sdk ret) message(FATAL_ERROR "Could not find Windows SDK") endif() - # Remove trailing newline - string(REGEX REPLACE "\n$" "" WINDOWS_SDK "${WINDOWS_SDK}") + # Remove trailing newline and non-numeric characters + string(REGEX REPLACE "[^0-9.]" "" WINDOWS_SDK "${WINDOWS_SDK}") set(${ret} ${WINDOWS_SDK} PARENT_SCOPE) endfunction()
\ No newline at end of file diff --git a/scripts/fetchDependency.ps1 b/scripts/fetchDependency.ps1 index 773ebeac4..16ba984e6 100644 --- a/scripts/fetchDependency.ps1 +++ b/scripts/fetchDependency.ps1 @@ -3,7 +3,36 @@ param( [string]$Dependency ) -if ($PSVersionTable.PSEdition -ne "Core") { +function Test-Command($commandName) +{ + return [bool](Get-Command -Name $commandName -ErrorAction SilentlyContinue) +} + +function Test-CommandParameter($commandName, $parameterName) +{ + return (Get-Command $commandName).Parameters.Keys -contains $parameterName +} + +function Test-Module($moduleName) +{ + return [bool](Get-Module -ListAvailable -Name $moduleName) +} + +function Get-Credential-Backwards-Compatible() +{ + if (Test-CommandParameter -commandName 'Get-Credential' -parameterName 'Message') + { + return Get-Credential -Message "Enter credentials for Proxy Authentication" + } + else + { + Write-Host "Enter credentials for Proxy Authentication" + return Get-Credential + } +} + +if (Test-Module -moduleName 'BitsTransfer') +{ Import-Module BitsTransfer -Verbose:$false } @@ -28,42 +57,59 @@ function SelectProgram([Parameter(Mandatory=$true)][string]$Dependency) return } - # Can't print because vcpkg captures the output and expects only the path that is returned at the end of this script file - # Write-Host "A suitable version of $Dependency was not found (required v$requiredVersion). Downloading portable $Dependency v$downloadVersion..." - if (!(Test-Path $downloadDir)) { New-Item -ItemType directory -Path $downloadDir | Out-Null } - $WC = New-Object System.Net.WebClient - $ProxyAuth = !$WC.Proxy.IsBypassed($url) - if ($ProxyAuth) + $downloadsTemp = "$downloadDir/temp" + if (Test-Path $downloadsTemp) # Delete temp dir if it exists { - $ProxyCred = Get-Credential -Message "Enter credentials for Proxy Authentication" - $PSDefaultParameterValues.Add("Start-BitsTransfer:ProxyAuthentication","Basic") - $PSDefaultParameterValues.Add("Start-BitsTransfer:ProxyCredential",$ProxyCred) - $WC.Proxy.Credentials=$ProxyCred + Remove-Item $downloadsTemp -Recurse -Force } + if (!(Test-Path $downloadsTemp)) # Recreate temp dir. It may still be there the dir was in use + { + New-Item -ItemType directory -Path $downloadsTemp | Out-Null + } + + $tempDownloadName = "$downloadsTemp/$Dependency-$downloadVersion.temp" + + $WC = New-Object System.Net.WebClient + $ProxyAuth = !$WC.Proxy.IsBypassed($url) - if (($PSVersionTable.PSEdition -ne "Core") -and ($Dependency -ne "git")) # git fails with BITS + # git and installerbase fail with Start-BitsTransfer + if ((Test-Command -commandName 'Start-BitsTransfer') -and ($Dependency -ne "git")-and ($Dependency -ne "installerbase")) { - try { - Start-BitsTransfer -Source $url -Destination $downloadPath -ErrorAction Stop + try + { + if ($ProxyAuth) + { + $ProxyCred = Get-Credential-Backwards-Compatible + $PSDefaultParameterValues.Add("Start-BitsTransfer:ProxyAuthentication","Basic") + $PSDefaultParameterValues.Add("Start-BitsTransfer:ProxyCredential", $ProxyCred) + } + Start-BitsTransfer -Source $url -Destination $tempDownloadName -ErrorAction Stop + Move-Item -Path $tempDownloadName -Destination $downloadPath + return } - catch [System.Exception] { + catch [System.Exception] + { # If BITS fails for any reason, delete any potentially partially downloaded files and continue - if (Test-Path $downloadPath) + if (Test-Path $tempDownloadName) { - Remove-Item $downloadPath + Remove-Item $tempDownloadName } } } - if (!(Test-Path $downloadPath)) + + if ($ProxyAuth) { - Write-Verbose("Downloading $Dependency...") - $WC.DownloadFile($url, $downloadPath) + $WC.Proxy.Credentials = Get-Credential-Backwards-Compatible } + + Write-Verbose("Downloading $Dependency...") + $WC.DownloadFile($url, $tempDownloadName) + Move-Item -Path $tempDownloadName -Destination $downloadPath } # Enums (without resorting to C#) are only available on powershell 5+. @@ -96,58 +142,65 @@ function SelectProgram([Parameter(Mandatory=$true)][string]$Dependency) New-Item -ItemType Directory -Path $destination | Out-Null } - $shell = new-object -com shell.application - $zip = $shell.NameSpace($file) - foreach($item in $zip.items()) + if (Test-Command -commandName 'Expand-Archive') + { + Expand-Archive -path $file -destinationpath $destination + } + else { - # Piping to Out-Null is used to block until finished - $shell.Namespace($destination).copyhere($item) | Out-Null + $shell = new-object -com shell.application + $zip = $shell.NameSpace($file) + foreach($item in $zip.items()) + { + # Piping to Out-Null is used to block until finished + $shell.Namespace($destination).copyhere($item) | Out-Null + } } } if($Dependency -eq "cmake") { - $requiredVersion = "3.9.3" - $downloadVersion = "3.9.3" - $url = "https://cmake.org/files/v3.9/cmake-3.9.3-win32-x86.zip" - $downloadPath = "$downloadsDir\cmake-3.9.3-win32-x86.zip" - $expectedDownloadedFileHash = "47870e3d4c9a5aa019e71020cd85cc60b6f2d2569fb239eaec204cd991e512f1" - $executableFromDownload = "$downloadsDir\cmake-3.9.3-win32-x86\bin\cmake.exe" + $requiredVersion = "3.9.5" + $downloadVersion = "3.9.5" + $url = "https://cmake.org/files/v3.9/cmake-3.9.5-win32-x86.zip" + $downloadPath = "$downloadsDir\cmake-3.9.5-win32-x86.zip" + $expectedDownloadedFileHash = "dd3e183254c12f7c338d3edfa642f1ac84a763b8b9a2feabb4ad5fccece5dff9" + $executableFromDownload = "$downloadsDir\cmake-3.9.5-win32-x86\bin\cmake.exe" $extractionType = $ExtractionType_ZIP $extractionFolder = $downloadsDir } elseif($Dependency -eq "nuget") { - $requiredVersion = "4.3.0" - $downloadVersion = "4.3.0" - $url = "https://dist.nuget.org/win-x86-commandline/v4.3.0/nuget.exe" + $requiredVersion = "4.4.0" + $downloadVersion = "4.4.0" + $url = "https://dist.nuget.org/win-x86-commandline/v4.4.0/nuget.exe" $downloadPath = "$downloadsDir\nuget-$downloadVersion\nuget.exe" - $expectedDownloadedFileHash = "386da77a8cf2b63d1260b7020feeedabfe3b65ab31d20e6a313a530865972f3a" + $expectedDownloadedFileHash = "2cf9b118937eef825464e548f0c44f7f64090047746de295d75ac3dcffa3e1f6" $executableFromDownload = $downloadPath $extractionType = $ExtractionType_NO_EXTRACTION_REQUIRED } elseif($Dependency -eq "vswhere") { - $requiredVersion = "2.2.3" - $downloadVersion = "2.2.3" - $url = "https://github.com/Microsoft/vswhere/releases/download/2.2.3/vswhere.exe" + $requiredVersion = "2.2.11" + $downloadVersion = "2.2.11" + $url = "https://github.com/Microsoft/vswhere/releases/download/2.2.11/vswhere.exe" $downloadPath = "$downloadsDir\vswhere-$downloadVersion\vswhere.exe" - $expectedDownloadedFileHash = "5f19066ac91635ad17d33fe0f79fc63c672a46f98c0358589a90163bcb2733e8" + $expectedDownloadedFileHash = "0235c2cb6341978abdf32e27fcf1d7af5cb5514c035e529c4cd9283e6f1a261f" $executableFromDownload = $downloadPath $extractionType = $ExtractionType_NO_EXTRACTION_REQUIRED } elseif($Dependency -eq "git") { - $requiredVersion = "2.14.1" - $downloadVersion = "2.14.1" - $url = "https://github.com/git-for-windows/git/releases/download/v2.14.1.windows.1/MinGit-2.14.1-32-bit.zip" # We choose the 32-bit version - $downloadPath = "$downloadsDir\MinGit-2.14.1-32-bit.zip" - $expectedDownloadedFileHash = "77b468e0ead1e7da4cb3a1cf35dabab5210bf10457b4142f5e9430318217cdef" + $requiredVersion = "2.15.0" + $downloadVersion = "2.15.0" + $url = "https://github.com/git-for-windows/git/releases/download/v2.15.0.windows.1/MinGit-2.15.0-32-bit.zip" + $downloadPath = "$downloadsDir\MinGit-2.15.0-32-bit.zip" + $expectedDownloadedFileHash = "69c035ab7b75c42ce5dd99e8927d2624ab618fab73c5ad84c9412bd74c343537" # There is another copy of git.exe in MinGit\bin. However, an installed version of git add the cmd dir to the PATH. # Therefore, choosing the cmd dir here as well. - $executableFromDownload = "$downloadsDir\MinGit-2.14.1-32-bit\cmd\git.exe" + $executableFromDownload = "$downloadsDir\MinGit-2.15.0-32-bit\cmd\git.exe" $extractionType = $ExtractionType_ZIP - $extractionFolder = "$downloadsDir\MinGit-2.14.1-32-bit" + $extractionFolder = "$downloadsDir\MinGit-2.15.0-32-bit" } elseif($Dependency -eq "installerbase") { @@ -174,21 +227,26 @@ function SelectProgram([Parameter(Mandatory=$true)][string]$Dependency) performDownload $Dependency $url $downloadsDir $downloadPath $downloadVersion $requiredVersion #calculating the hash - if ($PSVersionTable.PSEdition -ne "Core") + if (Test-Command -commandName 'Get-FileHash') + { + $downloadedFileHash = (Get-FileHash -Path $downloadPath -Algorithm SHA256).Hash + } + else { $hashAlgorithm = [Security.Cryptography.HashAlgorithm]::Create("SHA256") $fileAsByteArray = [io.File]::ReadAllBytes($downloadPath) $hashByteArray = $hashAlgorithm.ComputeHash($fileAsByteArray) $downloadedFileHash = -Join ($hashByteArray | ForEach-Object {"{0:x2}" -f $_}) } - else - { - $downloadedFileHash = (Get-FileHash -Path $downloadPath -Algorithm SHA256).Hash - } + $downloadedFileHash = $downloadedFileHash.ToLower() if ($expectedDownloadedFileHash -ne $downloadedFileHash) { - throw [System.IO.FileNotFoundException] ("Mismatching hash of the downloaded " + $Dependency) + Write-Host ("`nFile does not have expected hash:`n" + + " File path: [ $downloadPath ]`n" + + " Expected hash: [ $expectedDownloadedFileHash ]`n" + + " Actual hash: [ $downloadedFileHash ]`n") + throw "Invalid Hash" } if ($extractionType -eq $ExtractionType_NO_EXTRACTION_REQUIRED) @@ -217,12 +275,12 @@ function SelectProgram([Parameter(Mandatory=$true)][string]$Dependency) if (-not (Test-Path $executableFromDownload)) { - throw [System.IO.FileNotFoundException] ("Could not detect or download " + $Dependency) + throw ("Could not detect or download " + $Dependency) } return $executableFromDownload } -SelectProgram $Dependency - +$path = SelectProgram $Dependency Write-Verbose "Fetching dependency: $Dependency. Done." +return "<sol>::$path::<eol>" diff --git a/scripts/findAnyMSBuildWithCppPlatformToolset.ps1 b/scripts/findAnyMSBuildWithCppPlatformToolset.ps1 index e9fb60cb2..d9ffbd32a 100644 --- a/scripts/findAnyMSBuildWithCppPlatformToolset.ps1 +++ b/scripts/findAnyMSBuildWithCppPlatformToolset.ps1 @@ -9,8 +9,9 @@ $explicitlyRequestedVSPath = $explicitlyRequestedVSPath -replace "\\$" # Remove $scriptsDir = split-path -parent $MyInvocation.MyCommand.Definition $VisualStudioInstallationInstances = & $scriptsDir\findVisualStudioInstallationInstances.ps1 Write-Verbose "VS Candidates:`n`r$([system.String]::Join([Environment]::NewLine, $VisualStudioInstallationInstances))" -foreach ($instanceCandidate in $VisualStudioInstallationInstances) +foreach ($instanceCandidateWithEOL in $VisualStudioInstallationInstances) { + $instanceCandidate = $instanceCandidateWithEOL -replace "<sol>::" -replace "::<eol>" Write-Verbose "Inspecting: $instanceCandidate" $split = $instanceCandidate -split "::" # $preferenceWeight = $split[0] diff --git a/scripts/findVisualStudioInstallationInstances.ps1 b/scripts/findVisualStudioInstallationInstances.ps1 index 8a2adca10..e3bc67ff6 100644 --- a/scripts/findVisualStudioInstallationInstances.ps1 +++ b/scripts/findVisualStudioInstallationInstances.ps1 @@ -4,7 +4,7 @@ param( ) $scriptsDir = split-path -parent $MyInvocation.MyCommand.Definition -$vswhereExe = & $scriptsDir\fetchDependency.ps1 "vswhere" +$vswhereExe = (& $scriptsDir\fetchDependency.ps1 "vswhere") -replace "<sol>::" -replace "::<eol>" $output = & $vswhereExe -prerelease -legacy -products * -format xml [xml]$asXml = $output @@ -29,7 +29,7 @@ foreach ($instance in $asXml.instances.instance) } # Placed like that for easy sorting according to preference - $results.Add("${releaseType}::${installationVersion}::${installationPath}") > $null + $results.Add("<sol>::${releaseType}::${installationVersion}::${installationPath}::<eol>") > $null } # If nothing is found, attempt to find VS2015 Build Tools (not detected by vswhere.exe) @@ -42,7 +42,7 @@ if ($results.Count -eq 0) if ((Test-Path $clExe) -And (Test-Path $vcvarsallbat)) { - return "PreferenceWeight1::Legacy::14.0::$installationPath" + return "<sol>::PreferenceWeight1::Legacy::14.0::$installationPath::<eol>" } } diff --git a/scripts/internalCI.ps1 b/scripts/internalCI.ps1 index 887eb7bea..16ce4fc7a 100644 --- a/scripts/internalCI.ps1 +++ b/scripts/internalCI.ps1 @@ -5,7 +5,10 @@ New-Item -type directory downloads -errorAction SilentlyContinue | Out-Null if (-not $?) { throw $? } # Clear out any intermediate files from the previous build -Get-ChildItem buildtrees/*/* | ? { $_.Name -ne "src" -and $_.Extension -ne ".log"} | Remove-Item -Recurse -Force +if (Test-Path buildtrees) +{ + Get-ChildItem buildtrees/*/* | ? { $_.Name -ne "src" -and $_.Extension -ne ".log"} | Remove-Item -Recurse -Force +} # Purge any outdated packages ./vcpkg remove --outdated --recurse diff --git a/scripts/ports.cmake b/scripts/ports.cmake index 8b4d17d80..ef06a4d65 100644 --- a/scripts/ports.cmake +++ b/scripts/ports.cmake @@ -108,10 +108,12 @@ elseif(CMD MATCHES "^CREATE$") message(STATUS "If this is not desired, delete the file and ${NATIVE_VCPKG_ROOT_DIR}\\ports\\${PORT}") else() include(vcpkg_download_distfile) - file(DOWNLOAD ${URL} ${DOWNLOADS}/${FILENAME} STATUS error_code) - if(NOT error_code MATCHES "0;") - message(FATAL_ERROR "Error downloading file: ${error_code}") - endif() + set(_VCPKG_INTERNAL_NO_HASH_CHECK "TRUE") + vcpkg_download_distfile(ARCHIVE + URLS ${URL} + FILENAME ${FILENAME} + ) + set(_VCPKG_INTERNAL_NO_HASH_CHECK "FALSE") endif() file(SHA512 ${DOWNLOADS}/${FILENAME} SHA512) |
