diff options
| author | flysha <flysha@live.com> | 2017-01-25 10:01:57 +0800 |
|---|---|---|
| committer | flysha <flysha@live.com> | 2017-01-25 10:01:57 +0800 |
| commit | 033c7d0af6a5f5129e73ebb63b1abea0db128da6 (patch) | |
| tree | f0998507be51a02b1b9fa1e4e3836b95fe826ab8 /scripts | |
| parent | ce9741f71b079dad944e177daf984160bb9ce1bb (diff) | |
| parent | a4bcf67010a438a554696988e17f1066be629dba (diff) | |
| download | vcpkg-033c7d0af6a5f5129e73ebb63b1abea0db128da6.tar.gz vcpkg-033c7d0af6a5f5129e73ebb63b1abea0db128da6.zip | |
Merge remote-tracking branch 'refs/remotes/origin/master'
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/bootstrap.ps1 | 5 | ||||
| -rw-r--r-- | scripts/buildsystems/msbuild/applocal.ps1 | 9 | ||||
| -rw-r--r-- | scripts/buildsystems/msbuild/vcpkg.targets | 6 | ||||
| -rw-r--r-- | scripts/cmake/vcpkg_configure_cmake.cmake | 27 | ||||
| -rw-r--r-- | scripts/fetchDependency.ps1 | 59 | ||||
| -rw-r--r-- | scripts/findAnyMSBuildWithCppPlatformToolset.ps1 | 32 | ||||
| -rw-r--r-- | scripts/findVisualStudioInstallationInstances.ps1 | 40 |
7 files changed, 141 insertions, 37 deletions
diff --git a/scripts/bootstrap.ps1 b/scripts/bootstrap.ps1 index bcb570b39..a37ed99aa 100644 --- a/scripts/bootstrap.ps1 +++ b/scripts/bootstrap.ps1 @@ -23,7 +23,10 @@ if (!(Test-Path $vcpkgSourcesPath)) try{ pushd $vcpkgSourcesPath - cmd /c "$env:VS140COMNTOOLS..\..\VC\vcvarsall.bat" x86 "&" msbuild "/p:VCPKG_VERSION=-$gitHash" "/p:DISABLE_METRICS=$disableMetrics" /p:Configuration=Release /p:Platform=x86 /m + $msbuildExeWithPlatformToolset = & $scriptsDir\findAnyMSBuildWithCppPlatformToolset.ps1 + $msbuildExe = $msbuildExeWithPlatformToolset[0] + $platformToolset = $msbuildExeWithPlatformToolset[1] + & $msbuildExe "/p:VCPKG_VERSION=-$gitHash" "/p:DISABLE_METRICS=$disableMetrics" /p:Configuration=Release /p:Platform=x86 /p:PlatformToolset=$platformToolset /m Write-Verbose("Placing vcpkg.exe in the correct location") diff --git a/scripts/buildsystems/msbuild/applocal.ps1 b/scripts/buildsystems/msbuild/applocal.ps1 index 46981fad5..55680c1f6 100644 --- a/scripts/buildsystems/msbuild/applocal.ps1 +++ b/scripts/buildsystems/msbuild/applocal.ps1 @@ -2,7 +2,14 @@ param([string]$targetBinary, [string]$installedDir, [string]$tlogFile) function resolve($targetBinary) { - $targetBinaryPath = Resolve-Path $targetBinary + try + { + $targetBinaryPath = Resolve-Path $targetBinary -erroraction stop + } + catch [System.Management.Automation.ItemNotFoundException] + { + return + } $targetBinaryDir = Split-Path $targetBinaryPath -parent $a = $(dumpbin /DEPENDENTS $targetBinary | ? { $_ -match "^ [^ ].*\.dll" } | % { $_ -replace "^ ","" }) diff --git a/scripts/buildsystems/msbuild/vcpkg.targets b/scripts/buildsystems/msbuild/vcpkg.targets index 912cf6b8e..26a524ca3 100644 --- a/scripts/buildsystems/msbuild/vcpkg.targets +++ b/scripts/buildsystems/msbuild/vcpkg.targets @@ -57,12 +57,14 @@ Lines="^$(OutputPath)$(TargetName).$(OutputType);" Encoding="Unicode"/> <Exec Condition="'$(VcpkgConfiguration)' == 'Debug'" Command="powershell.exe -ExecutionPolicy Unrestricted -noprofile -File %22$(MSBuildThisFileDirectory)applocal.ps1%22 %22$(TargetPath)%22 %22$(VcpkgRoot)debug\bin%22 %22$(TLogLocation)$(ProjectName).write.1u.tlog%22" - ConsoleToMSBuild="true"> + ConsoleToMSBuild="true" + StandardOutputImportance="Normal"> <Output TaskParameter="ConsoleOutput" ItemName="ReferenceCopyLocalPaths" /> </Exec> <Exec Condition="'$(VcpkgConfiguration)' == 'Release'" Command="powershell.exe -ExecutionPolicy Unrestricted -noprofile -File %22$(MSBuildThisFileDirectory)applocal.ps1%22 %22$(TargetPath)%22 %22$(VcpkgRoot)bin%22 %22$(TLogLocation)$(ProjectName).write.1u.tlog%22" - ConsoleToMSBuild="true"> + ConsoleToMSBuild="true" + StandardOutputImportance="Normal"> <Output TaskParameter="ConsoleOutput" ItemName="ReferenceCopyLocalPaths" /> </Exec> </Target> diff --git a/scripts/cmake/vcpkg_configure_cmake.cmake b/scripts/cmake/vcpkg_configure_cmake.cmake index 179703172..128782075 100644 --- a/scripts/cmake/vcpkg_configure_cmake.cmake +++ b/scripts/cmake/vcpkg_configure_cmake.cmake @@ -4,20 +4,33 @@ function(vcpkg_configure_cmake) if(_csc_GENERATOR) set(GENERATOR ${_csc_GENERATOR}) - elseif(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" AND TRIPLET_SYSTEM_ARCH MATCHES "x86") + elseif(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" AND TRIPLET_SYSTEM_ARCH MATCHES "x86" AND VCPKG_PLATFORM_TOOLSET MATCHES "v140") set(GENERATOR "Visual Studio 14 2015") - elseif(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" AND TRIPLET_SYSTEM_ARCH MATCHES "x64") + elseif(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" AND TRIPLET_SYSTEM_ARCH MATCHES "x64" AND VCPKG_PLATFORM_TOOLSET MATCHES "v140") set(GENERATOR "Visual Studio 14 2015 Win64") - elseif(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" AND TRIPLET_SYSTEM_ARCH MATCHES "arm") + elseif(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" AND TRIPLET_SYSTEM_ARCH MATCHES "arm" AND VCPKG_PLATFORM_TOOLSET MATCHES "v140") set(GENERATOR "Visual Studio 14 2015 ARM") # elseif(NOT vcpkg_configure_cmake_NINJA MATCHES "NOTFOUND") # set(GENERATOR "Ninja") - elseif(TRIPLET_SYSTEM_ARCH MATCHES "x86") + elseif(TRIPLET_SYSTEM_ARCH MATCHES "x86" AND VCPKG_PLATFORM_TOOLSET MATCHES "v140") set(GENERATOR "Visual Studio 14 2015") - elseif(TRIPLET_SYSTEM_ARCH MATCHES "x64") + elseif(TRIPLET_SYSTEM_ARCH MATCHES "x64" AND VCPKG_PLATFORM_TOOLSET MATCHES "v140") set(GENERATOR "Visual Studio 14 2015 Win64") elseif(TRIPLET_SYSTEM_ARCH MATCHES "arm") - set(GENERATOR "Visual Studio 14 2015 ARM") + set(GENERATOR "Visual Studio 14 2015 ARM" AND VCPKG_PLATFORM_TOOLSET MATCHES "v140") + + elseif(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" AND TRIPLET_SYSTEM_ARCH MATCHES "x86" AND VCPKG_PLATFORM_TOOLSET MATCHES "v141") + set(GENERATOR "Visual Studio 15 2017") + elseif(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" AND TRIPLET_SYSTEM_ARCH MATCHES "x64" AND VCPKG_PLATFORM_TOOLSET MATCHES "v141") + set(GENERATOR "Visual Studio 15 2017 Win64") + elseif(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" AND TRIPLET_SYSTEM_ARCH MATCHES "arm" AND VCPKG_PLATFORM_TOOLSET MATCHES "v141") + set(GENERATOR "Visual Studio 15 2017 ARM") + elseif(TRIPLET_SYSTEM_ARCH MATCHES "x86" AND VCPKG_PLATFORM_TOOLSET MATCHES "v141") + set(GENERATOR "Visual Studio 15 2017") + elseif(TRIPLET_SYSTEM_ARCH MATCHES "x64" AND VCPKG_PLATFORM_TOOLSET MATCHES "v141") + set(GENERATOR "Visual Studio 15 2017 Win64") + elseif(TRIPLET_SYSTEM_ARCH MATCHES "arm") + set(GENERATOR "Visual Studio 15 2017 ARM" AND VCPKG_PLATFORM_TOOLSET MATCHES "v141") endif() file(REMOVE_RECURSE ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg) @@ -33,7 +46,7 @@ function(vcpkg_configure_cmake) elseif(DEFINED VCPKG_LIBRARY_LINKAGE AND VCPKG_LIBRARY_LINKAGE STREQUAL static) list(APPEND _csc_OPTIONS -DBUILD_SHARED_LIBS=OFF) endif() - + list(APPEND _csc_OPTIONS "-DCMAKE_CXX_FLAGS= /DWIN32 /D_WINDOWS /W3 /utf-8 /GR /EHsc" diff --git a/scripts/fetchDependency.ps1 b/scripts/fetchDependency.ps1 index 2f3d992ba..b56bf1087 100644 --- a/scripts/fetchDependency.ps1 +++ b/scripts/fetchDependency.ps1 @@ -51,12 +51,12 @@ function SelectProgram([Parameter(Mandatory=$true)][string]$Dependency) { return } - + $title = "Download " + $Dependency $message = ("No suitable version of " + $Dependency + " was found (requires $requiredVersion or higher). Download portable version?") $yesDescription = "Downloads " + $Dependency + " v" + $downloadVersion +" app-locally." - $noDescription = "Does not download " + $Dependency + "." - + $noDescription = "Does not download " + $Dependency + "." + $userAllowedDownload = promptForDownload $title $message $yesDescription $noDescription if (!$userAllowedDownload) { @@ -86,10 +86,10 @@ function SelectProgram([Parameter(Mandatory=$true)][string]$Dependency) $ExtractionType_NO_EXTRACTION_REQUIRED = 0 $ExtractionType_ZIP = 1 $ExtractionType_SELF_EXTRACTING_7Z = 2 - - + + # Using this to wait for the execution to finish - function Invoke-Command() + function Invoke-Command() { param ( [string]$program = $(throw "Please specify a program" ), [string]$argumentString = "", @@ -99,7 +99,7 @@ function SelectProgram([Parameter(Mandatory=$true)][string]$Dependency) $psi.FileName = $program $psi.Arguments = $argumentString $proc = [Diagnostics.Process]::Start($psi) - if ( $waitForExit ) + if ( $waitForExit ) { $proc.WaitForExit(); } @@ -120,33 +120,33 @@ function SelectProgram([Parameter(Mandatory=$true)][string]$Dependency) if($Dependency -eq "cmake") { - $requiredVersion = "3.5.0" - $downloadVersion = "3.5.2" - $url = "https://cmake.org/files/v3.5/cmake-3.5.2-win32-x86.zip" - $downloadName = "cmake-3.5.2-win32-x86.zip" - $expectedDownloadedFileHash = "671073aee66b3480a564d0736792e40570a11e861bb34819bb7ae7858bbdfb80" - $executableFromDownload = "$downloadsDir\cmake-3.5.2-win32-x86\bin\cmake.exe" + $requiredVersion = "3.7.2" + $downloadVersion = "3.7.2" + $url = "https://cmake.org/files/v3.7/cmake-3.7.2-win32-x86.zip" + $downloadPath = "$downloadsDir\cmake-3.7.2-win32-x86.zip" + $expectedDownloadedFileHash = "ec5e299d412e0272e01d4de5bf07718f42c96361f83d51cc39f91bf49cc3e5c3" + $executableFromDownload = "$downloadsDir\cmake-3.7.2-win32-x86\bin\cmake.exe" $extractionType = $ExtractionType_ZIP } elseif($Dependency -eq "nuget") { - $requiredVersion = "1.0.0" - $downloadVersion = "3.4.3" - $url = "https://dist.nuget.org/win-x86-commandline/v3.4.3/nuget.exe" - $downloadName = "nuget.exe" - $expectedDownloadedFileHash = "3B1EA72943968D7AF6BACDB4F2F3A048A25AFD14564EF1D8B1C041FDB09EBB0A" - $executableFromDownload = "$downloadsDir\nuget.exe" + $requiredVersion = "3.3.0" + $downloadVersion = "3.5.0" + $url = "https://dist.nuget.org/win-x86-commandline/v3.5.0/nuget.exe" + $downloadPath = "$downloadsDir\nuget-3.5.0\nuget.exe" + $expectedDownloadedFileHash = "399ec24c26ed54d6887cde61994bb3d1cada7956c1b19ff880f06f060c039918" + $executableFromDownload = $downloadPath $extractionType = $ExtractionType_NO_EXTRACTION_REQUIRED } elseif($Dependency -eq "git") { $requiredVersion = "2.0.0" - $downloadVersion = "2.8.3" - $url = "https://github.com/git-for-windows/git/releases/download/v2.8.3.windows.1/PortableGit-2.8.3-32-bit.7z.exe" # We choose the 32-bit version - $downloadName = "PortableGit-2.8.3-32-bit.7z.exe" - $expectedDownloadedFileHash = "DE52D070219E9C4EC1DB179F2ADBF4B760686C3180608F0382A1F8C7031E72AD" + $downloadVersion = "2.11.0" + $url = "https://github.com/git-for-windows/git/releases/download/v2.11.0.windows.3/PortableGit-2.11.0.3-32-bit.7z.exe" # We choose the 32-bit version + $downloadPath = "$downloadsDir\PortableGit-2.11.0.3-32-bit.7z.exe" + $expectedDownloadedFileHash = "8bf3769c37945e991903dd1b988c6b1d97bbf0f3afc9851508974f38bf94dc01" # There is another copy of git.exe in PortableGit\bin. However, an installed version of git add the cmd dir to the PATH. - # Therefore, choosing the cmd dir here as well. + # Therefore, choosing the cmd dir here as well. $executableFromDownload = "$downloadsDir\PortableGit\cmd\git.exe" $extractionType = $ExtractionType_SELF_EXTRACTING_7Z } @@ -155,7 +155,12 @@ function SelectProgram([Parameter(Mandatory=$true)][string]$Dependency) throw "Unknown program requested" } - $downloadPath = "$downloadsDir\$downloadName" + $downloadSubdir = Split-path $downloadPath -Parent + if (!(Test-Path $downloadSubdir)) + { + New-Item -ItemType Directory -Path $downloadSubdir | Out-Null + } + performDownload $Dependency $url $downloadsDir $downloadPath $downloadVersion $requiredVersion #calculating the hash @@ -186,7 +191,7 @@ function SelectProgram([Parameter(Mandatory=$true)][string]$Dependency) if (-not (Test-Path $executableFromDownload)) { Invoke-Command $downloadPath "-y" -waitForExit:$true - } + } } else { @@ -197,6 +202,8 @@ function SelectProgram([Parameter(Mandatory=$true)][string]$Dependency) { throw [System.IO.FileNotFoundException] ("Could not detect or download " + $Dependency) } + + return $downloadPath } SelectProgram $Dependency
\ No newline at end of file diff --git a/scripts/findAnyMSBuildWithCppPlatformToolset.ps1 b/scripts/findAnyMSBuildWithCppPlatformToolset.ps1 new file mode 100644 index 000000000..1be4a4e6d --- /dev/null +++ b/scripts/findAnyMSBuildWithCppPlatformToolset.ps1 @@ -0,0 +1,32 @@ +[CmdletBinding()] +param( + +) + +$scriptsDir = split-path -parent $MyInvocation.MyCommand.Definition + +# VS2017 +$VisualStudio2017InstallationInstances = & $scriptsDir\findVisualStudioInstallationInstances.ps1 +foreach ($instance in $VisualStudio2017InstallationInstances) +{ + $VCFolder= "$instance\VC\Tools\MSVC\" + + if (Test-Path $VCFolder) + { + return "$instance\MSBuild\15.0\Bin\MSBuild.exe","v141" + } +} + +# VS2015 +$CandidateProgramFiles = "${env:PROGRAMFILES(X86)}", "${env:PROGRAMFILES}" +foreach ($ProgramFiles in $CandidateProgramFiles) +{ + $clExe= "$ProgramFiles\Microsoft Visual Studio 14.0\\VC\bin\cl.exe" + + if (Test-Path $clExe) + { + return "$ProgramFiles\MSBuild\14.0\Bin\MSBuild.exe","v140" + } +} + +throw "Could not find MSBuild with C++ support. VS2015 or above with C++ support need to be installed."
\ No newline at end of file diff --git a/scripts/findVisualStudioInstallationInstances.ps1 b/scripts/findVisualStudioInstallationInstances.ps1 new file mode 100644 index 000000000..d5faa57d3 --- /dev/null +++ b/scripts/findVisualStudioInstallationInstances.ps1 @@ -0,0 +1,40 @@ +[CmdletBinding()] +param( + +) + +Import-Module BitsTransfer + +$scriptsDir = split-path -parent $MyInvocation.MyCommand.Definition +$vcpkgRootDir = & $scriptsDir\findFileRecursivelyUp.ps1 $scriptsDir .vcpkg-root + +$downloadsDir = "$vcpkgRootDir\downloads" + +$nugetexe = & $scriptsDir\fetchDependency.ps1 "nuget" +$nugetPackageDir = "$downloadsDir\nuget-packages" + +$SetupAPIVersion = "1.3.269-rc" +$url = "https://api.nuget.org/packages/microsoft.visualstudio.setup.configuration.native.$SetupAPIVersion.nupkg" +$downloadName = "microsoft.visualstudio.setup.configuration.native.$SetupAPIVersion.nupkg" +$downloadPath = "$downloadsDir\$downloadName" + +if (!(Test-Path $downloadPath)) +{ + Start-BitsTransfer -Source $url -Destination $downloadPath #-ErrorAction SilentlyContinue +} + +$nugetOutput = & $nugetexe install Microsoft.VisualStudio.Setup.Configuration.Native -Pre -Source $downloadsDir -OutputDirectory $nugetPackageDir 2>&1 + +$SetupConsoleExe = "$nugetPackageDir\Microsoft.VisualStudio.Setup.Configuration.Native.$SetupAPIVersion\tools\x86\Microsoft.VisualStudio.Setup.Configuration.Console.exe" + +if (!(Test-Path $SetupConsoleExe)) +{ + throw $nugetOutput +} + +$consoleOutput = & $SetupConsoleExe 2>&1 + +$key = "InstallationPath = " +$paths = $consoleOutput | Select-String -SimpleMatch $key +$paths = $paths -replace $key, "" +return $paths
\ No newline at end of file |
