Skip to content

Commit

Permalink
Rename the shell function to 'vcpkg-shell'. (#1442)
Browse files Browse the repository at this point in the history
  • Loading branch information
BillyONeal authored Jul 26, 2024
1 parent 6d6266c commit 0e30cb1
Show file tree
Hide file tree
Showing 13 changed files with 30 additions and 26 deletions.
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -444,14 +444,14 @@ endif()
# === Target: vcpkg-ps1 ===
add_custom_command(
OUTPUT
"${CMAKE_CURRENT_BINARY_DIR}/vcpkg.ps1"
"${CMAKE_CURRENT_BINARY_DIR}/vcpkg-shell.ps1"
COMMAND
"${CMAKE_COMMAND}" ARGS -E copy "${CMAKE_CURRENT_SOURCE_DIR}/src/vcpkg-in-development.ps1" "${CMAKE_CURRENT_BINARY_DIR}/vcpkg.ps1"
"${CMAKE_COMMAND}" ARGS -E copy "${CMAKE_CURRENT_SOURCE_DIR}/src/vcpkg-in-development.ps1" "${CMAKE_CURRENT_BINARY_DIR}/vcpkg-shell.ps1"
DEPENDS
"${CMAKE_CURRENT_SOURCE_DIR}/src/vcpkg-in-development.ps1"
VERBATIM
)
add_custom_target(vcpkg-ps1 ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/vcpkg.ps1")
add_custom_target(vcpkg-ps1 ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/vcpkg-shell.ps1")

# === Target: vcpkg ===

Expand Down
8 changes: 4 additions & 4 deletions azure-pipelines/end-to-end-tests-dir/artifacts.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ try {
# can't deactivate without postscript:
$output = Run-VcpkgAndCaptureOutput -ForceExe deactivate
Throw-IfNotFailed
Test-Match $output "no postscript file: rerun with the vcpkg shell function rather than executable"
Test-Match $output "no postscript file: run vcpkg-shell with the same arguments"

$output = Run-VcpkgAndCaptureOutput deactivate
Throw-IfFailed
Expand All @@ -219,21 +219,21 @@ try {
# can't activate without postscript:
$output = Run-VcpkgAndCaptureOutput -ForceExe activate
Throw-IfNotFailed
Test-Match $output "no postscript file: rerun with the vcpkg shell function rather than executable"
Test-Match $output "no postscript file: run vcpkg-shell with the same arguments"
Test-Activations

# unless --json passed
$output = Run-VcpkgAndCaptureOutput -ForceExe activate --json (Join-Path $Project 'result.json')
Throw-IfFailed
Test-Match $output "Activating: $ProjectRegex"
Test-NoMatch $output "no postscript file: rerun with the vcpkg shell function rather than executable"
Test-NoMatch $output "no postscript file: run vcpkg-shell with the same arguments"
Test-Activations # no shell activation

# or --msbuild-props passed
$output = Run-VcpkgAndCaptureOutput -ForceExe activate --msbuild-props (Join-Path $Project 'result.props')
Throw-IfFailed
Test-Match $output "Activating: $ProjectRegex"
Test-NoMatch $output "no postscript file: rerun with the vcpkg shell function rather than executable"
Test-NoMatch $output "no postscript file: run vcpkg-shell with the same arguments"
Test-Activations # no shell activation
} finally {
Run-Vcpkg deactivate
Expand Down
2 changes: 1 addition & 1 deletion azure-pipelines/end-to-end-tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ if ([string]::IsNullOrEmpty($VcpkgExe))

$VcpkgItem = Get-Item $VcpkgExe
$VcpkgExe = $VcpkgItem.FullName
$VcpkgPs1 = Join-Path $VcpkgItem.Directory "vcpkg.ps1"
$VcpkgPs1 = Join-Path $VcpkgItem.Directory "vcpkg-shell.ps1"
$TestScriptAssetCacheExe = Join-Path $VcpkgItem.Directory "test-script-asset-cache"

[Array]$AllTests = Get-ChildItem $PSScriptRoot/end-to-end-tests-dir/*.ps1
Expand Down
2 changes: 1 addition & 1 deletion docs/vcpkg_tool_release_process.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ flowchart TD
and check that a reasonable zlib version is printed.
1. Back in the developer command prompt, verify that the copy of CMake can be customized by running:
```
vcpkg use microsoft:cmake
vcpkg-shell use microsoft:cmake
cmake -G Ninja -DCMAKE_TOOLCHAIN_FILE="%VCPKG_ROOT%\scripts\buildsystems\vcpkg.cmake" -S . -B build_artifact
ninja -C build_artifact
build_artifact\program.exe
Expand Down
4 changes: 2 additions & 2 deletions locales/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -1720,7 +1720,7 @@
"_optionsShouldBeASequenceFound$.comment": "\n'${p0}' is a parameter of type 'string'\n",
"DuplicateKeysDetectedInManifest$": "Duplicate keys detected in manifest: '${p0}'",
"_DuplicateKeysDetectedInManifest$.comment": "\n'${p0}' is a parameter of type 'string'\n",
"noPostscriptFileRerunWithTheVcpkgShellFunctionRatherThanExecutable": "no postscript file: rerun with the vcpkg shell function rather than executable",
"noPostscriptFileRunVcpkgshellWithTheSameArguments": "no postscript file: run vcpkg-shell with the same arguments",
"DuplicateDefine$DuringActivationNewValueWillReplaceOld": "Duplicate define ${p0} during activation. New value will replace old.",
"_DuplicateDefine$DuringActivationNewValueWillReplaceOld.comment": "\n'${p0}' is a parameter of type 'string'\n",
"DuplicateToolDeclared$DuringActivationNewValueWillReplaceOld": "Duplicate tool declared ${p0} during activation. New value will replace old.",
Expand Down Expand Up @@ -1876,7 +1876,7 @@
"_TriedToAddAnArtifact$$ButCouldNotDetermineTheRegistryToUse.comment": "\n'${p0}' is a parameter of type 'string'\n\n'${p1}' (aka 'artifact.id') is a parameter of type 'string'\n",
"TriedToAddRegistry$As$ButItWasAlready$PleaseAdd$ToThisProjectManuallyAndReattempt": "Tried to add registry ${p0} as ${p1}, but it was already ${p2}. Please add ${p3} to this project manually and reattempt.",
"_TriedToAddRegistry$As$ButItWasAlready$PleaseAdd$ToThisProjectManuallyAndReattempt.comment": "\n'${p0}' is a parameter of type 'string | undefined'\n\n'${p1}' is a parameter of type 'string'\n\n'${p2}' is a parameter of type 'string'\n\n'${p3}' is a parameter of type 'string'\n",
"RunvcpkgActivateToApplyToTheCurrentTerminal": "Run \\`vcpkg activate\\` to apply to the current terminal",
"RunvcpkgshellActivateToApplyToTheCurrentTerminal": "Run \\`vcpkg-shell activate\\` to apply to the current terminal",
"DownloadsFolderCleared$": "Downloads folder cleared (${p0}) ",
"_DownloadsFolderCleared$.comment": "\n'${p0}' (aka 'session.downloads.fsPath') is a parameter of type 'string'\n",
"InstalledArtifactFolderCleared$": "Installed Artifact folder cleared (${p0}) ",
Expand Down
4 changes: 3 additions & 1 deletion src/vcpkg-in-development.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,7 @@ if (Test-Path $env:Z_VCPKG_POSTSCRIPT) {
iex $postscr
}

Remove-Item -Force -ea 0 $env:Z_VCPKG_POSTSCRIPT,env:Z_VCPKG_POSTSCRIPT
Remove-Item -Force -ea 0 $env:Z_VCPKG_POSTSCRIPT
}

Remove-Item env:Z_VCPKG_POSTSCRIPT
2 changes: 1 addition & 1 deletion src/vcpkg/commands.activate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace vcpkg
constexpr CommandMetadata CommandActivateMetadata{
"activate",
msgCmdActivateSynopsis,
{"vcpkg activate"},
{"vcpkg-shell activate", "vcpkg activate --msbuild-props file.targets"},
Undocumented,
AutocompletePriority::Public,
0,
Expand Down
2 changes: 1 addition & 1 deletion src/vcpkg/commands.use.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace vcpkg
constexpr CommandMetadata CommandUseMetadata{
"use",
msgCmdUseSynopsis,
{msgCmdUseExample1, "vcpkg use cmake"},
{msgCmdUseExample1, "vcpkg-shell use cmake"},
Undocumented,
AutocompletePriority::Public,
1,
Expand Down
2 changes: 1 addition & 1 deletion vcpkg-artifacts/artifacts/activation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function findCaseInsensitiveOnWindows<V>(map: Map<string, V>, key: string): V |
export type Tuple<K, V> = [K, V];

function displayNoPostScriptError(channels: Channels) {
channels.error(i`no postscript file: rerun with the vcpkg shell function rather than executable`);
channels.error(i`no postscript file: run vcpkg-shell with the same arguments`);
}

export class Activation {
Expand Down
2 changes: 1 addition & 1 deletion vcpkg-artifacts/cli/commands/add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export class AddCommand extends Command {

// write the file out.
await projectManifest.metadata.save();
session.channels.message(i`Run \`vcpkg activate\` to apply to the current terminal`);
session.channels.message(i`Run \`vcpkg-shell activate\` to apply to the current terminal`);
return true;
}
}
4 changes: 2 additions & 2 deletions vcpkg-artifacts/locales/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"_optionsShouldBeASequenceFound$.comment": "\n'${p0}' is a parameter of type 'string'\n",
"DuplicateKeysDetectedInManifest$": "Duplicate keys detected in manifest: '${p0}'",
"_DuplicateKeysDetectedInManifest$.comment": "\n'${p0}' is a parameter of type 'string'\n",
"noPostscriptFileRerunWithTheVcpkgShellFunctionRatherThanExecutable": "no postscript file: rerun with the vcpkg shell function rather than executable",
"noPostscriptFileRunVcpkgshellWithTheSameArguments": "no postscript file: run vcpkg-shell with the same arguments",
"DuplicateDefine$DuringActivationNewValueWillReplaceOld": "Duplicate define ${p0} during activation. New value will replace old.",
"_DuplicateDefine$DuringActivationNewValueWillReplaceOld.comment": "\n'${p0}' is a parameter of type 'string'\n",
"DuplicateToolDeclared$DuringActivationNewValueWillReplaceOld": "Duplicate tool declared ${p0} during activation. New value will replace old.",
Expand Down Expand Up @@ -195,7 +195,7 @@
"_TriedToAddAnArtifact$$ButCouldNotDetermineTheRegistryToUse.comment": "\n'${p0}' is a parameter of type 'string'\n\n'${p1}' (aka 'artifact.id') is a parameter of type 'string'\n",
"TriedToAddRegistry$As$ButItWasAlready$PleaseAdd$ToThisProjectManuallyAndReattempt": "Tried to add registry ${p0} as ${p1}, but it was already ${p2}. Please add ${p3} to this project manually and reattempt.",
"_TriedToAddRegistry$As$ButItWasAlready$PleaseAdd$ToThisProjectManuallyAndReattempt.comment": "\n'${p0}' is a parameter of type 'string | undefined'\n\n'${p1}' is a parameter of type 'string'\n\n'${p2}' is a parameter of type 'string'\n\n'${p3}' is a parameter of type 'string'\n",
"RunvcpkgActivateToApplyToTheCurrentTerminal": "Run \\`vcpkg activate\\` to apply to the current terminal",
"RunvcpkgshellActivateToApplyToTheCurrentTerminal": "Run \\`vcpkg-shell activate\\` to apply to the current terminal",
"DownloadsFolderCleared$": "Downloads folder cleared (${p0}) ",
"_DownloadsFolderCleared$.comment": "\n'${p0}' (aka 'session.downloads.fsPath') is a parameter of type 'string'\n",
"InstalledArtifactFolderCleared$": "Installed Artifact folder cleared (${p0}) ",
Expand Down
6 changes: 3 additions & 3 deletions vcpkg-init/vcpkg-init
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Licensed under the MIT License.

# wrapper script for vcpkg
# this is intended to be dot-sourced and then you can use the vcpkg() function.
# this is intended to be dot-sourced and then you can use the vcpkg-shell() function.

# check to see if we've been dot-sourced (should work for most POSIX shells)
sourced=0
Expand Down Expand Up @@ -82,7 +82,7 @@ if [ $? -eq 1 ]; then
fi

# So, we're the real script then.
vcpkg() {
vcpkg-shell() {
# set the response file
# Generate 32 bits of randomness, to avoid clashing with concurrent executions.
export Z_VCPKG_POSTSCRIPT="$(mktemp).sh"
Expand All @@ -104,7 +104,7 @@ vcpkg() {

# did they dotsource and have args go ahead and run it then!
if [ "$#" -gt "0" ]; then
vcpkg $@
vcpkg-shell $@
fi

Z_VCPKG_cleanup
12 changes: 7 additions & 5 deletions vcpkg-init/vcpkg-init.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ if #ftw NEQ '' goto :init
# Licensed under the MIT License.

# wrapper script for vcpkg
# this is intended to be dot-sourced and then you can use the vcpkg() function
# this is intended to be dot-sourced and then you can use the vcpkg-shell() function

# Workaround for $IsWindows not existing in Windows PowerShell
if (-Not (Test-Path variable:IsWindows)) {
Expand Down Expand Up @@ -80,7 +80,7 @@ if(-Not (bootstrap-vcpkg)) {
# Export vcpkg to the current shell.
New-Module -name vcpkg -ArgumentList @($VCPKG) -ScriptBlock {
param($VCPKG)
function vcpkg() {
function vcpkg-shell() {
# setup the postscript file
# Generate 31 bits of randomness, to avoid clashing with concurrent executions.
$env:Z_VCPKG_POSTSCRIPT = Join-Path ([System.IO.Path]::GetTempPath()) "VCPKG_tmp_$(Get-Random -SetSeed $PID).ps1"
Expand All @@ -92,13 +92,15 @@ New-Module -name vcpkg -ArgumentList @($VCPKG) -ScriptBlock {
iex $postscr
}

Remove-Item -Force -ea 0 $env:Z_VCPKG_POSTSCRIPT,env:Z_VCPKG_POSTSCRIPT
Remove-Item -Force -ea 0 $env:Z_VCPKG_POSTSCRIPT
}

Remove-Item env:Z_VCPKG_POSTSCRIPT
}
} | Out-Null

if ($args.Count -ne 0) {
return vcpkg @args
return vcpkg-shell @args
}

return
Expand Down Expand Up @@ -140,7 +142,7 @@ IF ERRORLEVEL 1 (
SET Z_POWERSHELL_EXE=
:: Install the doskey
DOSKEY vcpkg="%VCPKG_ROOT%\vcpkg-cmd.cmd" $*
DOSKEY vcpkg-shell="%VCPKG_ROOT%\vcpkg-cmd.cmd" $*
:: If there were any arguments, also invoke vcpkg with them
IF "%1"=="" GOTO fin
Expand Down

0 comments on commit 0e30cb1

Please sign in to comment.