From f12ded7fd0ca91fb128ddaf20b933f8457d9c1f3 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Tue, 24 Apr 2018 22:44:46 +0000 Subject: [sh] Fix permission --- scripts/bootstrap.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 scripts/bootstrap.sh (limited to 'scripts') diff --git a/scripts/bootstrap.sh b/scripts/bootstrap.sh old mode 100644 new mode 100755 -- cgit v1.2.3 From b5e4c4c7cf68b807e222b09415b678d2f47a3d3b Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Tue, 24 Apr 2018 16:04:14 -0700 Subject: [find_acquire.cmake] Fix ninja path for mac --- scripts/cmake/vcpkg_find_acquire_program.cmake | 2 ++ 1 file changed, 2 insertions(+) (limited to 'scripts') diff --git a/scripts/cmake/vcpkg_find_acquire_program.cmake b/scripts/cmake/vcpkg_find_acquire_program.cmake index 30ecb0573..39a722d93 100644 --- a/scripts/cmake/vcpkg_find_acquire_program.cmake +++ b/scripts/cmake/vcpkg_find_acquire_program.cmake @@ -115,6 +115,8 @@ function(vcpkg_find_acquire_program VAR) set(SUBDIR "ninja-1.8.2") if(CMAKE_HOST_WIN32) set(PATHS "${DOWNLOADS}/tools/ninja/${SUBDIR}") + elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin") + set(PATHS "${DOWNLOADS}/tools/${SUBDIR}-osx") else() set(PATHS "${DOWNLOADS}/tools/${SUBDIR}-linux") endif() -- cgit v1.2.3 From 6a3c1db30bbdc0d2580a3c787d90811e6bb7823a Mon Sep 17 00:00:00 2001 From: Rudi Lee Date: Thu, 26 Apr 2018 07:38:45 +0700 Subject: Checking for sha512sum on OS which doesn't have shasum --- scripts/bootstrap.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/bootstrap.sh b/scripts/bootstrap.sh index 66efb1d62..58eb9e9fb 100755 --- a/scripts/bootstrap.sh +++ b/scripts/bootstrap.sh @@ -29,8 +29,15 @@ vcpkgCheckRepoTool() vcpkgCheckEqualFileHash() { url=$1; filePath=$2; expectedHash=$3 + + SHASUM="shasum -a 512" # sha512sum is not available on osx - actualHash=$(shasum -a 512 "$filePath") # sha512sum not available on osx + # checking for sha512sum on os which doesn't have shasum + if which sha512sum >/dev/null 2>&1; then + SHASUM=sha512sum + fi + + actualHash=$("$SHASUM" "$filePath") actualHash="${actualHash%% *}" # shasum returns [hash filename], so get the first word if ! [ "$expectedHash" = "$actualHash" ]; then -- cgit v1.2.3 From c78a609dabb0df43d0443452261f7c3b592b9b41 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Thu, 26 Apr 2018 02:11:04 +0000 Subject: [sh] Tweak so only the sh forwarder needs to be +x --- scripts/bootstrap.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100755 => 100644 scripts/bootstrap.sh (limited to 'scripts') diff --git a/scripts/bootstrap.sh b/scripts/bootstrap.sh old mode 100755 new mode 100644 index 66efb1d62..c69dc0135 --- a/scripts/bootstrap.sh +++ b/scripts/bootstrap.sh @@ -185,4 +185,4 @@ mkdir -p "$buildDir" (cd "$buildDir" && "$cmakeExe" --build .) rm -rf "$vcpkgRootDir/vcpkg" -cp "$buildDir/vcpkg" "$vcpkgRootDir/" \ No newline at end of file +cp "$buildDir/vcpkg" "$vcpkgRootDir/" -- cgit v1.2.3 From ef594607829ad6ed2bd462a0ddcbb0ee698b3f4f Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Wed, 25 Apr 2018 22:23:45 -0700 Subject: [bootstrap.sh] Minor refactoring for clarity --- scripts/bootstrap.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'scripts') diff --git a/scripts/bootstrap.sh b/scripts/bootstrap.sh index 2225f029d..95ee75af1 100644 --- a/scripts/bootstrap.sh +++ b/scripts/bootstrap.sh @@ -29,15 +29,15 @@ vcpkgCheckRepoTool() vcpkgCheckEqualFileHash() { url=$1; filePath=$2; expectedHash=$3 - - SHASUM="shasum -a 512" # sha512sum is not available on osx - # checking for sha512sum on os which doesn't have shasum - if which sha512sum >/dev/null 2>&1; then - SHASUM=sha512sum + if command -v "sha512sum" >/dev/null 2>&1 ; then + actualHash=$(sha512sum "$filePath") + else + # sha512sum is not available by default on osx + # shasum is not available by default on Fedora + actualHash=$(shasum -a 512 "$filePath") fi - actualHash=$("$SHASUM" "$filePath") actualHash="${actualHash%% *}" # shasum returns [hash filename], so get the first word if ! [ "$expectedHash" = "$actualHash" ]; then -- cgit v1.2.3 From 540a32c8413df21bc11aa714ff3086c9520fe6f5 Mon Sep 17 00:00:00 2001 From: Francois Budin Date: Fri, 27 Apr 2018 11:14:47 -0400 Subject: Require the version of g++ to be at least 6 On Ubuntu 16.04, old versions of g++ such as 4.9 are available. Other Linux distributions may also ship with g++ versions older than 5. With the previous test, the bootstrap script was not failing fast and instead was starting to compile vcpkg before it encountered the unsupported flag -std=c++1z. The error message was not very explicit and that was making it difficult to the developer to understand what the problem was. However, when using g++ 5, an clear error message was printed to help the user. This commit shows the helpful error message anytime g++ is older than version 6. --- scripts/bootstrap.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/bootstrap.sh b/scripts/bootstrap.sh index 95ee75af1..037a9136d 100644 --- a/scripts/bootstrap.sh +++ b/scripts/bootstrap.sh @@ -166,7 +166,7 @@ selectCXX() gccversion="$("$CXX" -v 2>&1)" gccversion="$(extractStringBetweenDelimiters "$gccversion" "gcc version " ".")" - if [ "$gccversion" = "5" ]; then + if [ "$gccversion" -lt "6" ]; then echo "CXX ($CXX) is too old; please install a newer compiler such as g++-7." echo "sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y" echo "sudo apt-get update -y" -- cgit v1.2.3 From 08afae2a7a5cd276fd251cbeef9a27f15261fc0c Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Fri, 27 Apr 2018 16:17:18 -0700 Subject: Bump version of git to 2.17.0 (was 2.16.2) --- scripts/vcpkgTools.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'scripts') diff --git a/scripts/vcpkgTools.xml b/scripts/vcpkgTools.xml index daaf29214..1a2abae81 100644 --- a/scripts/vcpkgTools.xml +++ b/scripts/vcpkgTools.xml @@ -22,11 +22,11 @@ cmake-3.10.2-Linux-x86_64.tar.gz - 2.16.2 + 2.17.0 cmd\git.exe - https://github.com/git-for-windows/git/releases/download/v2.16.2.windows.1/MinGit-2.16.2-32-bit.zip - 004e1dc1904f2e2d5c3534d0a56f58bf030b1146f5b263d6d191e60f72cd35455977c588604708125a1e93268ee8f7a5ab32ed6115adc028257b12d5926f350a - MinGit-2.16.2-32-bit.zip + https://github.com/git-for-windows/git/releases/download/v2.17.0.windows.1/MinGit-2.17.0-32-bit.zip + a34575ab1b4f553e62535e38492904b512df4d6a837cf4abf205dbcdd05edf1eef450cc5b15a4f63f901424d5f3cd1f78b6b22437d0d4f8cd9ce4e42e82617b9 + MinGit-2.17.0-32-bit.zip 2.4.1 -- cgit v1.2.3 From 468bfeb56e29e0130a1b56adb4c23fdba403221e Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Wed, 21 Feb 2018 21:17:14 -0800 Subject: [Clean patching] Each portref-patchset combo gets its own hash-based directory --- scripts/cmake/vcpkg_from_github.cmake | 73 ++++++++++++++++++++++++++--------- 1 file changed, 55 insertions(+), 18 deletions(-) (limited to 'scripts') diff --git a/scripts/cmake/vcpkg_from_github.cmake b/scripts/cmake/vcpkg_from_github.cmake index c6a23cff6..28ada0631 100644 --- a/scripts/cmake/vcpkg_from_github.cmake +++ b/scripts/cmake/vcpkg_from_github.cmake @@ -51,7 +51,7 @@ ## * [beast](https://github.com/Microsoft/vcpkg/blob/master/ports/beast/portfile.cmake) function(vcpkg_from_github) set(oneValueArgs OUT_SOURCE_PATH REPO REF SHA512 HEAD_REF) - set(multipleValuesArgs) + set(multipleValuesArgs PATCHES) cmake_parse_arguments(_vdud "" "${oneValueArgs}" "${multipleValuesArgs}" ${ARGN}) if(NOT DEFINED _vdud_OUT_SOURCE_PATH) @@ -73,21 +73,17 @@ function(vcpkg_from_github) string(REGEX REPLACE ".*/" "" REPO_NAME ${_vdud_REPO}) string(REGEX REPLACE "/.*" "" ORG_NAME ${_vdud_REPO}) - macro(set_SOURCE_PATH BASE BASEREF) - set(SOURCE_PATH "${BASE}/${REPO_NAME}-${BASEREF}") - if(EXISTS ${SOURCE_PATH}) - set(${_vdud_OUT_SOURCE_PATH} "${SOURCE_PATH}" PARENT_SCOPE) - 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) - else() - message(FATAL_ERROR "Could not determine source path: '${BASE}/${REPO_NAME}-${BASEREF}' does not exist") - endif() + macro(set_TEMP_SOURCE_PATH BASE BASEREF) + set(TEMP_SOURCE_PATH "${BASE}/${REPO_NAME}-${BASEREF}") + if(NOT EXISTS ${TEMP_SOURCE_PATH}) + # Sometimes GitHub strips a leading 'v' off the REF. + string(REGEX REPLACE "^v" "" REF ${BASEREF}) + string(REPLACE "/" "-" REF ${REF}) + set(TEMP_SOURCE_PATH "${BASE}/${REPO_NAME}-${REF}") + if(NOT EXISTS ${TEMP_SOURCE_PATH}) + message(FATAL_ERROR "Could not determine source path: '${BASE}/${REPO_NAME}-${BASEREF}' does not exist") endif() + endif() endmacro() if(VCPKG_USE_HEAD_VERSION AND NOT DEFINED _vdud_HEAD_REF) @@ -108,8 +104,44 @@ function(vcpkg_from_github) SHA512 "${_vdud_SHA512}" FILENAME "${ORG_NAME}-${REPO_NAME}-${SANITIZED_REF}.tar.gz" ) - vcpkg_extract_source_archive_ex(ARCHIVE "${ARCHIVE}") - set_SOURCE_PATH(${CURRENT_BUILDTREES_DIR}/src ${SANITIZED_REF}) + + # Take the last 10 chars of the REF + set(REF_MAX_LENGTH 10) + string(LENGTH ${SANITIZED_REF} REF_LENGTH) + math(EXPR FROM_REF ${REF_LENGTH}-${REF_MAX_LENGTH}) + if(FROM_REF LESS 0) + set(FROM_REF 0) + endif() + string(SUBSTRING ${SANITIZED_REF} ${FROM_REF} ${REF_LENGTH} SHORTENED_SANITIZED_REF) + + # Hash the archive hash along with the patches. Take the first 10 chars of the hash + set(PATCHSET_HASH "${_vdud_SHA512}") + foreach(PATCH IN LISTS _vdud_PATCHES) + file(SHA512 ${PATCH} CURRENT_HASH) + string(APPEND PATCHSET_HASH ${CURRENT_HASH}) + endforeach() + + string(SHA512 PATCHSET_HASH ${PATCHSET_HASH}) + string(SUBSTRING ${PATCHSET_HASH} 0 10 PATCHSET_HASH) + set(SOURCE_PATH "${CURRENT_BUILDTREES_DIR}/src/${SHORTENED_SANITIZED_REF}-${PATCHSET_HASH}") + + if(NOT EXISTS ${SOURCE_PATH}) + set(TEMP_DIR "${CURRENT_BUILDTREES_DIR}/src/TEMP") + file(REMOVE_RECURSE ${TEMP_DIR}) + vcpkg_extract_source_archive_ex(ARCHIVE "${ARCHIVE}" WORKING_DIRECTORY ${TEMP_DIR}) + set_TEMP_SOURCE_PATH(${CURRENT_BUILDTREES_DIR}/src/TEMP ${SANITIZED_REF}) + + vcpkg_apply_patches( + SOURCE_PATH ${TEMP_SOURCE_PATH} + PATCHES ${_vdud_PATCHES} + ) + + file(RENAME ${TEMP_SOURCE_PATH} ${SOURCE_PATH}) + file(REMOVE_RECURSE ${TEMP_DIR}) + endif() + + set(${_vdud_OUT_SOURCE_PATH} "${SOURCE_PATH}" PARENT_SCOPE) + return() endif() @@ -167,5 +199,10 @@ function(vcpkg_from_github) set(VCPKG_HEAD_VERSION ${_version} PARENT_SCOPE) endif() - set_SOURCE_PATH(${CURRENT_BUILDTREES_DIR}/src/head ${SANITIZED_HEAD_REF}) + set_TEMP_SOURCE_PATH(${CURRENT_BUILDTREES_DIR}/src/head ${SANITIZED_HEAD_REF}) + vcpkg_apply_patches( + SOURCE_PATH ${TEMP_SOURCE_PATH} + PATCHES ${_vdud_PATCHES} + ) + set(${_vdud_OUT_SOURCE_PATH} "${TEMP_SOURCE_PATH}" PARENT_SCOPE) endfunction() -- cgit v1.2.3 From c4caf29213f54b1786102c1b4dc085b6d7142998 Mon Sep 17 00:00:00 2001 From: Robert Schumacher Date: Mon, 30 Apr 2018 19:08:34 -0700 Subject: [vcpkg] Fix temporary download directory when vcpkg is located at the root of a drive --- scripts/VcpkgPowershellUtils.ps1 | 17 ++++++++++++++--- scripts/fetchTool.ps1 | 2 ++ 2 files changed, 16 insertions(+), 3 deletions(-) (limited to 'scripts') diff --git a/scripts/VcpkgPowershellUtils.ps1 b/scripts/VcpkgPowershellUtils.ps1 index fdd89e7b9..3ea18116b 100644 --- a/scripts/VcpkgPowershellUtils.ps1 +++ b/scripts/VcpkgPowershellUtils.ps1 @@ -89,7 +89,13 @@ function vcpkgGetSHA512([Parameter(Mandatory=$true)][string]$filePath) if (vcpkgHasCommand -commandName 'Microsoft.PowerShell.Utility\Get-FileHash') { Write-Verbose("Hashing with Microsoft.PowerShell.Utility\Get-FileHash") - $hash = (Microsoft.PowerShell.Utility\Get-FileHash -Path $filePath -Algorithm SHA512).Hash + $hashresult = Microsoft.PowerShell.Utility\Get-FileHash -Path $filePath -Algorithm SHA512 -ErrorVariable hashError + if ($hashError) + { + Start-Sleep 3 + $hashresult = Microsoft.PowerShell.Utility\Get-FileHash -Path $filePath -Algorithm SHA512 -ErrorVariable Stop + } + $hash = $hashresult.Hash } elseif(vcpkgHasCommand -commandName 'Pscx\Get-Hash') { @@ -177,7 +183,7 @@ function vcpkgDownloadFileWithAria2( [Parameter(Mandatory=$true)][string]$ari return } - $ec = vcpkgInvokeCommand "$aria2exe" "--dir `"$parentDir`" --out `"$filename.part`" $url" + $ec = vcpkgInvokeCommand "$aria2exe" "--dir=`"$parentDir`" --out=`"$filename.part`" $url" if ($ec -ne 0) { Write-Host "Could not download $url" @@ -202,7 +208,12 @@ function vcpkgExtractFileWith7z([Parameter(Mandatory=$true)][string]$sevenZipExe Write-Host "Could not extract $archivePath" throw } - Rename-Item -Path "$destinationPartial" -NewName $destinationDir + Rename-Item -Path "$destinationPartial" -NewName $destinationDir -ErrorVariable renameResult + if ($renameResult) + { + Start-Sleep 3 + Rename-Item -Path "$destinationPartial" -NewName $destinationDir -ErrorAction Stop + } } function vcpkgExtractZipFile( [Parameter(Mandatory=$true)][string]$archivePath, diff --git a/scripts/fetchTool.ps1 b/scripts/fetchTool.ps1 index dd3f0f9f4..eca405b62 100644 --- a/scripts/fetchTool.ps1 +++ b/scripts/fetchTool.ps1 @@ -4,6 +4,7 @@ param( ) Set-StrictMode -Version Latest + $scriptsDir = split-path -parent $script:MyInvocation.MyCommand.Definition . "$scriptsDir\VcpkgPowershellUtils.ps1" @@ -12,6 +13,7 @@ $vcpkgRootDir = vcpkgFindFileRecursivelyUp $scriptsDir .vcpkg-root $downloadsDir = "$vcpkgRootDir\downloads" vcpkgCreateDirectoryIfNotExists $downloadsDir +$downloadsDir = Resolve-Path $downloadsDir function fetchToolInternal([Parameter(Mandatory=$true)][string]$tool) { -- cgit v1.2.3 From ab58f531ccf6da9895502cb8ae7bd85b29823d1d Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Fri, 4 May 2018 18:14:54 -0700 Subject: git for linux/osx version moved to vcpkgTools.xml --- scripts/vcpkgTools.xml | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'scripts') diff --git a/scripts/vcpkgTools.xml b/scripts/vcpkgTools.xml index 1a2abae81..1f17102d2 100644 --- a/scripts/vcpkgTools.xml +++ b/scripts/vcpkgTools.xml @@ -28,6 +28,18 @@ a34575ab1b4f553e62535e38492904b512df4d6a837cf4abf205dbcdd05edf1eef450cc5b15a4f63f901424d5f3cd1f78b6b22437d0d4f8cd9ce4e42e82617b9 MinGit-2.17.0-32-bit.zip + + 2.7.4 + + + + + + 2.7.4 + + + + 2.4.1 vswhere.exe -- cgit v1.2.3 From 8ce92654856897d5da7649ecea5d28818f3bcadd Mon Sep 17 00:00:00 2001 From: Robert Schumacher Date: Tue, 15 May 2018 20:57:10 -0700 Subject: [bootstrap-vcpkg.sh] Find g++-8. Fixes #3486. --- scripts/bootstrap.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/bootstrap.sh b/scripts/bootstrap.sh index 037a9136d..8a4c92936 100644 --- a/scripts/bootstrap.sh +++ b/scripts/bootstrap.sh @@ -157,7 +157,9 @@ selectCXX() if [ "x$CXX" = "x" ]; then CXX=g++ - if which g++-7 >/dev/null 2>&1; then + if which g++-8 >/dev/null 2>&1; then + CXX=g++-8 + elif which g++-7 >/dev/null 2>&1; then CXX=g++-7 elif which g++-6 >/dev/null 2>&1; then CXX=g++-6 -- cgit v1.2.3 From 52f01eefa6e1da7a9458807a1eb3d288ecd50613 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Wed, 16 May 2018 04:48:26 +0000 Subject: [bootstrap.sh] Fix whitespace-in-path issues --- scripts/bootstrap.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/bootstrap.sh b/scripts/bootstrap.sh index 8a4c92936..e999fa55e 100644 --- a/scripts/bootstrap.sh +++ b/scripts/bootstrap.sh @@ -97,7 +97,7 @@ fetchTool() return 1 fi - xmlFileAsString=`cat $vcpkgRootDir/scripts/vcpkgTools.xml` + xmlFileAsString=`cat "$vcpkgRootDir/scripts/vcpkgTools.xml"` toolRegexStart="" toolData="$(extractStringBetweenDelimiters "$xmlFileAsString" "$toolRegexStart" "")" if [ "$toolData" = "" ]; then -- cgit v1.2.3 From 1b0682a39e1143660c3d5aa371f66591a64e8a5d Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Sat, 5 May 2018 04:23:19 -0700 Subject: [vcpkg] Significantly reduce usage of powershell. Reduce console font switching bug --- scripts/VcpkgPowershellUtils.ps1 | 322 +--------------------- scripts/addPoshVcpkgToPowershellProfile.ps1 | 7 +- scripts/bootstrap.ps1 | 108 ++++++-- scripts/fetchTool.ps1 | 109 -------- scripts/findAnyMSBuildWithCppPlatformToolset.ps1 | 58 ---- scripts/findVisualStudioInstallationInstances.ps1 | 61 ---- scripts/getProgramFiles32bit.ps1 | 17 -- scripts/getProgramFilesPlatformBitness.ps1 | 17 -- scripts/getVisualStudioInstances.ps1 | 74 +++++ scripts/vcpkgTools.xml | 15 +- 10 files changed, 174 insertions(+), 614 deletions(-) delete mode 100644 scripts/fetchTool.ps1 delete mode 100644 scripts/findAnyMSBuildWithCppPlatformToolset.ps1 delete mode 100644 scripts/findVisualStudioInstallationInstances.ps1 delete mode 100644 scripts/getProgramFiles32bit.ps1 delete mode 100644 scripts/getProgramFilesPlatformBitness.ps1 create mode 100644 scripts/getVisualStudioInstances.ps1 (limited to 'scripts') diff --git a/scripts/VcpkgPowershellUtils.ps1 b/scripts/VcpkgPowershellUtils.ps1 index 3ea18116b..259df4acb 100644 --- a/scripts/VcpkgPowershellUtils.ps1 +++ b/scripts/VcpkgPowershellUtils.ps1 @@ -1,8 +1,3 @@ -function vcpkgHasModule([Parameter(Mandatory=$true)][string]$moduleName) -{ - return [bool](Get-Module -ListAvailable -Name $moduleName) -} - function vcpkgHasProperty([Parameter(Mandatory=$true)][AllowNull()]$object, [Parameter(Mandatory=$true)]$propertyName) { if ($object -eq $null) @@ -10,320 +5,21 @@ function vcpkgHasProperty([Parameter(Mandatory=$true)][AllowNull()]$object, [Par return $false } - return [bool]($object.psobject.Properties | where { $_.Name -eq "$propertyName"}) -} - -function vcpkgCreateDirectoryIfNotExists([Parameter(Mandatory=$true)][string]$dirPath) -{ - if (!(Test-Path $dirPath)) - { - New-Item -ItemType Directory -Path $dirPath | Out-Null - } -} - -function vcpkgCreateParentDirectoryIfNotExists([Parameter(Mandatory=$true)][string]$path) -{ - $parentDir = split-path -parent $path - if ([string]::IsNullOrEmpty($parentDir)) - { - return - } - - if (!(Test-Path $parentDir)) - { - New-Item -ItemType Directory -Path $parentDir | Out-Null - } -} - -function vcpkgIsDirectory([Parameter(Mandatory=$true)][string]$path) -{ - return (Get-Item $path) -is [System.IO.DirectoryInfo] -} - -function vcpkgRemoveItem([Parameter(Mandatory=$true)][string]$path) -{ - if ([string]::IsNullOrEmpty($path)) - { - return - } - - if (Test-Path $path) - { - # Remove-Item -Recurse occasionally fails. This is a workaround - if (vcpkgIsDirectory $path) - { - & cmd.exe /c rd /s /q $path - } - else - { - Remove-Item $path -Force - } - } -} - -function vcpkgHasCommand([Parameter(Mandatory=$true)][string]$commandName) -{ - return [bool](Get-Command -Name $commandName -ErrorAction SilentlyContinue) -} - -function vcpkgHasCommandParameter([Parameter(Mandatory=$true)][string]$commandName, [Parameter(Mandatory=$true)][string]$parameterName) -{ - return (Get-Command $commandName).Parameters.Keys -contains $parameterName -} - -function vcpkgGetCredentials() -{ - if (vcpkgHasCommandParameter -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 - } -} - -function vcpkgGetSHA512([Parameter(Mandatory=$true)][string]$filePath) -{ - if (vcpkgHasCommand -commandName 'Microsoft.PowerShell.Utility\Get-FileHash') - { - Write-Verbose("Hashing with Microsoft.PowerShell.Utility\Get-FileHash") - $hashresult = Microsoft.PowerShell.Utility\Get-FileHash -Path $filePath -Algorithm SHA512 -ErrorVariable hashError - if ($hashError) - { - Start-Sleep 3 - $hashresult = Microsoft.PowerShell.Utility\Get-FileHash -Path $filePath -Algorithm SHA512 -ErrorVariable Stop - } - $hash = $hashresult.Hash - } - elseif(vcpkgHasCommand -commandName 'Pscx\Get-Hash') - { - Write-Verbose("Hashing with Pscx\Get-Hash") - $hash = (Pscx\Get-Hash -Path $filePath -Algorithm SHA512).HashString - } - else - { - Write-Verbose("Hashing with .NET") - $hashAlgorithm = [Security.Cryptography.HashAlgorithm]::Create("SHA512") - $fileAsByteArray = [io.File]::ReadAllBytes($filePath) - $hashByteArray = $hashAlgorithm.ComputeHash($fileAsByteArray) - $hash = -Join ($hashByteArray | ForEach-Object {"{0:x2}" -f $_}) - } - - return $hash.ToLower() + return [bool]($object.psobject.Properties | Where-Object { $_.Name -eq "$propertyName"}) } -function vcpkgCheckEqualFileHash( [Parameter(Mandatory=$true)][string]$url, - [Parameter(Mandatory=$true)][string]$filePath, - [Parameter(Mandatory=$true)][string]$expectedHash) +function getProgramFiles32bit() { - $actualHash = vcpkgGetSHA512 $filePath - if ($expectedHash -ne $actualHash) + $out = ${env:PROGRAMFILES(X86)} + if ($out -eq $null) { - Write-Host ("`nFile does not have expected hash:`n" + - " url: [ $url ]`n" + - " File path: [ $filePath ]`n" + - " Expected hash: [ $expectedHash ]`n" + - " Actual hash: [ $actualHash ]`n") - throw + $out = ${env:PROGRAMFILES} } -} -function vcpkgDownloadFile( [Parameter(Mandatory=$true)][string]$url, - [Parameter(Mandatory=$true)][string]$downloadPath, - [Parameter(Mandatory=$true)][string]$sha512) -{ - if ($url -match "github") + if ($out -eq $null) { - if ([System.Enum]::IsDefined([Net.SecurityProtocolType], "Tls12")) - { - [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 - } - else - { - Write-Warning "Github has dropped support for TLS versions prior to 1.2, which is not available on your system" - Write-Warning "Please manually download $url to $downloadPath" - Write-Warning "To solve this issue for future downloads, you can also install Windows Management Framework 5.1+" - throw "Download failed" - } + throw "Could not find [Program Files 32-bit]" } - vcpkgCreateParentDirectoryIfNotExists $downloadPath - - $downloadPartPath = "$downloadPath.part" - vcpkgRemoveItem $downloadPartPath - - $wc = New-Object System.Net.WebClient - if (!$wc.Proxy.IsBypassed($url)) - { - $wc.Proxy.Credentials = vcpkgGetCredentials - } - - $wc.DownloadFile($url, $downloadPartPath) - vcpkgCheckEqualFileHash -url $url -filePath $downloadPartPath -expectedHash $sha512 - Move-Item -Path $downloadPartPath -Destination $downloadPath -} - -function vcpkgDownloadFileWithAria2( [Parameter(Mandatory=$true)][string]$aria2exe, - [Parameter(Mandatory=$true)][string]$url, - [Parameter(Mandatory=$true)][string]$downloadPath, - [Parameter(Mandatory=$true)][string]$sha512) -{ - vcpkgCreateParentDirectoryIfNotExists $downloadPath - $downloadPartPath = "$downloadPath.part" - vcpkgRemoveItem $downloadPartPath - - $parentDir = split-path -parent $downloadPath - $filename = split-path -leaf $downloadPath - - if ((Test-Path $url) -or ($url.StartsWith("file://"))) # if is local file - { - vcpkgDownloadFile $url $downloadPath $sha512 - return - } - - $ec = vcpkgInvokeCommand "$aria2exe" "--dir=`"$parentDir`" --out=`"$filename.part`" $url" - if ($ec -ne 0) - { - Write-Host "Could not download $url" - throw - } - - vcpkgCheckEqualFileHash -url $url -filePath $downloadPartPath -expectedHash $sha512 - Move-Item -Path $downloadPartPath -Destination $downloadPath -} - -function vcpkgExtractFileWith7z([Parameter(Mandatory=$true)][string]$sevenZipExe, - [Parameter(Mandatory=$true)][string]$archivePath, - [Parameter(Mandatory=$true)][string]$destinationDir) -{ - vcpkgRemoveItem $destinationDir - $destinationPartial = "$destinationDir.partial" - vcpkgRemoveItem $destinationPartial - vcpkgCreateDirectoryIfNotExists $destinationPartial - $ec = vcpkgInvokeCommand "$sevenZipExe" "x `"$archivePath`" -o`"$destinationPartial`" -y" - if ($ec -ne 0) - { - Write-Host "Could not extract $archivePath" - throw - } - Rename-Item -Path "$destinationPartial" -NewName $destinationDir -ErrorVariable renameResult - if ($renameResult) - { - Start-Sleep 3 - Rename-Item -Path "$destinationPartial" -NewName $destinationDir -ErrorAction Stop - } -} - -function vcpkgExtractZipFile( [Parameter(Mandatory=$true)][string]$archivePath, - [Parameter(Mandatory=$true)][string]$destinationDir) -{ - vcpkgRemoveItem $destinationDir - $destinationPartial = "$destinationDir.partial" - vcpkgRemoveItem $destinationPartial - vcpkgCreateDirectoryIfNotExists $destinationPartial - - - if (vcpkgHasCommand -commandName 'Microsoft.PowerShell.Archive\Expand-Archive') - { - Write-Verbose("Extracting with Microsoft.PowerShell.Archive\Expand-Archive") - Microsoft.PowerShell.Archive\Expand-Archive -path $archivePath -destinationpath $destinationPartial - } - elseif (vcpkgHasCommand -commandName 'Pscx\Expand-Archive') - { - Write-Verbose("Extracting with Pscx\Expand-Archive") - Pscx\Expand-Archive -path $archivePath -OutputPath $destinationPartial - } - else - { - Write-Verbose("Extracting via shell") - $shell = new-object -com shell.application - $zip = $shell.NameSpace($(Get-Item $archivePath).fullname) - foreach($item in $zip.items()) - { - # Piping to Out-Null is used to block until finished - $shell.Namespace($destinationPartial).copyhere($item) | Out-Null - } - } - - Rename-Item -Path "$destinationPartial" -NewName $destinationDir -} - -function vcpkgInvokeCommand() -{ - param ( [Parameter(Mandatory=$true)][string]$executable, - [string]$arguments = "") - - Write-Verbose "Executing: ${executable} ${arguments}" - $process = Start-Process -FilePath "`"$executable`"" -ArgumentList $arguments -PassThru -NoNewWindow - Wait-Process -InputObject $process - $ec = $process.ExitCode - Write-Verbose "Execution terminated with exit code $ec." - return $ec -} - -function vcpkgInvokeCommandClean() -{ - param ( [Parameter(Mandatory=$true)][string]$executable, - [string]$arguments = "") - - Write-Verbose "Clean-Executing: ${executable} ${arguments}" - $scriptsDir = split-path -parent $script:MyInvocation.MyCommand.Definition - $cleanEnvScript = "$scriptsDir\VcpkgPowershellUtils-ClearEnvironment.ps1" - $tripleQuotes = "`"`"`"" - $argumentsWithEscapedQuotes = $arguments -replace "`"", $tripleQuotes - $command = ". $tripleQuotes$cleanEnvScript$tripleQuotes; & $tripleQuotes$executable$tripleQuotes $argumentsWithEscapedQuotes" - $arg = "-NoProfile", "-ExecutionPolicy Bypass", "-command $command" - - $process = Start-Process -FilePath powershell.exe -ArgumentList $arg -PassThru -NoNewWindow - Wait-Process -InputObject $process - $ec = $process.ExitCode - Write-Verbose "Execution terminated with exit code $ec." - return $ec -} - -function vcpkgFormatElapsedTime([TimeSpan]$ts) -{ - if ($ts.TotalHours -ge 1) - { - return [string]::Format( "{0:N2} h", $ts.TotalHours); - } - - if ($ts.TotalMinutes -ge 1) - { - return [string]::Format( "{0:N2} min", $ts.TotalMinutes); - } - - if ($ts.TotalSeconds -ge 1) - { - return [string]::Format( "{0:N2} s", $ts.TotalSeconds); - } - - if ($ts.TotalMilliseconds -ge 1) - { - return [string]::Format( "{0:N2} ms", $ts.TotalMilliseconds); - } - - throw $ts -} - -function vcpkgFindFileRecursivelyUp() -{ - param( - [ValidateNotNullOrEmpty()] - [Parameter(Mandatory=$true)][string]$startingDir, - [ValidateNotNullOrEmpty()] - [Parameter(Mandatory=$true)][string]$filename - ) - - $currentDir = $startingDir - - while (!($currentDir -eq "") -and !(Test-Path "$currentDir\$filename")) - { - Write-Verbose "Examining $currentDir for $filename" - $currentDir = Split-path $currentDir -Parent - } - Write-Verbose "Examining $currentDir for $filename - Found" - return $currentDir -} + return $out +} \ No newline at end of file diff --git a/scripts/addPoshVcpkgToPowershellProfile.ps1 b/scripts/addPoshVcpkgToPowershellProfile.ps1 index dcbd2e0be..5c13a8d4a 100644 --- a/scripts/addPoshVcpkgToPowershellProfile.ps1 +++ b/scripts/addPoshVcpkgToPowershellProfile.ps1 @@ -18,10 +18,10 @@ $scriptsDir = split-path -parent $script:MyInvocation.MyCommand.Definition $profileEntry = "Import-Module '$scriptsDir\posh-vcpkg'" $profilePath = $PROFILE # Implicit powershell variable -if (!(Test-Path $profilePath)) +$profileDir = Split-Path $profilePath -Parent +if (!(Test-Path $profileDir)) { - $profileDir = Split-Path $profilePath -Parent - vcpkgCreateDirectoryIfNotExists $profileDir + New-Item -ItemType Directory -Path $profileDir | Out-Null } Write-Host "`nAdding the following line to ${profilePath}:" @@ -38,6 +38,7 @@ if ($existingImports.Count -gt 0) return } +# Modifying the profile will invalidate any signatures. # Posh-git does the following check, so we should too. # https://github.com/dahlbyk/posh-git/blob/master/src/Utils.ps1 # If the profile script exists and is signed, then we should not modify it diff --git a/scripts/bootstrap.ps1 b/scripts/bootstrap.ps1 index c8ba503d8..41ba25746 100644 --- a/scripts/bootstrap.ps1 +++ b/scripts/bootstrap.ps1 @@ -5,35 +5,18 @@ param( ) Set-StrictMode -Version Latest $scriptsDir = split-path -parent $script:MyInvocation.MyCommand.Definition -. "$scriptsDir\VcpkgPowershellUtils.ps1" -$vcpkgRootDir = vcpkgFindFileRecursivelyUp $scriptsDir .vcpkg-root -Write-Verbose("vcpkg Path " + $vcpkgRootDir) -$gitHash = "unknownhash" -$oldpath = $env:path -try -{ - [xml]$asXml = Get-Content "$scriptsDir\vcpkgTools.xml" - $toolData = $asXml.SelectSingleNode("//tools/tool[@name=`"git`"]") - $gitFromDownload = "$vcpkgRootDir\downloads\$($toolData.exeRelativePath)" - $gitDir = split-path -parent $gitFromDownload +$vcpkgRootDir = $scriptsDir +$withVSPath = $withVSPath -replace "\\$" # Remove potential trailing backslash - $env:path += ";$gitDir" - if (Get-Command "git" -ErrorAction SilentlyContinue) - { - $gitHash = git log HEAD -n 1 --format="%cd-%H" --date=short - if ($LASTEXITCODE -ne 0) - { - $gitHash = "unknownhash" - } - } -} -finally +while (!($vcpkgRootDir -eq "") -and !(Test-Path "$vcpkgRootDir\.vcpkg-root")) { - $env:path = $oldpath + Write-Verbose "Examining $vcpkgRootDir for .vcpkg-root" + $vcpkgRootDir = Split-path $vcpkgRootDir -Parent } -Write-Verbose("Git repo version string is " + $gitHash) +Write-Verbose "Examining $vcpkgRootDir for .vcpkg-root - Found" +$gitHash = "nohash" $vcpkgSourcesPath = "$vcpkgRootDir\toolsrc" if (!(Test-Path $vcpkgSourcesPath)) @@ -42,7 +25,58 @@ if (!(Test-Path $vcpkgSourcesPath)) return } -$msbuildExeWithPlatformToolset = & $scriptsDir\findAnyMSBuildWithCppPlatformToolset.ps1 $withVSPath +function findAnyMSBuildWithCppPlatformToolset([string]$withVSPath) +{ + $VisualStudioInstances = & $scriptsDir\getVisualStudioInstances.ps1 + if ($VisualStudioInstances -eq $null) + { + throw "Could not find Visual Studio. VS2015 or VS2017 (with C++) needs to be installed." + } + + Write-Verbose "VS Candidates:`n`r$([system.String]::Join([Environment]::NewLine, $VisualStudioInstances))" + foreach ($instanceCandidateWithEOL in $VisualStudioInstances) + { + $instanceCandidate = $instanceCandidateWithEOL -replace "::" -replace "::" + Write-Verbose "Inspecting: $instanceCandidate" + $split = $instanceCandidate -split "::" + # $preferenceWeight = $split[0] + # $releaseType = $split[1] + $version = $split[2] + $path = $split[3] + + if ($withVSPath -ne "" -and $withVSPath -ne $path) + { + Write-Verbose "Skipping: $instanceCandidate" + continue + } + + $majorVersion = $version.Substring(0,2); + if ($majorVersion -eq "15") + { + $VCFolder= "$path\VC\Tools\MSVC\" + if (Test-Path $VCFolder) + { + Write-Verbose "Picking: $instanceCandidate" + return "$path\MSBuild\15.0\Bin\MSBuild.exe", "v141" + } + } + + if ($majorVersion -eq "14") + { + $clExe= "$path\VC\bin\cl.exe" + if (Test-Path $clExe) + { + Write-Verbose "Picking: $instanceCandidate" + $programFilesPath = getProgramFiles32bit + return "$programFilesPath\MSBuild\14.0\Bin\MSBuild.exe", "v140" + } + } + } + + throw "Could not find MSBuild version with C++ support. VS2015 or VS2017 (with C++) needs to be installed." +} + +$msbuildExeWithPlatformToolset = findAnyMSBuildWithCppPlatformToolset $withVSPath $msbuildExe = $msbuildExeWithPlatformToolset[0] $platformToolset = $msbuildExeWithPlatformToolset[1] $windowsSDK = & $scriptsDir\getWindowsSDK.ps1 @@ -54,10 +88,33 @@ $arguments = ( "/p:Platform=x86", "/p:PlatformToolset=$platformToolset", "/p:TargetPlatformVersion=$windowsSDK", +"/verbosity:minimal", "/m", +"/nologo", "`"$vcpkgSourcesPath\dirs.proj`"") -join " " +function vcpkgInvokeCommandClean() +{ + param ( [Parameter(Mandatory=$true)][string]$executable, + [string]$arguments = "") + + Write-Verbose "Clean-Executing: ${executable} ${arguments}" + $scriptsDir = split-path -parent $script:MyInvocation.MyCommand.Definition + $cleanEnvScript = "$scriptsDir\VcpkgPowershellUtils-ClearEnvironment.ps1" + $tripleQuotes = "`"`"`"" + $argumentsWithEscapedQuotes = $arguments -replace "`"", $tripleQuotes + $command = ". $tripleQuotes$cleanEnvScript$tripleQuotes; & $tripleQuotes$executable$tripleQuotes $argumentsWithEscapedQuotes" + $arg = "-NoProfile", "-ExecutionPolicy Bypass", "-command $command" + + $process = Start-Process -FilePath powershell.exe -ArgumentList $arg -PassThru -NoNewWindow + Wait-Process -InputObject $process + $ec = $process.ExitCode + Write-Verbose "Execution terminated with exit code $ec." + return $ec +} + # vcpkgInvokeCommandClean cmd "/c echo %PATH%" +Write-Host "`nBuilding vcpkg.exe ...`n" $ec = vcpkgInvokeCommandClean $msbuildExe $arguments if ($ec -ne 0) @@ -65,6 +122,7 @@ if ($ec -ne 0) Write-Error "Building vcpkg.exe failed. Please ensure you have installed Visual Studio with the Desktop C++ workload and the Windows SDK for Desktop C++." return } +Write-Host "`nBuilding vcpkg.exe... done.`n" Write-Verbose("Placing vcpkg.exe in the correct location") diff --git a/scripts/fetchTool.ps1 b/scripts/fetchTool.ps1 deleted file mode 100644 index eca405b62..000000000 --- a/scripts/fetchTool.ps1 +++ /dev/null @@ -1,109 +0,0 @@ -[CmdletBinding()] -param( - [Parameter(Mandatory=$true)][string]$tool -) - -Set-StrictMode -Version Latest - -$scriptsDir = split-path -parent $script:MyInvocation.MyCommand.Definition -. "$scriptsDir\VcpkgPowershellUtils.ps1" - -Write-Verbose "Fetching tool: $tool" -$vcpkgRootDir = vcpkgFindFileRecursivelyUp $scriptsDir .vcpkg-root - -$downloadsDir = "$vcpkgRootDir\downloads" -vcpkgCreateDirectoryIfNotExists $downloadsDir -$downloadsDir = Resolve-Path $downloadsDir - -function fetchToolInternal([Parameter(Mandatory=$true)][string]$tool) -{ - $tool = $tool.toLower() - - [xml]$asXml = Get-Content "$scriptsDir\vcpkgTools.xml" - $toolData = $asXml.SelectSingleNode("//tools/tool[@name=`"$tool`"]") # Case-sensitive! - - if ($toolData -eq $null) - { - throw "Unknown tool $tool" - } - - $toolPath="$downloadsDir\tools\$tool-$($toolData.version)-windows" - $exePath = "$toolPath\$($toolData.exeRelativePath)" - - if (Test-Path $exePath) - { - return $exePath - } - - $isArchive = vcpkgHasProperty -object $toolData -propertyName "archiveName" - if ($isArchive) - { - $downloadPath = "$downloadsDir\$($toolData.archiveName)" - } - else - { - $downloadPath = "$toolPath\$($toolData.exeRelativePath)" - } - - [String]$url = $toolData.url - if (!(Test-Path $downloadPath)) - { - Write-Host "Downloading $tool..." - - # Download aria2 with .NET. aria2 will be used to download everything else. - if ($tool -eq "aria2") - { - vcpkgDownloadFile $url $downloadPath $toolData.sha512 - } - else - { - $aria2exe = fetchToolInternal "aria2" - vcpkgDownloadFileWithAria2 $aria2exe $url $downloadPath $toolData.sha512 - } - - Write-Host "Downloading $tool... done." - } - else - { - vcpkgCheckEqualFileHash -url $url -filePath $downloadPath -expectedHash $toolData.sha512 - } - - if ($isArchive) - { - Write-Host "Extracting $tool..." - # Extract 7zip920 with shell because we need it to extract 7zip - # Extract aria2 with shell because we need it to download 7zip - if ($tool -eq "7zip920" -or $tool -eq "aria2") - { - vcpkgExtractZipFile -ArchivePath $downloadPath -DestinationDir $toolPath - } - elseif ($tool -eq "7zip") - { - $sevenZip920 = fetchToolInternal "7zip920" - $ec = vcpkgInvokeCommand "$sevenZip920" "x `"$downloadPath`" -o`"$toolPath`" -y" - if ($ec -ne 0) - { - Write-Host "Could not extract $downloadPath" - throw - } - } - else - { - $sevenZipExe = fetchToolInternal "7zip" - vcpkgExtractFileWith7z -sevenZipExe "$sevenZipExe" -ArchivePath $downloadPath -DestinationDir $toolPath - } - Write-Host "Extracting $tool... done." - } - - if (-not (Test-Path $exePath)) - { - Write-Error "Could not detect or download $tool" - throw - } - - return $exePath -} - -$path = fetchToolInternal $tool -Write-Verbose "Fetching tool: $tool. Done." -return "::$path::" diff --git a/scripts/findAnyMSBuildWithCppPlatformToolset.ps1 b/scripts/findAnyMSBuildWithCppPlatformToolset.ps1 deleted file mode 100644 index d7fd24e24..000000000 --- a/scripts/findAnyMSBuildWithCppPlatformToolset.ps1 +++ /dev/null @@ -1,58 +0,0 @@ -[CmdletBinding()] -param( - [Parameter(Mandatory=$False)] - [string]$withVSPath = "" -) - -Set-StrictMode -Version Latest -$scriptsDir = split-path -parent $script:MyInvocation.MyCommand.Definition - -$withVSPath = $withVSPath -replace "\\$" # Remove potential trailing backslash - -$VisualStudioInstallationInstances = & $scriptsDir\findVisualStudioInstallationInstances.ps1 -if ($VisualStudioInstallationInstances -eq $null) -{ - throw "Could not find Visual Studio. VS2015 or VS2017 (with C++) needs to be installed." -} - -Write-Verbose "VS Candidates:`n`r$([system.String]::Join([Environment]::NewLine, $VisualStudioInstallationInstances))" -foreach ($instanceCandidateWithEOL in $VisualStudioInstallationInstances) -{ - $instanceCandidate = $instanceCandidateWithEOL -replace "::" -replace "::" - Write-Verbose "Inspecting: $instanceCandidate" - $split = $instanceCandidate -split "::" - # $preferenceWeight = $split[0] - # $releaseType = $split[1] - $version = $split[2] - $path = $split[3] - - if ($withVSPath -ne "" -and $withVSPath -ne $path) - { - Write-Verbose "Skipping: $instanceCandidate" - continue - } - - $majorVersion = $version.Substring(0,2); - if ($majorVersion -eq "15") - { - $VCFolder= "$path\VC\Tools\MSVC\" - if (Test-Path $VCFolder) - { - Write-Verbose "Picking: $instanceCandidate" - return "$path\MSBuild\15.0\Bin\MSBuild.exe", "v141" - } - } - - if ($majorVersion -eq "14") - { - $clExe= "$path\VC\bin\cl.exe" - if (Test-Path $clExe) - { - Write-Verbose "Picking: $instanceCandidate" - $programFilesPath = & $scriptsDir\getProgramFiles32bit.ps1 - return "$programFilesPath\MSBuild\14.0\Bin\MSBuild.exe", "v140" - } - } -} - -throw "Could not find MSBuild version with C++ support. VS2015 or VS2017 (with C++) needs to be installed." \ No newline at end of file diff --git a/scripts/findVisualStudioInstallationInstances.ps1 b/scripts/findVisualStudioInstallationInstances.ps1 deleted file mode 100644 index cb51c345d..000000000 --- a/scripts/findVisualStudioInstallationInstances.ps1 +++ /dev/null @@ -1,61 +0,0 @@ -[CmdletBinding()] -param( - -) -Set-StrictMode -Version Latest -$scriptsDir = split-path -parent $script:MyInvocation.MyCommand.Definition -. "$scriptsDir\VcpkgPowershellUtils.ps1" - -$vswhereExe = (& $scriptsDir\fetchTool.ps1 "vswhere") -replace "::" -replace "::" - -$output = & $vswhereExe -prerelease -legacy -products * -format xml -[xml]$asXml = $output - -$results = New-Object System.Collections.ArrayList -foreach ($instance in $asXml.instances.instance) -{ - $installationPath = $instance.InstallationPath -replace "\\$" # Remove potential trailing backslash - $installationVersion = $instance.InstallationVersion - - $isPrerelease = -7 - if (vcpkgHasProperty -object $instance -propertyName "isPrerelease") - { - $isPrerelease = $instance.isPrerelease - } - - if ($isPrerelease -eq 0) - { - $releaseType = "PreferenceWeight3::StableRelease" - } - elseif ($isPrerelease -eq 1) - { - $releaseType = "PreferenceWeight2::PreRelease" - } - else - { - $releaseType = "PreferenceWeight1::Legacy" - } - - # Placed like that for easy sorting according to preference - $results.Add("::${releaseType}::${installationVersion}::${installationPath}::") > $null -} - -# If nothing is found, attempt to find VS2015 Build Tools (not detected by vswhere.exe) -if ($results.Count -eq 0) -{ - $programFiles = & $scriptsDir\getProgramFiles32bit.ps1 - $installationPath = "$programFiles\Microsoft Visual Studio 14.0" - $clExe = "$installationPath\VC\bin\cl.exe" - $vcvarsallbat = "$installationPath\VC\vcvarsall.bat" - - if ((Test-Path $clExe) -And (Test-Path $vcvarsallbat)) - { - return "::PreferenceWeight1::Legacy::14.0::$installationPath::" - } -} - - -$results.Sort() -$results.Reverse() - -return $results \ No newline at end of file diff --git a/scripts/getProgramFiles32bit.ps1 b/scripts/getProgramFiles32bit.ps1 deleted file mode 100644 index 6b71915b1..000000000 --- a/scripts/getProgramFiles32bit.ps1 +++ /dev/null @@ -1,17 +0,0 @@ -[CmdletBinding()] -param( - -) - -$out = ${env:PROGRAMFILES(X86)} -if ($out -eq $null) -{ - $out = ${env:PROGRAMFILES} -} - -if ($out -eq $null) -{ - throw "Could not find [Program Files 32-bit]" -} - -return $out \ No newline at end of file diff --git a/scripts/getProgramFilesPlatformBitness.ps1 b/scripts/getProgramFilesPlatformBitness.ps1 deleted file mode 100644 index 2be4c1137..000000000 --- a/scripts/getProgramFilesPlatformBitness.ps1 +++ /dev/null @@ -1,17 +0,0 @@ -[CmdletBinding()] -param( - -) - -$out = ${env:ProgramW6432} -if ($out -eq $null) -{ - $out = ${env:PROGRAMFILES} -} - -if ($out -eq $null) -{ - throw "Could not find [Program Files Platform Bitness]" -} - -return $out \ No newline at end of file diff --git a/scripts/getVisualStudioInstances.ps1 b/scripts/getVisualStudioInstances.ps1 new file mode 100644 index 000000000..83b0b8ebd --- /dev/null +++ b/scripts/getVisualStudioInstances.ps1 @@ -0,0 +1,74 @@ +[CmdletBinding()] +param( + +) +Set-StrictMode -Version Latest +$scriptsDir = split-path -parent $script:MyInvocation.MyCommand.Definition +. "$scriptsDir\VcpkgPowershellUtils.ps1" + +$programFiles = getProgramFiles32bit + +$results = New-Object System.Collections.ArrayList + +$vswhereExe = "$programFiles\Microsoft Visual Studio\Installer\vswhere.exe" + +if (Test-Path $vswhereExe) +{ + $output = & $vswhereExe -prerelease -legacy -products * -format xml + [xml]$asXml = $output + + foreach ($instance in $asXml.instances.instance) + { + $installationPath = $instance.InstallationPath -replace "\\$" # Remove potential trailing backslash + $installationVersion = $instance.InstallationVersion + + $isPrerelease = -7 + if (vcpkgHasProperty -object $instance -propertyName "isPrerelease") + { + $isPrerelease = $instance.isPrerelease + } + + if ($isPrerelease -eq 0) + { + $releaseType = "PreferenceWeight3::StableRelease" + } + elseif ($isPrerelease -eq 1) + { + $releaseType = "PreferenceWeight2::PreRelease" + } + else + { + $releaseType = "PreferenceWeight1::Legacy" + } + + # Placed like that for easy sorting according to preference + $results.Add("::${releaseType}::${installationVersion}::${installationPath}::") > $null + } +} +else +{ + Write-Verbose "Could not locate vswhere at $vswhereExe" +} + +$installationPath = Split-Path -Parent $(Split-Path -Parent "$env:vs140comntools") +$clExe = "$installationPath\VC\bin\cl.exe" +$vcvarsallbat = "$installationPath\VC\vcvarsall.bat" + +if ((Test-Path $clExe) -And (Test-Path $vcvarsallbat)) +{ + $results.Add("::PreferenceWeight1::Legacy::14.0::$installationPath::") > $null +} + +$installationPath = "$programFiles\Microsoft Visual Studio 14.0" +$clExe = "$installationPath\VC\bin\cl.exe" +$vcvarsallbat = "$installationPath\VC\vcvarsall.bat" + +if ((Test-Path $clExe) -And (Test-Path $vcvarsallbat)) +{ + $results.Add("::PreferenceWeight1::Legacy::14.0::$installationPath::") > $null +} + +$results.Sort() +$results.Reverse() + +return $results diff --git a/scripts/vcpkgTools.xml b/scripts/vcpkgTools.xml index 1f17102d2..9d5487577 100644 --- a/scripts/vcpkgTools.xml +++ b/scripts/vcpkgTools.xml @@ -61,17 +61,10 @@ 18.01.0 - 7za.exe - https://www.7-zip.org/a/7z1801-extra.7z - 9133fc551d76515e37fdd4dd8c1e28d464aea493548246b44565a42bba46715764f41f9cfa14d470d298c3a6e9829d200f8be5168cb67cf8f23d8042fca833bc - 7z1801-extra.7z - - - 9.20.0 - 7za.exe - https://www.7-zip.org/a/7za920.zip - 84e830c91a0e8ae499cc4814080da6569d8a6acbddc585c8b62abc86c809793aeb669b0a741063a379fd281ade85f120bc27efeb67d63bf961be893eec8bc3b3 - 7za920.zip + 7-Zip.CommandLine.18.1.0\tools\7za.exe + https://www.nuget.org/api/v2/package/7-Zip.CommandLine/18.1.0 + 8c75314102e68d2b2347d592f8e3eb05812e1ebb525decbac472231633753f1d4ca31c8e6881a36144a8da26b2571305b3ae3f4e2b85fc4a290aeda63d1a13b8 + 7-zip.commandline.18.1.0.nupkg 18.01.0 -- cgit v1.2.3 From f35ff4c8bc0fbe52a3c5c78f74f7c33e550b12e1 Mon Sep 17 00:00:00 2001 From: Arkady Shapkin Date: Wed, 16 May 2018 17:26:45 +0300 Subject: [openexr] Fix linux build --- scripts/toolchains/linux.cmake | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'scripts') diff --git a/scripts/toolchains/linux.cmake b/scripts/toolchains/linux.cmake index ea4f15d60..1ad180b4b 100644 --- a/scripts/toolchains/linux.cmake +++ b/scripts/toolchains/linux.cmake @@ -2,3 +2,17 @@ if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux") set(CMAKE_CROSSCOMPILING OFF CACHE BOOL "") endif() set(CMAKE_SYSTEM_NAME Linux CACHE STRING "") + +get_property( _CMAKE_IN_TRY_COMPILE GLOBAL PROPERTY IN_TRY_COMPILE ) +if(NOT _CMAKE_IN_TRY_COMPILE) + set(CMAKE_CXX_FLAGS " ${VCPKG_CXX_FLAGS}" CACHE STRING "") + set(CMAKE_C_FLAGS " ${VCPKG_C_FLAGS}" CACHE STRING "") + + set(CMAKE_CXX_FLAGS_DEBUG "${VCPKG_CXX_FLAGS_DEBUG}" CACHE STRING "") + set(CMAKE_C_FLAGS_DEBUG "${VCPKG_C_FLAGS_DEBUG}" CACHE STRING "") + set(CMAKE_CXX_FLAGS_RELEASE "${VCPKG_CXX_FLAGS_RELEASE}" CACHE STRING "") + set(CMAKE_C_FLAGS_RELEASE "${VCPKG_C_FLAGS_RELEASE}" CACHE STRING "") + + set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${VCPKG_LINKER_FLAGS}" CACHE STRING "") + set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${VCPKG_LINKER_FLAGS}" CACHE STRING "") +endif() -- cgit v1.2.3 From 8347101e63649dab2930bbc11dab39fa37c1e927 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Wed, 16 May 2018 14:51:17 -0700 Subject: [ps1] Add missing "include" --- scripts/bootstrap.ps1 | 1 + 1 file changed, 1 insertion(+) (limited to 'scripts') diff --git a/scripts/bootstrap.ps1 b/scripts/bootstrap.ps1 index 41ba25746..ed9491e2d 100644 --- a/scripts/bootstrap.ps1 +++ b/scripts/bootstrap.ps1 @@ -5,6 +5,7 @@ param( ) Set-StrictMode -Version Latest $scriptsDir = split-path -parent $script:MyInvocation.MyCommand.Definition +. "$scriptsDir\VcpkgPowershellUtils.ps1" $vcpkgRootDir = $scriptsDir $withVSPath = $withVSPath -replace "\\$" # Remove potential trailing backslash -- cgit v1.2.3 From 1e03300470b5235b3026ff94e585adef8f961785 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Wed, 16 May 2018 19:19:02 -0700 Subject: [ps1] Fix error when vs140comntools is not available --- scripts/getVisualStudioInstances.ps1 | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'scripts') diff --git a/scripts/getVisualStudioInstances.ps1 b/scripts/getVisualStudioInstances.ps1 index 83b0b8ebd..910d0f98b 100644 --- a/scripts/getVisualStudioInstances.ps1 +++ b/scripts/getVisualStudioInstances.ps1 @@ -50,13 +50,16 @@ else Write-Verbose "Could not locate vswhere at $vswhereExe" } -$installationPath = Split-Path -Parent $(Split-Path -Parent "$env:vs140comntools") -$clExe = "$installationPath\VC\bin\cl.exe" -$vcvarsallbat = "$installationPath\VC\vcvarsall.bat" - -if ((Test-Path $clExe) -And (Test-Path $vcvarsallbat)) +if ("$env:vs140comntools" -ne "") { - $results.Add("::PreferenceWeight1::Legacy::14.0::$installationPath::") > $null + $installationPath = Split-Path -Parent $(Split-Path -Parent "$env:vs140comntools") + $clExe = "$installationPath\VC\bin\cl.exe" + $vcvarsallbat = "$installationPath\VC\vcvarsall.bat" + + if ((Test-Path $clExe) -And (Test-Path $vcvarsallbat)) + { + $results.Add("::PreferenceWeight1::Legacy::14.0::$installationPath::") > $null + } } $installationPath = "$programFiles\Microsoft Visual Studio 14.0" -- cgit v1.2.3 From 658f1caaab56e7559eca17653bd9ca87a900f136 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Sat, 19 May 2018 17:27:30 -0700 Subject: [vcpkg_get_windows_sdk] Don't call powershell. Deduce from env --- scripts/cmake/vcpkg_get_windows_sdk.cmake | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'scripts') diff --git a/scripts/cmake/vcpkg_get_windows_sdk.cmake b/scripts/cmake/vcpkg_get_windows_sdk.cmake index a8aad64a9..e7d72a125 100644 --- a/scripts/cmake/vcpkg_get_windows_sdk.cmake +++ b/scripts/cmake/vcpkg_get_windows_sdk.cmake @@ -1,16 +1,6 @@ # Returns Windows SDK number via out variable "ret" function(vcpkg_get_windows_sdk ret) - execute_process( - COMMAND powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "& {& '${VCPKG_ROOT_DIR}/scripts/getWindowsSDK.ps1'}" 2>&1 - INPUT_FILE NUL - OUTPUT_VARIABLE WINDOWS_SDK - RESULT_VARIABLE error_code) - - if (error_code) - message(FATAL_ERROR "Could not find Windows SDK") - endif() - - # Remove trailing newline and non-numeric characters - string(REGEX REPLACE "[^0-9.]" "" WINDOWS_SDK "${WINDOWS_SDK}") + set(WINDOWS_SDK $ENV{WindowsSDKVersion}) + string(REPLACE "\\" "" WINDOWS_SDK "${WINDOWS_SDK}") set(${ret} ${WINDOWS_SDK} PARENT_SCOPE) endfunction() \ No newline at end of file -- cgit v1.2.3 From 9e4196d49524d41959e84f27b4080a0ec2cb37e6 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Sat, 19 May 2018 17:50:51 -0700 Subject: Merge getWindowsSDK into bootstrap.ps1 --- scripts/bootstrap.ps1 | 119 ++++++++++++++++++++++++++++++++++++++++++- scripts/getWindowsSDK.ps1 | 126 ---------------------------------------------- 2 files changed, 118 insertions(+), 127 deletions(-) delete mode 100644 scripts/getWindowsSDK.ps1 (limited to 'scripts') diff --git a/scripts/bootstrap.ps1 b/scripts/bootstrap.ps1 index ed9491e2d..970fa0488 100644 --- a/scripts/bootstrap.ps1 +++ b/scripts/bootstrap.ps1 @@ -76,11 +76,128 @@ function findAnyMSBuildWithCppPlatformToolset([string]$withVSPath) throw "Could not find MSBuild version with C++ support. VS2015 or VS2017 (with C++) needs to be installed." } +function getWindowsSDK( [Parameter(Mandatory=$False)][switch]$DisableWin10SDK = $False, + [Parameter(Mandatory=$False)][switch]$DisableWin81SDK = $False) +{ + if ($DisableWin10SDK -and $DisableWin81SDK) + { + throw "Both Win10SDK and Win81SDK were disabled." + } + + Write-Verbose "Finding WinSDK" + + $validInstances = New-Object System.Collections.ArrayList + + # Windows 10 SDK + function CheckWindows10SDK($path) + { + if ($path -eq $null) + { + return + } + + $folder = (Join-Path $path "Include") + if (!(Test-Path $folder)) + { + Write-Verbose "$folder - Not Found" + return + } + + Write-Verbose "$folder - Found" + $win10sdkVersions = @(Get-ChildItem $folder | Where-Object {$_.Name -match "^10"} | Sort-Object) + [array]::Reverse($win10sdkVersions) # Newest SDK first + + foreach ($win10sdkV in $win10sdkVersions) + { + $windowsheader = "$folder\$win10sdkV\um\windows.h" + if (!(Test-Path $windowsheader)) + { + Write-Verbose "$windowsheader - Not Found" + continue + } + Write-Verbose "$windowsheader - Found" + + $ddkheader = "$folder\$win10sdkV\shared\sdkddkver.h" + if (!(Test-Path $ddkheader)) + { + Write-Verbose "$ddkheader - Not Found" + continue + } + + Write-Verbose "$ddkheader - Found" + $win10sdkVersionString = $win10sdkV.ToString() + Write-Verbose "Found $win10sdkVersionString" + $validInstances.Add($win10sdkVersionString) > $null + } + } + + Write-Verbose "`n" + Write-Verbose "Looking for Windows 10 SDK" + $regkey10 = Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows Kits\Installed Roots\' -Name 'KitsRoot10' -ErrorAction SilentlyContinue + $regkey10Wow6432 = Get-ItemProperty -Path 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows Kits\Installed Roots\' -Name 'KitsRoot10' -ErrorAction SilentlyContinue + if (vcpkgHasProperty -object $regkey10 "KitsRoot10") { CheckWindows10SDK($regkey10.KitsRoot10) } + if (vcpkgHasProperty -object $regkey10Wow6432 "KitsRoot10") { CheckWindows10SDK($regkey10Wow6432.KitsRoot10) } + CheckWindows10SDK("$env:ProgramFiles\Windows Kits\10") + CheckWindows10SDK("${env:ProgramFiles(x86)}\Windows Kits\10") + + # Windows 8.1 SDK + function CheckWindows81SDK($path) + { + if ($path -eq $null) + { + return + } + + $folder = "$path\Include" + if (!(Test-Path $folder)) + { + Write-Verbose "$folder - Not Found" + return + } + + Write-Verbose "$folder - Found" + $win81sdkVersionString = "8.1" + Write-Verbose "Found $win81sdkVersionString" + $validInstances.Add($win81sdkVersionString) > $null + } + + Write-Verbose "`n" + Write-Verbose "Looking for Windows 8.1 SDK" + $regkey81 = Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows Kits\Installed Roots\' -Name 'KitsRoot81' -ErrorAction SilentlyContinue + $regkey81Wow6432 = Get-ItemProperty -Path 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows Kits\Installed Roots\' -Name 'KitsRoot81' -ErrorAction SilentlyContinue + if (vcpkgHasProperty -object $regkey81 "KitsRoot81") { CheckWindows81SDK($regkey81.KitsRoot81) } + if (vcpkgHasProperty -object $regkey81Wow6432 "KitsRoot81") { CheckWindows81SDK($regkey81Wow6432.KitsRoot81) } + CheckWindows81SDK("$env:ProgramFiles\Windows Kits\8.1") + CheckWindows81SDK("${env:ProgramFiles(x86)}\Windows Kits\8.1") + + Write-Verbose "`n`n`n" + Write-Verbose "The following Windows SDKs were found:" + foreach ($instance in $validInstances) + { + Write-Verbose $instance + } + + # Selecting + foreach ($instance in $validInstances) + { + if (!$DisableWin10SDK -and $instance -match "10.") + { + return $instance + } + + if (!$DisableWin81SDK -and $instance -match "8.1") + { + return $instance + } + } + + throw "Could not detect a Windows SDK / TargetPlatformVersion" +} $msbuildExeWithPlatformToolset = findAnyMSBuildWithCppPlatformToolset $withVSPath $msbuildExe = $msbuildExeWithPlatformToolset[0] $platformToolset = $msbuildExeWithPlatformToolset[1] -$windowsSDK = & $scriptsDir\getWindowsSDK.ps1 +$windowsSDK = getWindowsSDK $arguments = ( "`"/p:VCPKG_VERSION=-$gitHash`"", diff --git a/scripts/getWindowsSDK.ps1 b/scripts/getWindowsSDK.ps1 deleted file mode 100644 index d5e2f59a2..000000000 --- a/scripts/getWindowsSDK.ps1 +++ /dev/null @@ -1,126 +0,0 @@ -[CmdletBinding()] -param( - [Parameter(Mandatory=$False)] - [switch]$DisableWin10SDK = $False, - - [Parameter(Mandatory=$False)] - [switch]$DisableWin81SDK = $False -) - -Set-StrictMode -Version Latest -$scriptsDir = split-path -parent $script:MyInvocation.MyCommand.Definition -. "$scriptsDir\VcpkgPowershellUtils.ps1" - -if ($DisableWin10SDK -and $DisableWin81SDK) -{ - throw "Both Win10SDK and Win81SDK were disabled." -} - -Write-Verbose "Executing $($MyInvocation.MyCommand.Name)" - -$validInstances = New-Object System.Collections.ArrayList - -# Windows 10 SDK -function CheckWindows10SDK($path) -{ - if ($path -eq $null) - { - return - } - - $folder = (Join-Path $path "Include") - if (!(Test-Path $folder)) - { - Write-Verbose "$folder - Not Found" - return - } - - Write-Verbose "$folder - Found" - $win10sdkVersions = @(Get-ChildItem $folder | Where-Object {$_.Name -match "^10"} | Sort-Object) - [array]::Reverse($win10sdkVersions) # Newest SDK first - - foreach ($win10sdkV in $win10sdkVersions) - { - $windowsheader = "$folder\$win10sdkV\um\windows.h" - if (!(Test-Path $windowsheader)) - { - Write-Verbose "$windowsheader - Not Found" - continue - } - Write-Verbose "$windowsheader - Found" - - $ddkheader = "$folder\$win10sdkV\shared\sdkddkver.h" - if (!(Test-Path $ddkheader)) - { - Write-Verbose "$ddkheader - Not Found" - continue - } - - Write-Verbose "$ddkheader - Found" - $win10sdkVersionString = $win10sdkV.ToString() - Write-Verbose "Found $win10sdkVersionString" - $validInstances.Add($win10sdkVersionString) > $null - } -} - -Write-Verbose "`n" -Write-Verbose "Looking for Windows 10 SDK" -$regkey10 = Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows Kits\Installed Roots\' -Name 'KitsRoot10' -ErrorAction SilentlyContinue -$regkey10Wow6432 = Get-ItemProperty -Path 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows Kits\Installed Roots\' -Name 'KitsRoot10' -ErrorAction SilentlyContinue -if (vcpkgHasProperty -object $regkey10 "KitsRoot10") { CheckWindows10SDK($regkey10.KitsRoot10) } -if (vcpkgHasProperty -object $regkey10Wow6432 "KitsRoot10") { CheckWindows10SDK($regkey10Wow6432.KitsRoot10) } -CheckWindows10SDK("$env:ProgramFiles\Windows Kits\10") -CheckWindows10SDK("${env:ProgramFiles(x86)}\Windows Kits\10") - -# Windows 8.1 SDK -function CheckWindows81SDK($path) -{ - if ($path -eq $null) - { - return - } - - $folder = "$path\Include" - if (!(Test-Path $folder)) - { - Write-Verbose "$folder - Not Found" - return - } - - Write-Verbose "$folder - Found" - $win81sdkVersionString = "8.1" - Write-Verbose "Found $win81sdkVersionString" - $validInstances.Add($win81sdkVersionString) > $null -} - -Write-Verbose "`n" -Write-Verbose "Looking for Windows 8.1 SDK" -$regkey81 = Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows Kits\Installed Roots\' -Name 'KitsRoot81' -ErrorAction SilentlyContinue -$regkey81Wow6432 = Get-ItemProperty -Path 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows Kits\Installed Roots\' -Name 'KitsRoot81' -ErrorAction SilentlyContinue -if (vcpkgHasProperty -object $regkey81 "KitsRoot81") { CheckWindows81SDK($regkey81.KitsRoot81) } -if (vcpkgHasProperty -object $regkey81Wow6432 "KitsRoot81") { CheckWindows81SDK($regkey81Wow6432.KitsRoot81) } -CheckWindows81SDK("$env:ProgramFiles\Windows Kits\8.1") -CheckWindows81SDK("${env:ProgramFiles(x86)}\Windows Kits\8.1") - -Write-Verbose "`n`n`n" -Write-Verbose "The following Windows SDKs were found:" -foreach ($instance in $validInstances) -{ - Write-Verbose $instance -} - -# Selecting -foreach ($instance in $validInstances) -{ - if (!$DisableWin10SDK -and $instance -match "10.") - { - return $instance - } - - if (!$DisableWin81SDK -and $instance -match "8.1") - { - return $instance - } -} - -throw "Could not detect a Windows SDK / TargetPlatformVersion" -- cgit v1.2.3 From 555fa8d7cc25f409fea9626383dfc38c5d5db6b4 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Sat, 19 May 2018 17:54:12 -0700 Subject: Merge getVisualStudioInstances into bootstrap.ps1 --- scripts/bootstrap.ps1 | 72 ++++++++++++++++++++++++++++++++- scripts/getVisualStudioInstances.ps1 | 77 ------------------------------------ 2 files changed, 71 insertions(+), 78 deletions(-) delete mode 100644 scripts/getVisualStudioInstances.ps1 (limited to 'scripts') diff --git a/scripts/bootstrap.ps1 b/scripts/bootstrap.ps1 index 970fa0488..a2d9103dd 100644 --- a/scripts/bootstrap.ps1 +++ b/scripts/bootstrap.ps1 @@ -26,9 +26,79 @@ if (!(Test-Path $vcpkgSourcesPath)) return } +function getVisualStudioInstances() +{ + $programFiles = getProgramFiles32bit + $results = New-Object System.Collections.ArrayList + $vswhereExe = "$programFiles\Microsoft Visual Studio\Installer\vswhere.exe" + if (Test-Path $vswhereExe) + { + $output = & $vswhereExe -prerelease -legacy -products * -format xml + [xml]$asXml = $output + + foreach ($instance in $asXml.instances.instance) + { + $installationPath = $instance.InstallationPath -replace "\\$" # Remove potential trailing backslash + $installationVersion = $instance.InstallationVersion + + $isPrerelease = -7 + if (vcpkgHasProperty -object $instance -propertyName "isPrerelease") + { + $isPrerelease = $instance.isPrerelease + } + + if ($isPrerelease -eq 0) + { + $releaseType = "PreferenceWeight3::StableRelease" + } + elseif ($isPrerelease -eq 1) + { + $releaseType = "PreferenceWeight2::PreRelease" + } + else + { + $releaseType = "PreferenceWeight1::Legacy" + } + + # Placed like that for easy sorting according to preference + $results.Add("::${releaseType}::${installationVersion}::${installationPath}::") > $null + } + } + else + { + Write-Verbose "Could not locate vswhere at $vswhereExe" + } + + if ("$env:vs140comntools" -ne "") + { + $installationPath = Split-Path -Parent $(Split-Path -Parent "$env:vs140comntools") + $clExe = "$installationPath\VC\bin\cl.exe" + $vcvarsallbat = "$installationPath\VC\vcvarsall.bat" + + if ((Test-Path $clExe) -And (Test-Path $vcvarsallbat)) + { + $results.Add("::PreferenceWeight1::Legacy::14.0::$installationPath::") > $null + } + } + + $installationPath = "$programFiles\Microsoft Visual Studio 14.0" + $clExe = "$installationPath\VC\bin\cl.exe" + $vcvarsallbat = "$installationPath\VC\vcvarsall.bat" + + if ((Test-Path $clExe) -And (Test-Path $vcvarsallbat)) + { + $results.Add("::PreferenceWeight1::Legacy::14.0::$installationPath::") > $null + } + + $results.Sort() + $results.Reverse() + + return $results +} + function findAnyMSBuildWithCppPlatformToolset([string]$withVSPath) { - $VisualStudioInstances = & $scriptsDir\getVisualStudioInstances.ps1 + $VisualStudioInstances = getVisualStudioInstances if ($VisualStudioInstances -eq $null) { throw "Could not find Visual Studio. VS2015 or VS2017 (with C++) needs to be installed." diff --git a/scripts/getVisualStudioInstances.ps1 b/scripts/getVisualStudioInstances.ps1 deleted file mode 100644 index 910d0f98b..000000000 --- a/scripts/getVisualStudioInstances.ps1 +++ /dev/null @@ -1,77 +0,0 @@ -[CmdletBinding()] -param( - -) -Set-StrictMode -Version Latest -$scriptsDir = split-path -parent $script:MyInvocation.MyCommand.Definition -. "$scriptsDir\VcpkgPowershellUtils.ps1" - -$programFiles = getProgramFiles32bit - -$results = New-Object System.Collections.ArrayList - -$vswhereExe = "$programFiles\Microsoft Visual Studio\Installer\vswhere.exe" - -if (Test-Path $vswhereExe) -{ - $output = & $vswhereExe -prerelease -legacy -products * -format xml - [xml]$asXml = $output - - foreach ($instance in $asXml.instances.instance) - { - $installationPath = $instance.InstallationPath -replace "\\$" # Remove potential trailing backslash - $installationVersion = $instance.InstallationVersion - - $isPrerelease = -7 - if (vcpkgHasProperty -object $instance -propertyName "isPrerelease") - { - $isPrerelease = $instance.isPrerelease - } - - if ($isPrerelease -eq 0) - { - $releaseType = "PreferenceWeight3::StableRelease" - } - elseif ($isPrerelease -eq 1) - { - $releaseType = "PreferenceWeight2::PreRelease" - } - else - { - $releaseType = "PreferenceWeight1::Legacy" - } - - # Placed like that for easy sorting according to preference - $results.Add("::${releaseType}::${installationVersion}::${installationPath}::") > $null - } -} -else -{ - Write-Verbose "Could not locate vswhere at $vswhereExe" -} - -if ("$env:vs140comntools" -ne "") -{ - $installationPath = Split-Path -Parent $(Split-Path -Parent "$env:vs140comntools") - $clExe = "$installationPath\VC\bin\cl.exe" - $vcvarsallbat = "$installationPath\VC\vcvarsall.bat" - - if ((Test-Path $clExe) -And (Test-Path $vcvarsallbat)) - { - $results.Add("::PreferenceWeight1::Legacy::14.0::$installationPath::") > $null - } -} - -$installationPath = "$programFiles\Microsoft Visual Studio 14.0" -$clExe = "$installationPath\VC\bin\cl.exe" -$vcvarsallbat = "$installationPath\VC\vcvarsall.bat" - -if ((Test-Path $clExe) -And (Test-Path $vcvarsallbat)) -{ - $results.Add("::PreferenceWeight1::Legacy::14.0::$installationPath::") > $null -} - -$results.Sort() -$results.Reverse() - -return $results -- cgit v1.2.3 From a739df905c129eb13d7060419a78f5a693974b63 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Sat, 19 May 2018 17:54:50 -0700 Subject: Merge VcpkgPowershellUtils into bootstrap.ps1 --- scripts/VcpkgPowershellUtils.ps1 | 25 ------------------------- scripts/bootstrap.ps1 | 27 +++++++++++++++++++++++++-- 2 files changed, 25 insertions(+), 27 deletions(-) delete mode 100644 scripts/VcpkgPowershellUtils.ps1 (limited to 'scripts') diff --git a/scripts/VcpkgPowershellUtils.ps1 b/scripts/VcpkgPowershellUtils.ps1 deleted file mode 100644 index 259df4acb..000000000 --- a/scripts/VcpkgPowershellUtils.ps1 +++ /dev/null @@ -1,25 +0,0 @@ -function vcpkgHasProperty([Parameter(Mandatory=$true)][AllowNull()]$object, [Parameter(Mandatory=$true)]$propertyName) -{ - if ($object -eq $null) - { - return $false - } - - return [bool]($object.psobject.Properties | Where-Object { $_.Name -eq "$propertyName"}) -} - -function getProgramFiles32bit() -{ - $out = ${env:PROGRAMFILES(X86)} - if ($out -eq $null) - { - $out = ${env:PROGRAMFILES} - } - - if ($out -eq $null) - { - throw "Could not find [Program Files 32-bit]" - } - - return $out -} \ No newline at end of file diff --git a/scripts/bootstrap.ps1 b/scripts/bootstrap.ps1 index a2d9103dd..09c138bb3 100644 --- a/scripts/bootstrap.ps1 +++ b/scripts/bootstrap.ps1 @@ -5,10 +5,33 @@ param( ) Set-StrictMode -Version Latest $scriptsDir = split-path -parent $script:MyInvocation.MyCommand.Definition -. "$scriptsDir\VcpkgPowershellUtils.ps1" - $vcpkgRootDir = $scriptsDir $withVSPath = $withVSPath -replace "\\$" # Remove potential trailing backslash +function vcpkgHasProperty([Parameter(Mandatory=$true)][AllowNull()]$object, [Parameter(Mandatory=$true)]$propertyName) +{ + if ($object -eq $null) + { + return $false + } + + return [bool]($object.psobject.Properties | Where-Object { $_.Name -eq "$propertyName"}) +} + +function getProgramFiles32bit() +{ + $out = ${env:PROGRAMFILES(X86)} + if ($out -eq $null) + { + $out = ${env:PROGRAMFILES} + } + + if ($out -eq $null) + { + throw "Could not find [Program Files 32-bit]" + } + + return $out +} while (!($vcpkgRootDir -eq "") -and !(Test-Path "$vcpkgRootDir\.vcpkg-root")) { -- cgit v1.2.3 From 8549a095a8707c2aa38e9ee1642bef2cf0a90d81 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Sat, 19 May 2018 17:55:15 -0700 Subject: Remove stray entries --- scripts/addPoshVcpkgToPowershellProfile.ps1 | 1 - 1 file changed, 1 deletion(-) (limited to 'scripts') diff --git a/scripts/addPoshVcpkgToPowershellProfile.ps1 b/scripts/addPoshVcpkgToPowershellProfile.ps1 index 5c13a8d4a..1dd27aacf 100644 --- a/scripts/addPoshVcpkgToPowershellProfile.ps1 +++ b/scripts/addPoshVcpkgToPowershellProfile.ps1 @@ -14,7 +14,6 @@ function findExistingImportModuleDirectives([Parameter(Mandatory=$true)][string] } $scriptsDir = split-path -parent $script:MyInvocation.MyCommand.Definition -. "$scriptsDir\VcpkgPowershellUtils.ps1" $profileEntry = "Import-Module '$scriptsDir\posh-vcpkg'" $profilePath = $PROFILE # Implicit powershell variable -- cgit v1.2.3 From bc96c069aced70a51a04a5e009f7c7931c488028 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Sat, 19 May 2018 18:07:09 -0700 Subject: [bootstrap.ps1] Remove unneeded it was used for communication with vcpkg --- scripts/bootstrap.ps1 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'scripts') diff --git a/scripts/bootstrap.ps1 b/scripts/bootstrap.ps1 index 09c138bb3..0427ce2ba 100644 --- a/scripts/bootstrap.ps1 +++ b/scripts/bootstrap.ps1 @@ -7,6 +7,7 @@ Set-StrictMode -Version Latest $scriptsDir = split-path -parent $script:MyInvocation.MyCommand.Definition $vcpkgRootDir = $scriptsDir $withVSPath = $withVSPath -replace "\\$" # Remove potential trailing backslash + function vcpkgHasProperty([Parameter(Mandatory=$true)][AllowNull()]$object, [Parameter(Mandatory=$true)]$propertyName) { if ($object -eq $null) @@ -84,7 +85,7 @@ function getVisualStudioInstances() } # Placed like that for easy sorting according to preference - $results.Add("::${releaseType}::${installationVersion}::${installationPath}::") > $null + $results.Add("${releaseType}::${installationVersion}::${installationPath}") > $null } } else @@ -100,7 +101,7 @@ function getVisualStudioInstances() if ((Test-Path $clExe) -And (Test-Path $vcvarsallbat)) { - $results.Add("::PreferenceWeight1::Legacy::14.0::$installationPath::") > $null + $results.Add("PreferenceWeight1::Legacy::14.0::$installationPath") > $null } } @@ -110,7 +111,7 @@ function getVisualStudioInstances() if ((Test-Path $clExe) -And (Test-Path $vcvarsallbat)) { - $results.Add("::PreferenceWeight1::Legacy::14.0::$installationPath::") > $null + $results.Add("PreferenceWeight1::Legacy::14.0::$installationPath") > $null } $results.Sort() @@ -128,9 +129,8 @@ function findAnyMSBuildWithCppPlatformToolset([string]$withVSPath) } Write-Verbose "VS Candidates:`n`r$([system.String]::Join([Environment]::NewLine, $VisualStudioInstances))" - foreach ($instanceCandidateWithEOL in $VisualStudioInstances) + foreach ($instanceCandidate in $VisualStudioInstances) { - $instanceCandidate = $instanceCandidateWithEOL -replace "::" -replace "::" Write-Verbose "Inspecting: $instanceCandidate" $split = $instanceCandidate -split "::" # $preferenceWeight = $split[0] -- cgit v1.2.3 From f1653a23d5a4a1f4ce8b4d034594526a649de0d1 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Sat, 19 May 2018 18:08:10 -0700 Subject: Inline variable --- scripts/bootstrap.ps1 | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/bootstrap.ps1 b/scripts/bootstrap.ps1 index 0427ce2ba..43cf96c56 100644 --- a/scripts/bootstrap.ps1 +++ b/scripts/bootstrap.ps1 @@ -41,7 +41,6 @@ while (!($vcpkgRootDir -eq "") -and !(Test-Path "$vcpkgRootDir\.vcpkg-root")) } Write-Verbose "Examining $vcpkgRootDir for .vcpkg-root - Found" -$gitHash = "nohash" $vcpkgSourcesPath = "$vcpkgRootDir\toolsrc" if (!(Test-Path $vcpkgSourcesPath)) @@ -293,7 +292,7 @@ $platformToolset = $msbuildExeWithPlatformToolset[1] $windowsSDK = getWindowsSDK $arguments = ( -"`"/p:VCPKG_VERSION=-$gitHash`"", +"`"/p:VCPKG_VERSION=-nohash`"", "`"/p:DISABLE_METRICS=$disableMetrics`"", "/p:Configuration=Release", "/p:Platform=x86", -- cgit v1.2.3 From 3fc199dc52c4c6152ee83e95474a18bb076549e5 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Sat, 19 May 2018 18:23:05 -0700 Subject: Remove unused internalCI.ps1 --- scripts/internalCI.ps1 | 22 ---------------------- 1 file changed, 22 deletions(-) delete mode 100644 scripts/internalCI.ps1 (limited to 'scripts') diff --git a/scripts/internalCI.ps1 b/scripts/internalCI.ps1 deleted file mode 100644 index 9529c3766..000000000 --- a/scripts/internalCI.ps1 +++ /dev/null @@ -1,22 +0,0 @@ -$ErrorActionPreference = "Stop" - -rm TEST-internal-ci.xml -errorAction SilentlyContinue - -New-Item -type directory downloads -errorAction SilentlyContinue | Out-Null -./scripts/bootstrap.ps1 -if (-not $?) { throw $? } - -# Clear out any intermediate files from the previous build -if (Test-Path buildtrees) -{ - Get-ChildItem buildtrees/*/* | ? { $_.Name -ne "src" } | Remove-Item -Recurse -Force -} - -# Purge any outdated packages -./vcpkg remove --outdated --recurse -if (-not $?) { throw $? } - -./vcpkg.exe install azure-storage-cpp cpprestsdk:x64-windows-static cpprestsdk:x86-uwp ` -bond cryptopp zlib expat sdl2 curl sqlite3 libuv protobuf:x64-windows sfml opencv:x64-windows uwebsockets uwebsockets:x64-windows-static ` -opencv:x86-uwp boost:x86-uwp --keep-going "--x-xunit=TEST-internal-ci.xml" --recurse -if (-not $?) { throw $? } -- cgit v1.2.3 From 6ccd43dfa7bedbfe9323e13085a476cca5d616d5 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Sat, 19 May 2018 18:24:50 -0700 Subject: Rename ps1 file --- scripts/VcpkgPowershellUtils-ClearEnvironment.ps1 | 52 ----------------------- scripts/bootstrap.ps1 | 2 +- scripts/cleanEnvironmentHelper.ps1 | 52 +++++++++++++++++++++++ 3 files changed, 53 insertions(+), 53 deletions(-) delete mode 100644 scripts/VcpkgPowershellUtils-ClearEnvironment.ps1 create mode 100644 scripts/cleanEnvironmentHelper.ps1 (limited to 'scripts') diff --git a/scripts/VcpkgPowershellUtils-ClearEnvironment.ps1 b/scripts/VcpkgPowershellUtils-ClearEnvironment.ps1 deleted file mode 100644 index 0a133f5f8..000000000 --- a/scripts/VcpkgPowershellUtils-ClearEnvironment.ps1 +++ /dev/null @@ -1,52 +0,0 @@ -# Capture environment variables for the System and User. Also add some special/built-in variables. -# These will be used to synthesize a clean environment -$specialEnvironmentMap = @{ "SystemDrive"=$env:SystemDrive; "SystemRoot"=$env:SystemRoot; "UserProfile"=$env:UserProfile } # These are built-in and not set in the registry -$machineEnvironmentMap = [Environment]::GetEnvironmentVariables('Machine') # HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment -$userEnvironmentMap = [Environment]::GetEnvironmentVariables('User') # HKEY_CURRENT_USER\Environment - -# Identify the keySet of environment variable names -$nameSet = ($specialEnvironmentMap.Keys + $machineEnvironmentMap.Keys + $userEnvironmentMap.Keys) | Sort-Object | Select-Object -Unique - -# Any environment variable in the $nameSet should be restored to its original value -foreach ($name in $nameSet) -{ - if ($specialEnvironmentMap.ContainsKey($name)) - { - [Environment]::SetEnvironmentVariable($name, $specialEnvironmentMap[$name], 'Process') - continue; - } - - # PATH needs to be concatenated as it has values in both machine and user environment. Any other values should be set. - if ($name -match 'path') - { - $pathValuePartial = @() - # Machine values before user values - $pathValuePartial += $machineEnvironmentMap[$name] -split ';' - $pathValuePartial += $userEnvironmentMap[$name] -split ';' - $pathValue = $pathValuePartial -join ';' - [Environment]::SetEnvironmentVariable($name, $pathValue, 'Process') - continue; - } - - if ($userEnvironmentMap.ContainsKey($name)) - { - [Environment]::SetEnvironmentVariable($name, $userEnvironmentMap[$name], 'Process') - continue; - } - - if ($machineEnvironmentMap.ContainsKey($name)) - { - [Environment]::SetEnvironmentVariable($name, $machineEnvironmentMap[$name], 'Process') - continue; - } - - throw "Unreachable: Unknown variable $name" -} - -# Any environment variable NOT in the $nameSet should be removed -$processEnvironmentMap = [Environment]::GetEnvironmentVariables('Process') -$variablesForRemoval = $processEnvironmentMap.Keys | Where-Object {$nameSet -notcontains $_} -foreach ($name in $variablesForRemoval) -{ - [Environment]::SetEnvironmentVariable($name, $null, 'Process') -} diff --git a/scripts/bootstrap.ps1 b/scripts/bootstrap.ps1 index 43cf96c56..c37ffd57f 100644 --- a/scripts/bootstrap.ps1 +++ b/scripts/bootstrap.ps1 @@ -310,7 +310,7 @@ function vcpkgInvokeCommandClean() Write-Verbose "Clean-Executing: ${executable} ${arguments}" $scriptsDir = split-path -parent $script:MyInvocation.MyCommand.Definition - $cleanEnvScript = "$scriptsDir\VcpkgPowershellUtils-ClearEnvironment.ps1" + $cleanEnvScript = "$scriptsDir\cleanEnvironmentHelper.ps1" $tripleQuotes = "`"`"`"" $argumentsWithEscapedQuotes = $arguments -replace "`"", $tripleQuotes $command = ". $tripleQuotes$cleanEnvScript$tripleQuotes; & $tripleQuotes$executable$tripleQuotes $argumentsWithEscapedQuotes" diff --git a/scripts/cleanEnvironmentHelper.ps1 b/scripts/cleanEnvironmentHelper.ps1 new file mode 100644 index 000000000..0a133f5f8 --- /dev/null +++ b/scripts/cleanEnvironmentHelper.ps1 @@ -0,0 +1,52 @@ +# Capture environment variables for the System and User. Also add some special/built-in variables. +# These will be used to synthesize a clean environment +$specialEnvironmentMap = @{ "SystemDrive"=$env:SystemDrive; "SystemRoot"=$env:SystemRoot; "UserProfile"=$env:UserProfile } # These are built-in and not set in the registry +$machineEnvironmentMap = [Environment]::GetEnvironmentVariables('Machine') # HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment +$userEnvironmentMap = [Environment]::GetEnvironmentVariables('User') # HKEY_CURRENT_USER\Environment + +# Identify the keySet of environment variable names +$nameSet = ($specialEnvironmentMap.Keys + $machineEnvironmentMap.Keys + $userEnvironmentMap.Keys) | Sort-Object | Select-Object -Unique + +# Any environment variable in the $nameSet should be restored to its original value +foreach ($name in $nameSet) +{ + if ($specialEnvironmentMap.ContainsKey($name)) + { + [Environment]::SetEnvironmentVariable($name, $specialEnvironmentMap[$name], 'Process') + continue; + } + + # PATH needs to be concatenated as it has values in both machine and user environment. Any other values should be set. + if ($name -match 'path') + { + $pathValuePartial = @() + # Machine values before user values + $pathValuePartial += $machineEnvironmentMap[$name] -split ';' + $pathValuePartial += $userEnvironmentMap[$name] -split ';' + $pathValue = $pathValuePartial -join ';' + [Environment]::SetEnvironmentVariable($name, $pathValue, 'Process') + continue; + } + + if ($userEnvironmentMap.ContainsKey($name)) + { + [Environment]::SetEnvironmentVariable($name, $userEnvironmentMap[$name], 'Process') + continue; + } + + if ($machineEnvironmentMap.ContainsKey($name)) + { + [Environment]::SetEnvironmentVariable($name, $machineEnvironmentMap[$name], 'Process') + continue; + } + + throw "Unreachable: Unknown variable $name" +} + +# Any environment variable NOT in the $nameSet should be removed +$processEnvironmentMap = [Environment]::GetEnvironmentVariables('Process') +$variablesForRemoval = $processEnvironmentMap.Keys | Where-Object {$nameSet -notcontains $_} +foreach ($name in $variablesForRemoval) +{ + [Environment]::SetEnvironmentVariable($name, $null, 'Process') +} -- cgit v1.2.3 From 7932abed8d10b59f6a448c71349667dded004106 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Sat, 19 May 2018 19:38:45 -0700 Subject: [ps1] Move variable close to where it is set --- scripts/bootstrap.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/bootstrap.ps1 b/scripts/bootstrap.ps1 index c37ffd57f..149134dff 100644 --- a/scripts/bootstrap.ps1 +++ b/scripts/bootstrap.ps1 @@ -5,7 +5,6 @@ param( ) Set-StrictMode -Version Latest $scriptsDir = split-path -parent $script:MyInvocation.MyCommand.Definition -$vcpkgRootDir = $scriptsDir $withVSPath = $withVSPath -replace "\\$" # Remove potential trailing backslash function vcpkgHasProperty([Parameter(Mandatory=$true)][AllowNull()]$object, [Parameter(Mandatory=$true)]$propertyName) @@ -34,6 +33,7 @@ function getProgramFiles32bit() return $out } +$vcpkgRootDir = $scriptsDir while (!($vcpkgRootDir -eq "") -and !(Test-Path "$vcpkgRootDir\.vcpkg-root")) { Write-Verbose "Examining $vcpkgRootDir for .vcpkg-root" -- cgit v1.2.3