Skip to content

Commit

Permalink
Add qz-tray-console.exe for debugging purposes (qzind#828)
Browse files Browse the repository at this point in the history
* Add qz-tray-console.exe for debugging purposes
Supersedes qzind#801
  • Loading branch information
tresf authored Jun 25, 2021
1 parent 9e13b94 commit f39e9d4
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
/fx.zip
/README.md
.DS_Store
windows-debug-launcher.nsi.in
9 changes: 9 additions & 0 deletions ant/windows/installer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@
<param name="nsis.outfile" value="${dist.dir}/${project.filename}.exe"/>
</antcall>

<!-- Debug Launcher -->
<copy file="ant/windows/windows-launcher.nsi.in" tofile="ant/windows/windows-debug-launcher.nsi.in" overwrite="true"/>
<replace file="ant/windows/windows-debug-launcher.nsi.in" token="$javaw" value="$java"/>
<replace file="ant/windows/windows-debug-launcher.nsi.in" token="/assets/branding/windows-icon.ico" value="/ant/windows/nsis/console.ico"/>
<antcall target="config-compile-sign">
<param name="nsis.script.in" value="windows-debug-launcher.nsi.in"/>
<param name="nsis.outfile" value="${dist.dir}/${project.filename}-console.exe"/>
</antcall>

<!-- Uninstaller -->
<antcall target="config-compile-sign">
<param name="nsis.script.in" value="windows-uninstaller.nsi.in"/>
Expand Down
72 changes: 72 additions & 0 deletions ant/windows/nsis/Include/StrLoc.nsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
!define StrLoc "!insertmacro StrLoc"

!macro StrLoc ResultVar String SubString StartPoint
Push "${String}"
Push "${SubString}"
Push "${StartPoint}"
Call StrLoc
Pop "${ResultVar}"
!macroend

Function StrLoc
/*After this point:
------------------------------------------
$R0 = StartPoint (input)
$R1 = SubString (input)
$R2 = String (input)
$R3 = SubStringLen (temp)
$R4 = StrLen (temp)
$R5 = StartCharPos (temp)
$R6 = TempStr (temp)*/

;Get input from user
Exch $R0
Exch
Exch $R1
Exch 2
Exch $R2
Push $R3
Push $R4
Push $R5
Push $R6

;Get "String" and "SubString" length
StrLen $R3 $R1
StrLen $R4 $R2
;Start "StartCharPos" counter
StrCpy $R5 0

;Loop until "SubString" is found or "String" reaches its end
${Do}
;Remove everything before and after the searched part ("TempStr")
StrCpy $R6 $R2 $R3 $R5

;Compare "TempStr" with "SubString"
${If} $R6 == $R1
${If} $R0 == `<`
IntOp $R6 $R3 + $R5
IntOp $R0 $R4 - $R6
${Else}
StrCpy $R0 $R5
${EndIf}
${ExitDo}
${EndIf}
;If not "SubString", this could be "String"'s end
${If} $R5 >= $R4
StrCpy $R0 ``
${ExitDo}
${EndIf}
;If not, continue the loop
IntOp $R5 $R5 + 1
${Loop}

;Return output to user
Pop $R6
Pop $R5
Pop $R4
Pop $R3
Pop $R2
Exch
Pop $R1
Exch $R0
FunctionEnd
Binary file added ant/windows/nsis/console.ico
Binary file not shown.
13 changes: 12 additions & 1 deletion ant/windows/windows-launcher.nsi.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
!endif
!addincludedir "${basedir}/ant/windows/nsis/Include"
!include StdUtils.nsh
!include StrLoc.nsh
!include FindJava.nsh

!insertmacro GetParameters
Expand Down Expand Up @@ -54,7 +55,17 @@ Section
IfErrors +2 0
StrCpy $opts "$opts $R0"

Exec '"$javaw" $opts -jar "${JAR}" $params'
Var /GLOBAL command
StrCpy $command '"$javaw" $opts -jar "${JAR}" $params'

; If ends in "-console.exe", use "cmd /s /k" to launch
${StrLoc} $R1 "${nsis.outfile}" "-console.exe" "<"
${If} $R1 == "0"
ExpandEnvStrings $R2 %COMSPEC%
StrCpy $command '"$R2" /s /k "$command"'
${EndIf}

Exec $command
${If} ${RunningX64}
${EnableX64FSRedirection}
${EndIf}
Expand Down

0 comments on commit f39e9d4

Please sign in to comment.