Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Commit 081c391

Browse files
committed
Name shortcuts consistently
- The VS Code shortcut now closes the terminal after Code is launched
1 parent 3964bd6 commit 081c391

File tree

5 files changed

+53
-59
lines changed

5 files changed

+53
-59
lines changed

build.ps1

+21-31
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ $repositories | ForEach-Object {
107107
}
108108

109109
$sdkVersion = (.\build\cmake\bin\cmake.exe -P .\packages\pico-setup-windows\pico-sdk-version.cmake -N | Select-String -Pattern 'PICO_SDK_VERSION_STRING=(.*)$').Matches.Groups[1].Value
110-
$product = "Raspberry Pi Pico SDK $sdkVersion"
110+
$product = "Raspberry Pi Pico SDK v$sdkVersion"
111111

112112
Write-Host "SDK version: $sdkVersion"
113113
Write-Host "Installer version: $version"
@@ -164,8 +164,10 @@ if (-not (Test-Path ".\build\picotool-install\mingw$bitness")) {
164164
; CMake generates build defs with long hashes in the paths. Both CMake and
165165
; Ninja currently have problems working with long paths on Windows.
166166
; !define PICO_REPOS_DIR "`$LOCALAPPDATA\Programs\$product"
167-
!define PICO_REPOS_DIR "`$DOCUMENTS\Pico"
168-
!define PICO_SHORTCUTS_DIR "`$SMPROGRAMS\$product"
167+
!define PICO_REPOS_DIR "`$DOCUMENTS\Pico-v$sdkVersion"
168+
!define PICO_SHORTCUTS_DIR "`$SMPROGRAMS\Raspberry Pi\Pico SDK v$sdkVersion"
169+
!define PICO_REG_ROOT HKCU
170+
!define PICO_REG_KEY "Software\Raspberry Pi\$basename"
169171
170172
Name "`${TITLE}"
171173
Caption "`${TITLE}"
@@ -187,7 +189,7 @@ SpaceTexts "none"
187189
InstallDir "`${PICO_INSTALL_DIR}"
188190
189191
;Get installation folder from registry if available
190-
InstallDirRegKey HKCU "Software\$basename" "InstallPath"
192+
InstallDirRegKey `${PICO_REG_ROOT} "`${PICO_REG_KEY}" "InstallPath"
191193
192194
!define MUI_ABORTWARNING
193195
@@ -222,8 +224,8 @@ Section
222224
InitPluginsDir
223225
File /oname=`$TEMP\RefreshEnv.cmd "packages\pico-setup-windows\RefreshEnv.cmd"
224226
225-
WriteRegStr HKCU "Software\$basename" "InstallPath" "`$INSTDIR"
226-
WriteRegStr HKCU "Software\$basename\v$version" "InstallPath" "`$INSTDIR"
227+
WriteRegStr `${PICO_REG_ROOT} "`${PICO_REG_KEY}" "InstallPath" "`$INSTDIR"
228+
WriteRegStr `${PICO_REG_ROOT} "`${PICO_REG_KEY}\v$version" "InstallPath" "`$INSTDIR"
227229
228230
CreateDirectory "`${PICO_REPOS_DIR}"
229231
CreateDirectory "`${PICO_SHORTCUTS_DIR}"
@@ -290,6 +292,8 @@ Section "VS Code Extensions" SecCodeExts
290292
Pop `$1
291293
nsExec::ExecToLog '"`$0" /c call "`$TEMP\RefreshEnv.cmd" && code --install-extension ms-vscode.cpptools-extension-pack'
292294
Pop `$1
295+
nsExec::ExecToLog '"`$0" /c call "`$TEMP\RefreshEnv.cmd" && code --install-extension ms-vscode.vscode-serial-monitor'
296+
Pop `$1
293297
294298
SectionEnd
295299
@@ -319,32 +323,29 @@ Section "Pico environment" SecPico
319323
320324
SetOutPath "`$INSTDIR\pico-sdk-tools"
321325
File "build\pico-sdk-tools\mingw$bitness\*.*"
322-
WriteRegStr HKCU "Software\Kitware\CMake\Packages\pico-sdk-tools" "v$version" "`$INSTDIR\pico-sdk-tools"
326+
WriteRegStr `${PICO_REG_ROOT} "Software\Kitware\CMake\Packages\pico-sdk-tools" "v$version" "`$INSTDIR\pico-sdk-tools"
323327
324328
SetOutPath "`$INSTDIR\picotool"
325329
File "build\picotool-install\mingw$bitness\*.*"
326330
327331
SetOutPath "`${PICO_REPOS_DIR}"
328332
File "version.txt"
333+
File "packages\pico-setup-windows\pico-code.ps1"
334+
File "packages\pico-setup-windows\pico-env.ps1"
329335
File "packages\pico-setup-windows\pico-env.cmd"
330336
File "packages\pico-setup-windows\pico-setup.cmd"
331337
File "packages\pico-setup-windows\ReadMe.txt"
332338
333-
CreateShortcut "`${PICO_SHORTCUTS_DIR}\Developer Command Prompt for Pico.lnk" "cmd.exe" '/k "`${PICO_REPOS_DIR}\pico-env.cmd"'
334-
335-
CreateShortcut "`${PICO_SHORTCUTS_DIR}\Open pico-examples in Visual Studio Code.lnk" "cmd.exe" '/c (call "`${PICO_REPOS_DIR}\pico-env.cmd" && code --disable-workspace-trust "`${PICO_REPOS_DIR}\pico-examples") || pause' "`$INSTDIR\resources\vscode.ico"
336-
337-
WriteINIStr "`${PICO_SHORTCUTS_DIR}\Raspberry Pi microcontrollers documentation.url" "InternetShortcut" "URL" "https://www.raspberrypi.com/documentation/microcontrollers/"
339+
CreateDirectory "`${PICO_SHORTCUTS_DIR}\Pico - Documentation"
338340
339-
WriteINIStr "`${PICO_SHORTCUTS_DIR}\Raspberry Pi Pico C-C++ SDK documentation.url" "InternetShortcut" "URL" "https://www.raspberrypi.com/documentation/microcontrollers/c_sdk.html"
341+
CreateShortcut "`${PICO_SHORTCUTS_DIR}\Pico - Developer Command Prompt.lnk" "cmd.exe" '/k "`${PICO_REPOS_DIR}\pico-env.cmd"'
342+
CreateShortcut "`${PICO_SHORTCUTS_DIR}\Pico - Developer PowerShell.lnk" "powershell.exe" '-NoExit -ExecutionPolicy Bypass -File "`${PICO_REPOS_DIR}\pico-env.ps1"'
343+
CreateShortcut "`${PICO_SHORTCUTS_DIR}\Pico - Visual Studio Code.lnk" "powershell.exe" 'powershell -WindowStyle Hidden -ExecutionPolicy Bypass -File "`${PICO_REPOS_DIR}\pico-code.ps1"' "`$INSTDIR\resources\vscode.ico" "" SW_SHOWMINIMIZED
340344
341-
; Unconditionally create a shortcut for VS Code -- in case the user had it
342-
; installed already, or if they install it later
343-
CreateShortcut "`${PICO_SHORTCUTS_DIR}\Visual Studio Code for Pico.lnk" "cmd.exe" '/c (call "`${PICO_REPOS_DIR}\pico-env.cmd" && code) || pause' "`$INSTDIR\resources\vscode.ico"
344-
345-
; SetOutPath is needed here to set the working directory for the shortcut
346-
SetOutPath "`$INSTDIR\pico-project-generator"
347-
CreateShortcut "`${PICO_SHORTCUTS_DIR}\Pico Project Generator.lnk" "cmd.exe" '/c (call "`${PICO_REPOS_DIR}\pico-env.cmd" && python "`${PICO_REPOS_DIR}\pico-project-generator\pico_project.py" --gui) || pause'
345+
WriteINIStr "`${PICO_SHORTCUTS_DIR}\Pico - Documentation\Pico Datasheet.url" "InternetShortcut" "URL" "https://datasheets.raspberrypi.com/pico/pico-datasheet.pdf"
346+
WriteINIStr "`${PICO_SHORTCUTS_DIR}\Pico - Documentation\Pico W Datasheet.url" "InternetShortcut" "URL" "https://datasheets.raspberrypi.com/picow/pico-w-datasheet.pdf"
347+
WriteINIStr "`${PICO_SHORTCUTS_DIR}\Pico - Documentation\Pico C C++ SDK.url" "InternetShortcut" "URL" "https://datasheets.raspberrypi.com/pico/raspberry-pi-pico-c-sdk.pdf"
348+
WriteINIStr "`${PICO_SHORTCUTS_DIR}\Pico - Documentation\Pico Python SDK.url" "InternetShortcut" "URL" "https://datasheets.raspberrypi.com/pico/raspberry-pi-pico-python-sdk.pdf"
348349
349350
; Reset working dir for pico-setup.cmd launched from the finish page
350351
SetOutPath "`${PICO_REPOS_DIR}"
@@ -353,28 +354,17 @@ SectionEnd
353354
354355
LangString DESC_SecPico `${LANG_ENGLISH} "Scripts for cloning the Pico SDK and tools repos, and for setting up your Pico development environment."
355356
356-
Section "Download documents and files" SecDocs
357-
358-
SetOutPath "`${PICO_REPOS_DIR}"
359-
File "common.ps1"
360-
File "packages\pico-setup-windows\pico-docs.ps1"
361-
362-
SectionEnd
363-
364357
Function RunBuild
365358
366359
ReadEnvStr `$0 COMSPEC
367360
Exec '"`$0" /k call "`$TEMP\RefreshEnv.cmd" && del "`$TEMP\RefreshEnv.cmd" && call "`${PICO_REPOS_DIR}\pico-setup.cmd" 1'
368361
369362
FunctionEnd
370363
371-
LangString DESC_SecDocs `${LANG_ENGLISH} "Adds a script to download the latest Pico documents, design files, and UF2 files."
372-
373364
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
374365
!insertmacro MUI_DESCRIPTION_TEXT `${SecCodeExts} `$(DESC_SecCodeExts)
375366
!insertmacro MUI_DESCRIPTION_TEXT `${SecOpenOCD} `$(DESC_SecOpenOCD)
376367
!insertmacro MUI_DESCRIPTION_TEXT `${SecPico} `$(DESC_SecPico)
377-
!insertmacro MUI_DESCRIPTION_TEXT `${SecDocs} `$(DESC_SecDocs)
378368
$($downloads | ForEach-Object {
379369
" !insertmacro MUI_DESCRIPTION_TEXT `${Sec$($_.shortName)} `$(DESC_Sec$($_.shortName))`n"
380370
})
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
Set-StrictMode -Version Latest
2+
$ErrorActionPreference = 'Stop'
3+
$ProgressPreference = 'SilentlyContinue'
4+
5+
. "$PSScriptRoot\pico-env.ps1"
6+
7+
# On first run, open the pico-examples repo. Open a blank VS Code instance otherwise.
8+
$openArgs = "--disable-workspace-trust `"$PSScriptRoot\pico-examples`""
9+
$regPath = 'HKCU:\Software\Raspberry Pi\pico-setup-windows'
10+
$regName = 'FirstRun'
11+
$entries = Get-ItemProperty -Path $regPath
12+
if ($entries | Get-Member $regName) {
13+
$openArgs = ''
14+
} else {
15+
Set-ItemProperty -Path $regPath -Name $regName -Value '0'
16+
}
17+
18+
$codeBinDir = Split-Path -Parent (Get-Command 'code.cmd').Path
19+
$codeExeDir = Split-Path -Parent $codeBinDir
20+
$codeExe = Join-Path $codeExeDir 'code.exe'
21+
22+
cmd /s /c "start `"`" `"$codeExe`" --new-window $openArgs"

packages/pico-setup-windows/pico-docs.ps1

-27
This file was deleted.

packages/pico-setup-windows/pico-env.cmd

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ if not defined PICO_INSTALL_VERSION (
3838

3939
rem https://stackoverflow.com/questions/22352793/reading-a-registry-value-to-a-batch-variable-handling-spaces-in-value
4040
for /f "usebackq skip=1 tokens=2,*" %%h in (
41-
`reg query "HKCU\Software\pico-setup-windows\v%PICO_INSTALL_VERSION%" /v "InstallPath"`
41+
`reg query "HKCU\Software\Raspberry Pi\pico-setup-windows\v%PICO_INSTALL_VERSION%" /v "InstallPath"`
4242
) do (
4343
echo PICO_INSTALL_PATH=%%i
4444
set "PICO_INSTALL_PATH=%%i"
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Set-StrictMode -Version Latest
2+
$ErrorActionPreference = 'Stop'
3+
$ProgressPreference = 'SilentlyContinue'
4+
5+
# https://github.com/microsoft/vswhere/wiki/Start-Developer-Command-Prompt#using-powershell
6+
& "${env:COMSPEC}" /s /c "`"$PSScriptRoot\pico-env.cmd`" && set" | ForEach-Object {
7+
$name, $value = $_ -split '=', 2
8+
Set-Content env:\"$name" $value
9+
}

0 commit comments

Comments
 (0)