Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update when the user runs a new copy of vcpkg-init rather than just assuming things are already OK. #533

Merged
merged 8 commits into from
May 3, 2022
Merged
Show file tree
Hide file tree
Changes from 7 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
2 changes: 1 addition & 1 deletion azure-pipelines/signing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ jobs:
tagSource: manual
tag: $(VCPKG_BASE_VERSION)
assets: "$(Build.ArtifactStagingDirectory)\\drop\\*"
addChangeLog: true
addChangeLog: false
compareWith: 'lastFullRelease'
- task: MicroBuildCleanup@1
condition: succeededOrFailed()
Expand Down
6 changes: 6 additions & 0 deletions vcpkg-init/lock-versions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,14 @@ $versionLockedUri = "https://github.com/microsoft/vcpkg-tool/releases/download/$

$pwshInstaller = Get-Content "$PSScriptRoot\vcpkg-init.ps1" -Raw -Encoding ascii
$pwshInstaller = $pwshInstaller.Replace($versionUnlockedUri, $versionLockedUri)
$pwshLatestLine = "`$SCRIPT:VCPKG_INIT_VERSION = 'latest'"
$pwshLockedLine = "`$SCRIPT:VCPKG_INIT_VERSION = '$VcpkgBaseVersion'"
$pwshInstaller = $pwshInstaller.Replace($pwshLatestLine, $pwshLockedLine)
Set-Content -Path "$Destination\vcpkg-init.ps1" -Value $pwshInstaller -NoNewline -Encoding ascii

$shInstaller = Get-Content "$PSScriptRoot\vcpkg-init" -Raw -Encoding ascii
$shInstaller = $shInstaller.Replace($versionUnlockedUri, $versionLockedUri)
$shLatestLine = "VCPKG_BASE_VERSION='latest'"
$shLockedLine = "VCPKG_BASE_VERSION='$VcpkgBaseVersion'"
$shInstaller = $shInstaller.Replace($shLatestLine, $shLockedLine)
Set-Content -Path "$Destination\vcpkg-init" -Value $shInstaller -NoNewline -Encoding ascii
13 changes: 8 additions & 5 deletions vcpkg-init/vcpkg-init
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,14 @@ Z_VCPKG_init() {
}

Z_VCPKG_bootstrap() {
if [ -f "${VCPKG_ROOT}/vcpkg" ]; then
return 0
fi
VCPKG_BASE_VERSION='latest'

# it's not there!
# let's install it where we want it
if [ $VCPKG_BASE_VERSION != 'latest' ] \
&& [ -f "${VCPKG_ROOT}/vcpkg" ] \
&& [ -f "${VCPKG_ROOT}/vcpkg-one-liner-version.txt" ] \
&& [ "$(cat "${VCPKG_ROOT}/vcpkg-one-liner-version.txt")" == $VCPKG_BASE_VERSION ]; then
BillyONeal marked this conversation as resolved.
Show resolved Hide resolved
return 0;
fi

echo installing vcpkg in $VCPKG_ROOT

Expand All @@ -62,6 +64,7 @@ Z_VCPKG_bootstrap() {

chmod +x "${VCPKG_ROOT}/vcpkg"
"${VCPKG_ROOT}/vcpkg" z-bootstrap-standalone
echo $VCPKG_BASE_VERSION > "${VCPKG_ROOT}/vcpkg-one-liner-version.txt"
return 0;
}

Expand Down
14 changes: 13 additions & 1 deletion vcpkg-init/vcpkg-init.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ if( $ENV:VCPKG_ROOT ) {

$VCPKG = "${VCPKG_ROOT}/vcpkg.exe"
$SCRIPT:VCPKG_SCRIPT = "${VCPKG_ROOT}/vcpkg-init.ps1"
$SCRIPT:VCPKG_VERSION_MARKER = "${VCPKG_ROOT}/vcpkg-one-liner-version.txt"
$SCRIPT:VCPKG_INIT_VERSION = 'latest'

$remove = $args.IndexOf('--remove-vcpkg') -gt -1

Expand All @@ -84,7 +86,15 @@ if( $remove ) {
}

function bootstrap-vcpkg {
if( test-path $VCPKG_SCRIPT ) {
[bool]$do_bootstrap = -not (test-path $VCPKG_SCRIPT) -or ($VCPKG_INIT_VERSION -eq 'latest')
if(-not $do_bootstrap -and (test-path $VCPKG_VERSION_MARKER)) {
$previous_version = Get-Content -Path $VCPKG_VERSION_MARKER -Raw
if ($previous_version -ne $VCPKG_INIT_VERSION) {
BillyONeal marked this conversation as resolved.
Show resolved Hide resolved
$do_bootstrap = $true
}
}

if( -not $do_bootstrap ) {
return $true
}

Expand All @@ -99,6 +109,8 @@ function bootstrap-vcpkg {
$PATH = $ENV:PATH
$ENV:PATH="$VCPKG_ROOT;$PATH"

Set-Content -Path $VCPKG_VERSION_MARKER -Value $VCPKG_INIT_VERSION -Force -NoNewline
BillyONeal marked this conversation as resolved.
Show resolved Hide resolved

z-vcpkg-debug "Bootstrapped vcpkg: ${VCPKG_ROOT}"

if( -not ( test-path $VCPKG_SCRIPT )) {
Expand Down