Skip to content

Commit

Permalink
Clean up paths, fix VS Code launch script
Browse files Browse the repository at this point in the history
  • Loading branch information
ndabas committed Dec 1, 2022
1 parent 081c391 commit 5d23bd2
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 37 deletions.
21 changes: 11 additions & 10 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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}"
Expand Down Expand Up @@ -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"
Expand All @@ -338,17 +339,17 @@ 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"
WriteINIStr "`${PICO_SHORTCUTS_DIR}\Pico - Documentation\Pico C C++ SDK.url" "InternetShortcut" "URL" "https://datasheets.raspberrypi.com/pico/raspberry-pi-pico-c-sdk.pdf"
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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions packages/pico-setup-windows/pico-code.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
37 changes: 22 additions & 15 deletions packages/pico-setup-windows/pico-env.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
)
)

Expand Down
13 changes: 4 additions & 9 deletions packages/pico-setup-windows/pico-setup.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 (
Expand All @@ -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 .
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.3.6
0.3.7

0 comments on commit 5d23bd2

Please sign in to comment.