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

Commit 68e3450

Browse files
committed
Better install logging
1 parent 33e35a9 commit 68e3450

File tree

2 files changed

+35
-10
lines changed

2 files changed

+35
-10
lines changed

build.ps1

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -146,13 +146,6 @@ if (-not (Test-Path $MSYS2Path)) {
146146
exec { & .\downloads\msys2.exe -y "-o$(Resolve-Path (Split-Path $MSYS2Path -Parent))" }
147147
}
148148

149-
if (-not (Test-Path build\NSIS)) {
150-
Write-Host 'Extracting NSIS'
151-
Expand-Archive '.\downloads\nsis.zip' -DestinationPath '.\build'
152-
Rename-Item (Resolve-Path '.\build\nsis-*').Path 'NSIS'
153-
Expand-Archive '.\downloads\nsis-log.zip' -DestinationPath '.\build\NSIS' -Force
154-
}
155-
156149
function sign {
157150
param ([string[]] $filesToSign)
158151

@@ -257,7 +250,7 @@ Name "`${TITLE}"
257250
Caption "`${TITLE}"
258251
XPStyle on
259252
ManifestDPIAware true
260-
Unicode True
253+
Unicode true
261254
SetCompressor $Compression
262255
RequestExecutionLevel admin
263256
@@ -391,6 +384,8 @@ $($componentSelection ? '!insertmacro MUI_PAGE_COMPONENTS' : '')
391384
392385
!insertmacro MUI_LANGUAGE "English"
393386
387+
!include "packages\pico-setup-windows\DumpLog.nsh"
388+
394389
Function .onInit
395390
396391
StrCpy `$ReposDir "`${PICO_REPOS_DIR}"
@@ -416,9 +411,7 @@ FunctionEnd
416411
417412
Section
418413
419-
; Make sure that `$INSTDIR exists before enabling logging
420414
SetOutPath `$INSTDIR
421-
LogSet on
422415
423416
$(if ($bitness -eq '64') {
424417
'${IfNot} ${IsNativeAMD64}
@@ -562,6 +555,7 @@ Section "-Pico environment" SecPico
562555
`${IfNot} `${FileExists} "`$1"
563556
# Just use the default install location for the icon, in case the user installs VS Code later
564557
StrCpy `$1 "%LOCALAPPDATA%\Programs\Microsoft VS Code\Code.exe"
558+
DetailPrint "Could not find Visual Studio Code."
565559
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
566560
`${EndIf}
567561
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
; Based on https://nsis.sourceforge.io/Dump_log_to_file
2+
; This should be included after the MUI2 defines.
3+
4+
!include "WinMessages.nsh"
5+
6+
!define /ifndef LOG_PATH "$INSTDIR\install.log"
7+
8+
Function DumpLog
9+
System::Store "S"
10+
11+
FileOpen $5 ${LOG_PATH} "w"
12+
${If} $5 != ""
13+
SendMessage $mui.InstFilesPage.Log ${LVM_GETITEMCOUNT} 0 0 $6
14+
System::Call "*(&t${NSIS_MAX_STRLEN})p.r3"
15+
System::Call "*(i, i, i, i, i, p, i, i, i) p (0, 0, 0, 0, 0, r3, ${NSIS_MAX_STRLEN}) .r1"
16+
17+
StrCpy $2 0
18+
${While} $2 < $6
19+
System::Call "User32::SendMessage(p, i, p, p) p ($mui.InstFilesPage.Log, ${LVM_GETITEMTEXT}, $2, r1)"
20+
System::Call "*$3(&t${NSIS_MAX_STRLEN} .r4)"
21+
FileWriteUTF16LE $5 "$4$\r$\n"
22+
IntOp $2 $2 + 1
23+
${EndWhile}
24+
25+
FileClose $5
26+
System::Free $1
27+
System::Free $3
28+
${EndIf}
29+
30+
System::Store "L"
31+
FunctionEnd

0 commit comments

Comments
 (0)