aboutsummaryrefslogtreecommitdiff
path: root/scripts/bootstrap.ps1
blob: 1821551463cfd2cc0cbb16302fec9f759b7c2128 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
[CmdletBinding()]
param(
    [ValidateNotNullOrEmpty()]
    [string]$disableMetrics = "0"
)

$scriptsDir = split-path -parent $MyInvocation.MyCommand.Definition
$vcpkgRootDir = & $scriptsDir\findFileRecursivelyUp.ps1 $scriptsDir .vcpkg-root

$gitHash = git rev-parse HEAD
Write-Verbose("Git hash is " + $gitHash)
$gitStartOfHash = $gitHash.substring(0,6)
$vcpkgSourcesPath = "$vcpkgRootDir\toolsrc"
Write-Verbose("vcpkg Path " + $vcpkgSourcesPath)

if (!(Test-Path $vcpkgSourcesPath))
{
    New-Item -ItemType directory -Path $vcpkgSourcesPath -force | Out-Null
}

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

    Write-Verbose("Placing vcpkg.exe in the correct location")

    Copy-Item $vcpkgSourcesPath\Release\vcpkg.exe $vcpkgRootDir\vcpkg.exe | Out-Null
    Copy-Item $vcpkgSourcesPath\Release\vcpkgmetricsuploader.exe $vcpkgRootDir\scripts\vcpkgmetricsuploader.exe | Out-Null
}
finally{
    popd
}