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

Commit 5d23bd2

Browse files
committed
Clean up paths, fix VS Code launch script
1 parent 081c391 commit 5d23bd2

File tree

5 files changed

+40
-37
lines changed

5 files changed

+40
-37
lines changed

build.ps1

+11-10
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,9 @@ SpaceTexts "none"
188188
189189
InstallDir "`${PICO_INSTALL_DIR}"
190190
191-
;Get installation folder from registry if available
192-
InstallDirRegKey `${PICO_REG_ROOT} "`${PICO_REG_KEY}" "InstallPath"
191+
; Get installation folder from registry if available
192+
; We use a version-specific key here so that multiple versions can be installed side-by-side
193+
InstallDirRegKey `${PICO_REG_ROOT} "`${PICO_REG_KEY}\v$version" "InstallPath"
193194
194195
!define MUI_ABORTWARNING
195196
@@ -201,7 +202,7 @@ InstallDirRegKey `${PICO_REG_ROOT} "`${PICO_REG_KEY}" "InstallPath"
201202
!define MUI_FINISHPAGE_RUN
202203
!define MUI_FINISHPAGE_RUN_FUNCTION RunBuild
203204
204-
!define MUI_FINISHPAGE_SHOWREADME "`${PICO_REPOS_DIR}\ReadMe.txt"
205+
!define MUI_FINISHPAGE_SHOWREADME "`$INSTDIR\ReadMe.txt"
205206
!define MUI_FINISHPAGE_SHOWREADME_TEXT "Show ReadMe"
206207
207208
!define MUI_FINISHPAGE_NOAUTOCLOSE
@@ -224,8 +225,8 @@ Section
224225
InitPluginsDir
225226
File /oname=`$TEMP\RefreshEnv.cmd "packages\pico-setup-windows\RefreshEnv.cmd"
226227
227-
WriteRegStr `${PICO_REG_ROOT} "`${PICO_REG_KEY}" "InstallPath" "`$INSTDIR"
228228
WriteRegStr `${PICO_REG_ROOT} "`${PICO_REG_KEY}\v$version" "InstallPath" "`$INSTDIR"
229+
WriteRegStr `${PICO_REG_ROOT} "`${PICO_REG_KEY}\v$version" "ReposPath" "`${PICO_REPOS_DIR}"
229230
230231
CreateDirectory "`${PICO_REPOS_DIR}"
231232
CreateDirectory "`${PICO_SHORTCUTS_DIR}"
@@ -328,7 +329,7 @@ Section "Pico environment" SecPico
328329
SetOutPath "`$INSTDIR\picotool"
329330
File "build\picotool-install\mingw$bitness\*.*"
330331
331-
SetOutPath "`${PICO_REPOS_DIR}"
332+
SetOutPath "`$INSTDIR"
332333
File "version.txt"
333334
File "packages\pico-setup-windows\pico-code.ps1"
334335
File "packages\pico-setup-windows\pico-env.ps1"
@@ -338,17 +339,17 @@ Section "Pico environment" SecPico
338339
339340
CreateDirectory "`${PICO_SHORTCUTS_DIR}\Pico - Documentation"
340341
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
342+
CreateShortcut "`${PICO_SHORTCUTS_DIR}\Pico - Developer Command Prompt.lnk" "cmd.exe" '/k "`$INSTDIR\pico-env.cmd"'
343+
CreateShortcut "`${PICO_SHORTCUTS_DIR}\Pico - Developer PowerShell.lnk" "powershell.exe" '-NoExit -ExecutionPolicy Bypass -File "`$INSTDIR\pico-env.ps1"'
344+
CreateShortcut "`${PICO_SHORTCUTS_DIR}\Pico - Visual Studio Code.lnk" "powershell.exe" '-WindowStyle Hidden -ExecutionPolicy Bypass -File "`$INSTDIR\pico-code.ps1"' "`$INSTDIR\resources\vscode.ico" "" SW_SHOWMINIMIZED
344345
345346
WriteINIStr "`${PICO_SHORTCUTS_DIR}\Pico - Documentation\Pico Datasheet.url" "InternetShortcut" "URL" "https://datasheets.raspberrypi.com/pico/pico-datasheet.pdf"
346347
WriteINIStr "`${PICO_SHORTCUTS_DIR}\Pico - Documentation\Pico W Datasheet.url" "InternetShortcut" "URL" "https://datasheets.raspberrypi.com/picow/pico-w-datasheet.pdf"
347348
WriteINIStr "`${PICO_SHORTCUTS_DIR}\Pico - Documentation\Pico C C++ SDK.url" "InternetShortcut" "URL" "https://datasheets.raspberrypi.com/pico/raspberry-pi-pico-c-sdk.pdf"
348349
WriteINIStr "`${PICO_SHORTCUTS_DIR}\Pico - Documentation\Pico Python SDK.url" "InternetShortcut" "URL" "https://datasheets.raspberrypi.com/pico/raspberry-pi-pico-python-sdk.pdf"
349350
350351
; Reset working dir for pico-setup.cmd launched from the finish page
351-
SetOutPath "`${PICO_REPOS_DIR}"
352+
SetOutPath "`$INSTDIR"
352353
353354
SectionEnd
354355
@@ -357,7 +358,7 @@ LangString DESC_SecPico `${LANG_ENGLISH} "Scripts for cloning the Pico SDK and t
357358
Function RunBuild
358359
359360
ReadEnvStr `$0 COMSPEC
360-
Exec '"`$0" /k call "`$TEMP\RefreshEnv.cmd" && del "`$TEMP\RefreshEnv.cmd" && call "`${PICO_REPOS_DIR}\pico-setup.cmd" 1'
361+
Exec '"`$0" /k call "`$TEMP\RefreshEnv.cmd" && del "`$TEMP\RefreshEnv.cmd" && call "`$INSTDIR\pico-setup.cmd" 1'
361362
362363
FunctionEnd
363364

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ $ProgressPreference = 'SilentlyContinue'
55
. "$PSScriptRoot\pico-env.ps1"
66

77
# 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'
8+
$openArgs = "--disable-workspace-trust `"$env:PICO_EXAMPLES_PATH`""
9+
$regPath = "HKCU:\Software\Raspberry Pi\pico-setup-windows\v$env:PICO_INSTALL_VERSION"
1010
$regName = 'FirstRun'
1111
$entries = Get-ItemProperty -Path $regPath
1212
if ($entries | Get-Member $regName) {

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

+22-15
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,23 @@ goto main
2222

2323
goto :EOF
2424

25+
:SetEnvFromRegistry
26+
27+
rem https://stackoverflow.com/questions/22352793/reading-a-registry-value-to-a-batch-variable-handling-spaces-in-value
28+
for /f "usebackq skip=2 tokens=2,*" %%h in (
29+
`reg query "HKCU\Software\Raspberry Pi\pico-setup-windows\v%PICO_INSTALL_VERSION%" /v "%1Path"`
30+
) do (
31+
echo PICO_%1_PATH=%%i
32+
set "PICO_%1_PATH=%%i"
33+
)
34+
35+
if not defined PICO_%1_PATH (
36+
echo ERROR: Unable to determine Pico %1 path.
37+
set /a errors += 1
38+
)
39+
40+
goto :EOF
41+
2542
:main
2643

2744
pushd "%~dp0"
@@ -36,25 +53,15 @@ if not defined PICO_INSTALL_VERSION (
3653
set /a errors += 1
3754
)
3855

39-
rem https://stackoverflow.com/questions/22352793/reading-a-registry-value-to-a-batch-variable-handling-spaces-in-value
40-
for /f "usebackq skip=1 tokens=2,*" %%h in (
41-
`reg query "HKCU\Software\Raspberry Pi\pico-setup-windows\v%PICO_INSTALL_VERSION%" /v "InstallPath"`
42-
) do (
43-
echo PICO_INSTALL_PATH=%%i
44-
set "PICO_INSTALL_PATH=%%i"
45-
)
46-
47-
if not defined PICO_INSTALL_PATH (
48-
echo ERROR: Unable to determine Pico install path.
49-
set /a errors += 1
50-
)
56+
call :SetEnvFromRegistry install
57+
call :SetEnvFromRegistry repos
5158

5259
for %%i in (sdk examples extras playground) do (
5360
rem Environment variables in Windows aren't case-sensitive, so we don't need
5461
rem to bother with uppercasing the env var name.
55-
if exist "%~dp0pico-%%i" (
56-
echo PICO_%%i_PATH=%~dp0pico-%%i
57-
set "PICO_%%i_PATH=%~dp0pico-%%i"
62+
if exist "%PICO_REPOS_PATH%\pico-%%i" (
63+
echo PICO_%%i_PATH=%PICO_REPOS_PATH%\pico-%%i
64+
set "PICO_%%i_PATH=%PICO_REPOS_PATH%\pico-%%i"
5865
)
5966
)
6067

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

+4-9
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ set "GITHUB_PREFIX=https://github.com/raspberrypi/"
1010
set "GITHUB_SUFFIX=.git"
1111
set "SDK_BRANCH=master"
1212

13-
pushd "%~dp0"
13+
pushd "%PICO_REPOS_PATH%"
1414

1515
for %%i in (sdk examples extras playground project-generator) do (
16-
set "DEST=%~dp0pico-%%i"
16+
set "DEST=%PICO_REPOS_PATH%\pico-%%i"
1717

1818
if exist "!DEST!\.git" (
1919
echo !DEST! exists, skipping clone
@@ -32,8 +32,8 @@ for %%i in (sdk examples extras playground project-generator) do (
3232
)
3333

3434
rem Build a couple of examples
35-
mkdir "%~dp0pico-examples\build"
36-
pushd "%~dp0pico-examples\build"
35+
mkdir "%PICO_REPOS_PATH%\pico-examples\build"
36+
pushd "%PICO_REPOS_PATH%\pico-examples\build"
3737
cmake -G Ninja .. -DCMAKE_BUILD_TYPE=Debug --fresh || exit /b 1
3838

3939
for %%i in (blink "hello_world/all") do (
@@ -43,11 +43,6 @@ for %%i in (blink "hello_world/all") do (
4343

4444
popd
4545

46-
if exist "%~dp0pico-docs.ps1" (
47-
echo Downloading Pico documents and files...
48-
powershell -NoProfile -NonInteractive -ExecutionPolicy Bypass -File "%~dp0pico-docs.ps1" || exit /b 1
49-
)
50-
5146
if "%interactive%" equ "1" (
5247
rem Open repo folder in Explorer
5348
start .

version.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.3.6
1+
0.3.7

0 commit comments

Comments
 (0)