@@ -208,6 +208,10 @@ $ExecutionContext.InvokeCommand.ExpandString($template) | Set-Content ".\build\p
208
208
209
209
exec { .\build\pandoc\pandoc.exe -- from gfm -- to gfm -- output .\build\ReadMe.txt .\docs\tutorial.md }
210
210
211
+ mkdirp .\build\pico- examples\.vscode
212
+ Copy-Item .\packages\pico- examples\ide\vscode\* .json .\build\pico- examples\.vscode\ - Force
213
+ exec { tar - a - cf " build\pico-examples.zip" - C " build" " pico-examples" }
214
+
211
215
$endl = ' $\r$\n'
212
216
213
217
function writeFile {
@@ -239,7 +243,7 @@ function writeFile {
239
243
; The repos need to be cloned into a dir with a fairly short name, because
240
244
; CMake generates build defs with long hashes in the paths. Both CMake and
241
245
; Ninja currently have problems working with long paths on Windows.
242
- !define PICO_REPOS_DIR "`$ LOCALAPPDATA\ $productDir "
246
+ !define PICO_REPOS_DIR "`$ DOCUMENTS\Pico-v $sdkVersion "
243
247
!define PICO_SHORTCUTS_DIR "`$ SMPROGRAMS\$product "
244
248
!define PICO_WINTERM_DIR "`$ LOCALAPPDATA\Microsoft\Windows Terminal\Fragments\$product "
245
249
!define PICO_REG_ROOT SHELL_CONTEXT
@@ -274,6 +278,8 @@ InstallDir "`${PICO_INSTALL_DIR}"
274
278
; We use a version-specific key here so that multiple versions can be installed side-by-side
275
279
InstallDirRegKey HKLM "`$ {PICO_REG_KEY}" "InstallPath"
276
280
281
+ Var ReposDir
282
+
277
283
!ifdef BUILD_UNINSTALLER
278
284
279
285
OutFile "build\build-uninstaller-$suffix .exe"
@@ -298,8 +304,8 @@ Function un.onInit
298
304
DetailPrint "Install path: `$ R0"
299
305
StrCpy `$ INSTDIR `$ R0
300
306
301
- ReadRegStr `$ R1 `$ {PICO_REG_ROOT} "`$ {PICO_REG_KEY}" "ReposPath"
302
- DetailPrint "Repos path: `$ R1 "
307
+ ReadRegStr `$ ReposDir HKCU "`$ {PICO_REG_KEY}" "ReposPath"
308
+ DetailPrint "Repos path: `$ ReposDir "
303
309
304
310
SetRegView $bitness
305
311
@@ -337,16 +343,12 @@ Section "Uninstall"
337
343
`$ {GetParent} "`$ INSTDIR" `$ R0
338
344
RMDir `$ R0
339
345
340
- RMDir /r /REBOOTOK "`$ R1\pico-examples"
341
- RMDir /r /REBOOTOK "`$ R1\pico-extras"
342
- RMDir /r /REBOOTOK "`$ R1\pico-playground"
343
- RMDir /r /REBOOTOK "`$ R1\pico-project-generator"
344
- RMDir /r /REBOOTOK "`$ R1\pico-sdk"
345
-
346
- RMDir /REBOOTOK "`$ R1"
347
- ; Remove the C:\ProgramData\Raspberry Pi directory if it is empty
348
- `$ {GetParent} "`$ R1" `$ R0
349
- RMDir `$ R0
346
+ `$ {If} `$ ReposDir != ""
347
+ RMDir /r /REBOOTOK "`$ ReposDir\pico-examples"
348
+ RMDir /r /REBOOTOK "`$ ReposDir\pico-extras"
349
+ RMDir /r /REBOOTOK "`$ ReposDir\pico-playground"
350
+ RMDir "`$ ReposDir"
351
+ `$ {EndIf}
350
352
351
353
DeleteRegValue `$ {PICO_REG_ROOT} "Software\Kitware\CMake\Packages\pico-sdk-tools" "v$sdkVersion "
352
354
DeleteRegKey /ifempty `$ {PICO_REG_ROOT} "Software\Kitware\CMake\Packages\pico-sdk-tools"
@@ -370,32 +372,41 @@ SectionEnd
370
372
OutFile "$binfile "
371
373
372
374
!define MUI_ICON "resources\raspberrypi.ico"
373
-
374
375
!define MUI_ABORTWARNING
375
-
376
376
!define MUI_WELCOMEPAGE_TITLE "`$ {TITLE}"
377
377
378
- ;!define MUI_COMPONENTSPAGE_SMALLDESC
379
-
380
- !define MUI_FINISHPAGE_RUN_TEXT "Clone and build Pico repos"
381
- !define MUI_FINISHPAGE_RUN
382
- !define MUI_FINISHPAGE_RUN_FUNCTION RunBuild
383
-
384
- !define MUI_FINISHPAGE_SHOWREADME "`$ INSTDIR\ReadMe.txt"
385
- !define MUI_FINISHPAGE_SHOWREADME_TEXT "Show ReadMe"
386
-
387
- !define MUI_FINISHPAGE_NOAUTOCLOSE
388
-
389
378
!insertmacro MUI_PAGE_WELCOME
390
379
$ ( $componentSelection ? ' !insertmacro MUI_PAGE_COMPONENTS' : ' ' )
391
380
!insertmacro MUI_PAGE_DIRECTORY
381
+ !define MUI_PAGE_CUSTOMFUNCTION_LEAVE DumpLog
392
382
!insertmacro MUI_PAGE_INSTFILES
383
+
384
+ !define FINISHPAGE_RUN_FUNCTION RunBuild
385
+ !define MUI_FINISHPAGE_SHOWREADME "`$ INSTDIR\ReadMe.txt"
386
+ !define MUI_FINISHPAGE_SHOWREADME_TEXT "Show ReadMe"
387
+ !include "packages\pico-setup-windows\FinishPage.nsh"
393
388
!insertmacro MUI_PAGE_FINISH
394
389
395
390
!insertmacro MUI_LANGUAGE "English"
396
391
397
392
Function .onInit
398
393
394
+ StrCpy `$ ReposDir "`$ {PICO_REPOS_DIR}"
395
+
396
+ ReadRegStr `$ R0 HKCU "`$ {PICO_REG_KEY}" "ReposPath"
397
+ `$ {If} `$ R0 != ""
398
+ StrCpy `$ ReposDir "`$ R0"
399
+ `$ {EndIf}
400
+
401
+ ClearErrors
402
+ `$ {GetParameters} `$ R1
403
+ `$ {GetOptions} "`$ R1" "/REPOSDIR=" `$ R0
404
+ `$ {IfNot} `$ {Errors}
405
+ StrCpy `$ ReposDir "`$ R0"
406
+ `$ {EndIf}
407
+
408
+ DetailPrint "Repos path: `$ ReposDir"
409
+
399
410
SetShellVarContext all
400
411
SetRegView $bitness
401
412
@@ -430,10 +441,8 @@ Section
430
441
; Save install paths in the 32-bit registry for ease of access from NSIS (un)installers
431
442
SetRegView 32
432
443
WriteRegStr `$ {PICO_REG_ROOT} "`$ {PICO_REG_KEY}" "InstallPath" "`$ INSTDIR"
433
- WriteRegStr `$ {PICO_REG_ROOT} "`$ {PICO_REG_KEY}" "ReposPath" "`$ {PICO_REPOS_DIR}"
434
444
SetRegView $bitness
435
445
436
- CreateDirectory "`$ {PICO_REPOS_DIR}"
437
446
CreateDirectory "`$ {PICO_SHORTCUTS_DIR}"
438
447
439
448
SetOutPath `$ INSTDIR\resources
@@ -510,18 +519,9 @@ SectionEnd
510
519
511
520
Section "-Pico environment" SecPico
512
521
513
- SetOutPath "`$ {PICO_REPOS_DIR} \pico-sdk"
522
+ SetOutPath "`$ INSTDIR \pico-sdk"
514
523
File /r "build\pico-sdk\*.*"
515
524
516
- SetOutPath "`$ {PICO_REPOS_DIR}\pico-examples"
517
- File /r "build\pico-examples\*.*"
518
- SetOutPath "`$ {PICO_REPOS_DIR}\pico-examples\.vscode"
519
- File "packages\pico-examples\ide\vscode\cmake-kits.json"
520
- File "packages\pico-examples\ide\vscode\extensions.json"
521
- File "packages\pico-examples\ide\vscode\launch.json"
522
- File "packages\pico-examples\ide\vscode\settings.json"
523
- File "packages\pico-examples\ide\vscode\tasks.json"
524
-
525
525
SetOutPath "`$ INSTDIR\pico-sdk-tools"
526
526
File "build\pico-sdk-tools\mingw$bitness \*.*"
527
527
WriteRegStr `$ {PICO_REG_ROOT} "Software\Kitware\CMake\Packages\pico-sdk-tools" "v$sdkVersion " "`$ INSTDIR\pico-sdk-tools"
@@ -530,15 +530,15 @@ Section "-Pico environment" SecPico
530
530
File "build\picotool-install\mingw$bitness \*.*"
531
531
532
532
SetOutPath "`$ INSTDIR"
533
+ File "build\pico-examples.zip"
533
534
WriteINIStr "`$ INSTDIR\version.ini" "pico-setup-windows" "PICO_SDK_VERSION" "$sdkVersion "
534
- WriteINIStr "`$ INSTDIR\version.ini" "pico-setup-windows" "PICO_REPOS_PATH" "`$ {PICO_REPOS_DIR}"
535
535
WriteINIStr "`$ INSTDIR\version.ini" "pico-setup-windows" "PICO_INSTALL_PATH" "`$ INSTDIR"
536
+ WriteINIStr "`$ INSTDIR\version.ini" "pico-setup-windows" "PICO_REG_KEY" "`$ {PICO_REG_KEY}"
536
537
File "packages\pico-setup-windows\pico-code.ps1"
537
538
File "packages\pico-setup-windows\pico-env.ps1"
538
539
File "packages\pico-setup-windows\pico-env.cmd"
539
540
File "packages\pico-setup-windows\pico-setup.cmd"
540
541
File "build\ReadMe.txt"
541
- CreateShortcut "`$ INSTDIR\pico-setup.lnk" "cmd.exe" '/k call "`$ INSTDIR\pico-setup.cmd" 1'
542
542
543
543
File /oname=uninstall.exe "build\uninstall-$suffix .exe"
544
544
WriteRegStr `$ {PICO_REG_ROOT} "`$ {UNINSTALL_KEY}" "DisplayName" "$product "
@@ -563,29 +563,26 @@ Section "-Pico environment" SecPico
563
563
MessageBox MB_OK|MB_ICONEXCLAMATION "Installation of Visual Studio Code failed. Please install it manually by downloading the installer from:${endl}${endl} https://code.visualstudio.com/" /SD IDOK
564
564
`$ {EndIf}
565
565
566
- ; Set the working directory for our terminals to the repos directory
567
- SetOutPath "`$ {PICO_REPOS_DIR}"
568
566
`$ {CreateShortcutEx} "`$ {PICO_SHORTCUTS_DIR}\Pico - Developer Command Prompt.lnk" "`$ {PICO_AppUserModel_ID}!cmd" `` "cmd.exe" '/k "`$ INSTDIR\pico-env.cmd"'``
569
567
`$ {CreateShortcutEx} "`$ {PICO_SHORTCUTS_DIR}\Pico - Developer PowerShell.lnk" "`$ {PICO_AppUserModel_ID}!powershell" `` "powershell.exe" '-NoExit -ExecutionPolicy Bypass -File "`$ INSTDIR\pico-env.ps1"'``
570
568
`$ {CreateShortcutEx} "`$ {PICO_SHORTCUTS_DIR}\Pico - Visual Studio Code.lnk" "`$ {PICO_AppUserModel_ID}!code" `` "powershell.exe" '-NoProfile -WindowStyle Hidden -ExecutionPolicy Bypass -File "`$ INSTDIR\pico-code.ps1"' "`$ 1" "" SW_SHOWMINIMIZED``
571
569
572
570
SetOutPath "`$ {PICO_WINTERM_DIR}"
573
571
`$ {WordReplace} "`$ INSTDIR" "\" "\\" "+" `$ 7
574
- `$ {WordReplace} "`$ {PICO_REPOS_DIR}" "\" "\\" "+" `$ 8
575
572
$ ( @"
576
573
{
577
574
"profiles": [
578
575
{
579
576
"name": "Pico - Developer Command Prompt (SDK v$sdkVersion )",
580
577
"commandline": "cmd.exe /k \"`$ 7\\pico-env.cmd\"",
581
578
"icon": "`$ 7\\resources\\raspberrypi.ico",
582
- "startingDirectory": "`$ 8 "
579
+ "startingDirectory": "`$ 7 "
583
580
},
584
581
{
585
582
"name": "Pico - Developer PowerShell (SDK v$sdkVersion )",
586
583
"commandline": "powershell.exe -NoExit -ExecutionPolicy Bypass -File \"`$ 7\\pico-env.ps1\"",
587
584
"icon": "`$ 7\\resources\\raspberrypi.ico",
588
- "startingDirectory": "`$ 8 "
585
+ "startingDirectory": "`$ 7 "
589
586
}
590
587
]
591
588
}
@@ -607,6 +604,8 @@ Function RunBuild
607
604
; We need to run pico-setup.cmd un-elevated, to avoid problems with builds later on.
608
605
; So we create a shortcut with the command line to use, and have explorer.exe launch it.
609
606
; http://mdb-blog.blogspot.com/2013/01/nsis-lunch-program-as-user-from-uac.html
607
+ SetShellVarContext current
608
+ CreateShortcut "`$ INSTDIR\pico-setup.lnk" "cmd.exe" '/k call "`$ INSTDIR\pico-setup.cmd" "`$ ReposDir" 1'
610
609
Exec '"`$ WINDIR\explorer.exe" "`$ INSTDIR\pico-setup.lnk"'
611
610
612
611
FunctionEnd
0 commit comments