Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions scripts/bootstrap.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,16 @@ Write-Verbose "Examining $vcpkgRootDir for .vcpkg-root - Found"
$Config = ConvertFrom-StringData (Get-Content "$PSScriptRoot\vcpkg-tool-metadata.txt" -Raw)
$versionDate = $Config.VCPKG_TOOL_RELEASE_TAG

if ($null -eq $env:X_VCPKG_BINARY_DIR) {
$vcpkgBinaryDir=$vcpkgRootDir
} else {
$vcpkgBinaryDir="$env:X_VCPKG_BINARY_DIR"
}

if ($env:PROCESSOR_ARCHITECTURE -eq 'ARM64' -or $env:PROCESSOR_IDENTIFIER -match "ARMv[8,9] \(64-bit\)") {
& "$scriptsDir/tls12-download-arm64.exe" github.com "/microsoft/vcpkg-tool/releases/download/$versionDate/vcpkg-arm64.exe" "$vcpkgRootDir\vcpkg.exe"
& "$scriptsDir/tls12-download-arm64.exe" github.com "/microsoft/vcpkg-tool/releases/download/$versionDate/vcpkg-arm64.exe" "$vcpkgBinaryDir\vcpkg.exe"
} else {
& "$scriptsDir/tls12-download.exe" github.com "/microsoft/vcpkg-tool/releases/download/$versionDate/vcpkg.exe" "$vcpkgRootDir\vcpkg.exe"
& "$scriptsDir/tls12-download.exe" github.com "/microsoft/vcpkg-tool/releases/download/$versionDate/vcpkg.exe" "$vcpkgBinaryDir\vcpkg.exe"
}

Write-Host ""
Expand All @@ -63,13 +69,13 @@ if ($LASTEXITCODE -ne 0)
throw
}

& "$vcpkgRootDir\vcpkg.exe" version --disable-metrics
& "$vcpkgBinaryDir\vcpkg.exe" version --disable-metrics

if ($disableMetrics)
{
Set-Content -Value "" -Path "$vcpkgRootDir\vcpkg.disable-metrics" -Force
Set-Content -Value "" -Path "$vcpkgBinaryDir\vcpkg.disable-metrics" -Force
}
elseif (-Not (Test-Path "$vcpkgRootDir\vcpkg.disable-metrics"))
elseif (-Not (Test-Path "$vcpkgBinaryDir\vcpkg.disable-metrics"))
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

# Note that we intentionally leave any existing vcpkg.disable-metrics; once a user has
# opted out they should stay opted out.
Expand Down
27 changes: 19 additions & 8 deletions scripts/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,20 @@ if [ "$unixKernelName" = CYGWIN_NT ] || [ "$unixKernelName" = MINGW_NT ] || [ "$
exit 0
fi

# Determine base dir to store the vcpkg executable
if [ -z ${X_VCPKG_BINARY_DIR+x} ]; then
binaryDir="$vcpkgRootDir"
else
binaryDir="$X_VCPKG_BINARY_DIR"
if [ ! -d "$X_VCPKG_BINARY_DIR" ]; then
echo "X_VCPKG_BINARY_DIR was set to '$X_VCPKG_BINARY_DIR', but that was not a directory."
exit 1
fi
fi

# Determine the downloads directory.
if [ -z ${VCPKG_DOWNLOADS+x} ]; then
downloadsDir="$vcpkgRootDir/downloads"
downloadsDir="$binaryDir/downloads"
else
downloadsDir="$VCPKG_DOWNLOADS"
if [ ! -d "$VCPKG_DOWNLOADS" ]; then
Expand Down Expand Up @@ -209,11 +220,11 @@ fi

# Do the download or build.
if [ "$vcpkgDownloadTool" = "ON" ]; then
vcpkgDownloadFile "https://github.com/microsoft/vcpkg-tool/releases/download/$VCPKG_TOOL_RELEASE_TAG/$vcpkgToolName" "$vcpkgRootDir/vcpkg" $vcpkgToolReleaseSha
vcpkgDownloadFile "https://github.com/microsoft/vcpkg-tool/releases/download/$VCPKG_TOOL_RELEASE_TAG/$vcpkgToolName" "$binaryDir/vcpkg" $vcpkgToolReleaseSha
else
vcpkgToolReleaseArchive="$VCPKG_TOOL_RELEASE_TAG.zip"
vcpkgToolUrl="https://github.com/microsoft/vcpkg-tool/archive/$vcpkgToolReleaseArchive"
baseBuildDir="$vcpkgRootDir/buildtrees/_vcpkg"
baseBuildDir="$binaryDir/buildtrees/_vcpkg"
buildDir="$baseBuildDir/build"
archivePath="$downloadsDir/$vcpkgToolReleaseArchive"
srcBaseDir="$baseBuildDir/src"
Expand All @@ -239,16 +250,16 @@ else
(cd "$buildDir" && eval cmake "$srcDir" $cmakeConfigOptions) || exit 1
(cd "$buildDir" && cmake --build .) || exit 1

rm -rf "$vcpkgRootDir/vcpkg"
cp "$buildDir/vcpkg" "$vcpkgRootDir/"
rm -rf "$binaryDir/vcpkg"
cp "$buildDir/vcpkg" "$binaryDir/"
fi

"$vcpkgRootDir/vcpkg" version --disable-metrics
"$binaryDir/vcpkg" version --disable-metrics

# Apply the disable-metrics marker file.
if [ "$vcpkgDisableMetrics" = "ON" ]; then
touch "$vcpkgRootDir/vcpkg.disable-metrics"
elif ! [ -f "$vcpkgRootDir/vcpkg.disable-metrics" ]; then
touch "$binaryDir/vcpkg.disable-metrics"
elif ! [ -f "$binaryDir/vcpkg.disable-metrics" ]; then
# Note that we intentionally leave any existing vcpkg.disable-metrics; once a user has
# opted out they should stay opted out.
cat <<EOF
Expand Down
10 changes: 8 additions & 2 deletions scripts/buildsystems/vcpkg.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -463,12 +463,18 @@ endif()

set(VCPKG_CMAKE_FIND_ROOT_PATH "${CMAKE_FIND_ROOT_PATH}")

# by default we clobber our own source dir, but
# this can be changed by setting X_VCPKG_BINARY_DIR
if (NOT DEFINED ENV{X_VCPKG_BINARY_DIR})
set(ENV{X_VCPKG_BINARY_DIR} "${Z_VCPKG_ROOT_DIR}")
endif()

# CMAKE_EXECUTABLE_SUFFIX is not yet defined
if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
set(Z_VCPKG_EXECUTABLE "${Z_VCPKG_ROOT_DIR}/vcpkg.exe")
set(Z_VCPKG_EXECUTABLE "$ENV{X_VCPKG_BINARY_DIR}/vcpkg.exe")
set(Z_VCPKG_BOOTSTRAP_SCRIPT "${Z_VCPKG_ROOT_DIR}/bootstrap-vcpkg.bat")
else()
set(Z_VCPKG_EXECUTABLE "${Z_VCPKG_ROOT_DIR}/vcpkg")
set(Z_VCPKG_EXECUTABLE "$ENV{X_VCPKG_BINARY_DIR}/vcpkg")
set(Z_VCPKG_BOOTSTRAP_SCRIPT "${Z_VCPKG_ROOT_DIR}/bootstrap-vcpkg.sh")
endif()

Expand Down