Skip to content

Commit

Permalink
adding logging macros with nsis option. implements electron-userland#…
Browse files Browse the repository at this point in the history
  • Loading branch information
mmaietta committed Jul 4, 2021
1 parent 4293576 commit 0c12609
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/app-builder-lib/src/targets/nsis/NsisTarget.ts
Expand Up @@ -190,6 +190,7 @@ export class NsisTarget extends Target {
BUILD_RESOURCES_DIR: packager.info.buildResourcesDir,

APP_PACKAGE_NAME: appInfo.name,
ENABLE_LOGGING: !!options.debugLogging,
}
if (uninstallAppKey !== guid) {
defines.UNINSTALL_REGISTRY_KEY_2 = `Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\${guid}`
Expand Down
9 changes: 8 additions & 1 deletion packages/app-builder-lib/src/targets/nsis/nsisOptions.ts
Expand Up @@ -50,8 +50,15 @@ export interface CommonNsisOptions {
/**
* @private
*/

readonly customNsisBinary?: CustomNsisBinary | null

/**
* Whether or not to enable NSIS logging for debugging
* Note: Requires a debug-enabled NSIS build
* https://github.com/electron-userland/electron-builder/issues/5119#issuecomment-811353612
* @private
*/
readonly debugLogging?: boolean | null
}

export interface NsisOptions extends CommonNsisOptions, CommonWindowsInstallerConfiguration, TargetSpecificOptions {
Expand Down
15 changes: 15 additions & 0 deletions packages/app-builder-lib/templates/nsis/common.nsh
Expand Up @@ -10,6 +10,7 @@ SpaceTexts none
FileBufSize 64
Name "${PRODUCT_NAME}"

!define ENABLE_LOGGING
!define APP_EXECUTABLE_FILENAME "${PRODUCT_FILENAME}.exe"
!define UNINSTALL_FILENAME "Uninstall ${PRODUCT_FILENAME}.exe"

Expand Down Expand Up @@ -99,3 +100,17 @@ Name "${PRODUCT_NAME}"

${StdUtils.ExecShellAsUser} $0 "$launchLink" "open" "$startAppArgs"
!macroend

!define LogSet "!insertmacro LogSetMacro"
!macro LogSetMacro SETTING
!ifdef ENABLE_LOGGING
LogSet ${SETTING}
!endif
!macroend

!define LogText "!insertmacro LogTextMacro"
!macro LogTextMacro INPUT_TEXT
!ifdef ENABLE_LOGGING
LogText ${INPUT_TEXT}
!endif
!macroend
3 changes: 3 additions & 0 deletions packages/app-builder-lib/templates/nsis/installer.nsi
Expand Up @@ -40,6 +40,9 @@ Var oldMenuDirectory
!endif

Function .onInit
SetOutPath $INSTDIR
${LogSet} on

!ifmacrodef preInit
!insertmacro preInit
!endif
Expand Down
3 changes: 3 additions & 0 deletions packages/app-builder-lib/templates/nsis/uninstaller.nsh
@@ -1,4 +1,7 @@
Function un.onInit
SetOutPath $INSTDIR
${LogSet} on

!insertmacro check64BitAndSetRegView

${IfNot} ${Silent}
Expand Down

0 comments on commit 0c12609

Please sign in to comment.