diff --git a/build.ps1 b/build.ps1 index 5778dd7..617c2ab 100644 --- a/build.ps1 +++ b/build.ps1 @@ -188,8 +188,9 @@ SpaceTexts "none" InstallDir "`${PICO_INSTALL_DIR}" -;Get installation folder from registry if available -InstallDirRegKey `${PICO_REG_ROOT} "`${PICO_REG_KEY}" "InstallPath" +; Get installation folder from registry if available +; We use a version-specific key here so that multiple versions can be installed side-by-side +InstallDirRegKey `${PICO_REG_ROOT} "`${PICO_REG_KEY}\v$version" "InstallPath" !define MUI_ABORTWARNING @@ -201,7 +202,7 @@ InstallDirRegKey `${PICO_REG_ROOT} "`${PICO_REG_KEY}" "InstallPath" !define MUI_FINISHPAGE_RUN !define MUI_FINISHPAGE_RUN_FUNCTION RunBuild -!define MUI_FINISHPAGE_SHOWREADME "`${PICO_REPOS_DIR}\ReadMe.txt" +!define MUI_FINISHPAGE_SHOWREADME "`$INSTDIR\ReadMe.txt" !define MUI_FINISHPAGE_SHOWREADME_TEXT "Show ReadMe" !define MUI_FINISHPAGE_NOAUTOCLOSE @@ -224,8 +225,8 @@ Section InitPluginsDir File /oname=`$TEMP\RefreshEnv.cmd "packages\pico-setup-windows\RefreshEnv.cmd" - WriteRegStr `${PICO_REG_ROOT} "`${PICO_REG_KEY}" "InstallPath" "`$INSTDIR" WriteRegStr `${PICO_REG_ROOT} "`${PICO_REG_KEY}\v$version" "InstallPath" "`$INSTDIR" + WriteRegStr `${PICO_REG_ROOT} "`${PICO_REG_KEY}\v$version" "ReposPath" "`${PICO_REPOS_DIR}" CreateDirectory "`${PICO_REPOS_DIR}" CreateDirectory "`${PICO_SHORTCUTS_DIR}" @@ -328,7 +329,7 @@ Section "Pico environment" SecPico SetOutPath "`$INSTDIR\picotool" File "build\picotool-install\mingw$bitness\*.*" - SetOutPath "`${PICO_REPOS_DIR}" + SetOutPath "`$INSTDIR" File "version.txt" File "packages\pico-setup-windows\pico-code.ps1" File "packages\pico-setup-windows\pico-env.ps1" @@ -338,9 +339,9 @@ Section "Pico environment" SecPico CreateDirectory "`${PICO_SHORTCUTS_DIR}\Pico - Documentation" - CreateShortcut "`${PICO_SHORTCUTS_DIR}\Pico - Developer Command Prompt.lnk" "cmd.exe" '/k "`${PICO_REPOS_DIR}\pico-env.cmd"' - CreateShortcut "`${PICO_SHORTCUTS_DIR}\Pico - Developer PowerShell.lnk" "powershell.exe" '-NoExit -ExecutionPolicy Bypass -File "`${PICO_REPOS_DIR}\pico-env.ps1"' - 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 + CreateShortcut "`${PICO_SHORTCUTS_DIR}\Pico - Developer Command Prompt.lnk" "cmd.exe" '/k "`$INSTDIR\pico-env.cmd"' + CreateShortcut "`${PICO_SHORTCUTS_DIR}\Pico - Developer PowerShell.lnk" "powershell.exe" '-NoExit -ExecutionPolicy Bypass -File "`$INSTDIR\pico-env.ps1"' + 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 WriteINIStr "`${PICO_SHORTCUTS_DIR}\Pico - Documentation\Pico Datasheet.url" "InternetShortcut" "URL" "https://datasheets.raspberrypi.com/pico/pico-datasheet.pdf" WriteINIStr "`${PICO_SHORTCUTS_DIR}\Pico - Documentation\Pico W Datasheet.url" "InternetShortcut" "URL" "https://datasheets.raspberrypi.com/picow/pico-w-datasheet.pdf" @@ -348,7 +349,7 @@ Section "Pico environment" SecPico WriteINIStr "`${PICO_SHORTCUTS_DIR}\Pico - Documentation\Pico Python SDK.url" "InternetShortcut" "URL" "https://datasheets.raspberrypi.com/pico/raspberry-pi-pico-python-sdk.pdf" ; Reset working dir for pico-setup.cmd launched from the finish page - SetOutPath "`${PICO_REPOS_DIR}" + SetOutPath "`$INSTDIR" SectionEnd @@ -357,7 +358,7 @@ LangString DESC_SecPico `${LANG_ENGLISH} "Scripts for cloning the Pico SDK and t Function RunBuild ReadEnvStr `$0 COMSPEC - Exec '"`$0" /k call "`$TEMP\RefreshEnv.cmd" && del "`$TEMP\RefreshEnv.cmd" && call "`${PICO_REPOS_DIR}\pico-setup.cmd" 1' + Exec '"`$0" /k call "`$TEMP\RefreshEnv.cmd" && del "`$TEMP\RefreshEnv.cmd" && call "`$INSTDIR\pico-setup.cmd" 1' FunctionEnd diff --git a/packages/pico-setup-windows/pico-code.ps1 b/packages/pico-setup-windows/pico-code.ps1 index 5c5a552..598990d 100644 --- a/packages/pico-setup-windows/pico-code.ps1 +++ b/packages/pico-setup-windows/pico-code.ps1 @@ -5,8 +5,8 @@ $ProgressPreference = 'SilentlyContinue' . "$PSScriptRoot\pico-env.ps1" # On first run, open the pico-examples repo. Open a blank VS Code instance otherwise. -$openArgs = "--disable-workspace-trust `"$PSScriptRoot\pico-examples`"" -$regPath = 'HKCU:\Software\Raspberry Pi\pico-setup-windows' +$openArgs = "--disable-workspace-trust `"$env:PICO_EXAMPLES_PATH`"" +$regPath = "HKCU:\Software\Raspberry Pi\pico-setup-windows\v$env:PICO_INSTALL_VERSION" $regName = 'FirstRun' $entries = Get-ItemProperty -Path $regPath if ($entries | Get-Member $regName) { diff --git a/packages/pico-setup-windows/pico-env.cmd b/packages/pico-setup-windows/pico-env.cmd index 3de3c57..eab82e9 100644 --- a/packages/pico-setup-windows/pico-env.cmd +++ b/packages/pico-setup-windows/pico-env.cmd @@ -22,6 +22,23 @@ goto main goto :EOF +:SetEnvFromRegistry + + rem https://stackoverflow.com/questions/22352793/reading-a-registry-value-to-a-batch-variable-handling-spaces-in-value + for /f "usebackq skip=2 tokens=2,*" %%h in ( + `reg query "HKCU\Software\Raspberry Pi\pico-setup-windows\v%PICO_INSTALL_VERSION%" /v "%1Path"` + ) do ( + echo PICO_%1_PATH=%%i + set "PICO_%1_PATH=%%i" + ) + + if not defined PICO_%1_PATH ( + echo ERROR: Unable to determine Pico %1 path. + set /a errors += 1 + ) + + goto :EOF + :main pushd "%~dp0" @@ -36,25 +53,15 @@ if not defined PICO_INSTALL_VERSION ( set /a errors += 1 ) -rem https://stackoverflow.com/questions/22352793/reading-a-registry-value-to-a-batch-variable-handling-spaces-in-value -for /f "usebackq skip=1 tokens=2,*" %%h in ( - `reg query "HKCU\Software\Raspberry Pi\pico-setup-windows\v%PICO_INSTALL_VERSION%" /v "InstallPath"` - ) do ( - echo PICO_INSTALL_PATH=%%i - set "PICO_INSTALL_PATH=%%i" -) - -if not defined PICO_INSTALL_PATH ( - echo ERROR: Unable to determine Pico install path. - set /a errors += 1 -) +call :SetEnvFromRegistry install +call :SetEnvFromRegistry repos for %%i in (sdk examples extras playground) do ( rem Environment variables in Windows aren't case-sensitive, so we don't need rem to bother with uppercasing the env var name. - if exist "%~dp0pico-%%i" ( - echo PICO_%%i_PATH=%~dp0pico-%%i - set "PICO_%%i_PATH=%~dp0pico-%%i" + if exist "%PICO_REPOS_PATH%\pico-%%i" ( + echo PICO_%%i_PATH=%PICO_REPOS_PATH%\pico-%%i + set "PICO_%%i_PATH=%PICO_REPOS_PATH%\pico-%%i" ) ) diff --git a/packages/pico-setup-windows/pico-setup.cmd b/packages/pico-setup-windows/pico-setup.cmd index f4c00a3..396081a 100644 --- a/packages/pico-setup-windows/pico-setup.cmd +++ b/packages/pico-setup-windows/pico-setup.cmd @@ -10,10 +10,10 @@ set "GITHUB_PREFIX=https://github.com/raspberrypi/" set "GITHUB_SUFFIX=.git" set "SDK_BRANCH=master" -pushd "%~dp0" +pushd "%PICO_REPOS_PATH%" for %%i in (sdk examples extras playground project-generator) do ( - set "DEST=%~dp0pico-%%i" + set "DEST=%PICO_REPOS_PATH%\pico-%%i" if exist "!DEST!\.git" ( echo !DEST! exists, skipping clone @@ -32,8 +32,8 @@ for %%i in (sdk examples extras playground project-generator) do ( ) rem Build a couple of examples -mkdir "%~dp0pico-examples\build" -pushd "%~dp0pico-examples\build" +mkdir "%PICO_REPOS_PATH%\pico-examples\build" +pushd "%PICO_REPOS_PATH%\pico-examples\build" cmake -G Ninja .. -DCMAKE_BUILD_TYPE=Debug --fresh || exit /b 1 for %%i in (blink "hello_world/all") do ( @@ -43,11 +43,6 @@ for %%i in (blink "hello_world/all") do ( popd -if exist "%~dp0pico-docs.ps1" ( - echo Downloading Pico documents and files... - powershell -NoProfile -NonInteractive -ExecutionPolicy Bypass -File "%~dp0pico-docs.ps1" || exit /b 1 -) - if "%interactive%" equ "1" ( rem Open repo folder in Explorer start . diff --git a/version.txt b/version.txt index 78c10c9..9690c32 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -0.3.6 +0.3.7