github.com/drud/ddev@v1.21.5-alpha1.0.20230226034409-94fcc4b94453/winpkg/include/ddev.nsh (about)

     1  /**
     2   * ddev.nsh - LogicLib extensions for handling DDEV checks and actions
     3   *
     4   * The following "expressions" are available:
     5   *
     6   * DdevIsInstalled checks if ddev.exe is available in the provided directory
     7   *
     8   *   ${If} ${DdevIsInstalled} "$PROGRAMFILES64\DDEV"
     9   *     DetailPrint "DDEV exists"
    10   *   ${Else}
    11   *     DetailPrint "$PROGRAMFILES64\DDEV\ddev.exe not found"
    12   *   ${EndIf}
    13   *
    14   *
    15   * DdevIsExecutable checks if ddev.exe can be executed in the provided directory
    16   *
    17   *   ${If} ${DdevIsExecutable} "$PROGRAMFILES64\DDEV"
    18   *     DetailPrint "DDEV is executable"
    19   *   ${Else}
    20   *     Pop $R0 ; Output
    21   *     DetailPrint "DDEV is not executable: $R0"
    22   *   ${EndIf}
    23   *
    24   *
    25   * DdevPowerOff executes ddev.exe poweroff in the provided directory
    26   *
    27   *   ${If} ${DdevPowerOff} "$PROGRAMFILES64\DDEV"
    28   *     DetailPrint "DDEV projects are powered off now"
    29   *   ${Else}
    30   *     Pop $R0 ; Output
    31   *     DetailPrint "DDEV power off failed: $R0"
    32   *   ${EndIf}
    33   *
    34   *
    35   * The following "statements" are available:
    36   *
    37   * DdevDoPowerOff executes ddev.exe poweroff in the provided directory
    38   *
    39   *   ${DdevDoPowerOff} "$PROGRAMFILES64\DDEV"
    40   *   Pop $R0 ; Output
    41   *   DetailPrint "DDEV power off output: $R0"
    42   *
    43   *
    44   * DDEV_NO_PLUGINS disables the usage of external plugins and relays on built
    45   * in functions only but on the other hand disable some functionality like
    46   * accessing the output of the command execution.
    47   *
    48   *   !define DDEV_NO_PLUGINS
    49   *   !include ddev.nsh
    50   *
    51   */
    52  
    53  !verbose push
    54  !verbose 3
    55  !ifndef DDEV_VERBOSITY
    56    !define DDEV_VERBOSITY 3
    57  !endif
    58  !define _DDEV_VERBOSITY ${DDEV_VERBOSITY}
    59  !undef DDEV_VERBOSITY
    60  !verbose ${_DDEV_VERBOSITY}
    61  
    62  !ifndef DDEV_NSH
    63    !define DDEV_NSH
    64  
    65    !ifndef DDEV_NO_PLUGINS
    66      ReserveFile /plugin nsExec.dll
    67    !endif
    68  
    69    !include LogicLib.nsh
    70  
    71    !macro _DdevIsInstalled _a _b _t _f
    72      !insertmacro _FileExists `${_a}` `${_b}\ddev.exe` `${_t}` `${_f}`
    73    !macroend
    74    !define DdevIsInstalled `"" DdevIsInstalled`
    75  
    76    !macro _DdevIsExecutable _a _b _t _f
    77      !insertmacro _LOGICLIB_TEMP
    78      !ifdef DDEV_NO_PLUGINS
    79        ExecWait `"${_b}\ddev.exe" version` $_LOGICLIB_TEMP
    80      !else
    81        nsExec::ExecToStack `"${_b}\ddev.exe" version`
    82        Pop $_LOGICLIB_TEMP ; Return, the Output remains on the stack
    83      !endif
    84      !insertmacro _== $_LOGICLIB_TEMP `0` `${_t}` `${_f}`
    85    !macroend
    86    !define DdevIsExecutable `"" DdevIsExecutable`
    87  
    88    !macro _DdevPowerOff _a _b _t _f
    89      !insertmacro _LOGICLIB_TEMP
    90      !insertmacro _DdevDoPowerOff `${_b}`
    91      Pop $_LOGICLIB_TEMP ; Return, the Output remains on the stack
    92      !insertmacro _== $_LOGICLIB_TEMP `0` `${_t}` `${_f}`
    93    !macroend
    94    !define DdevPowerOff `"" DdevPowerOff`
    95  
    96    !macro _DdevDoPowerOff _path
    97      !insertmacro _LOGICLIB_TEMP
    98      !ifdef DDEV_NO_PLUGINS
    99        ExecWait `"${_path}\ddev.exe" poweroff` $_LOGICLIB_TEMP
   100        Push $_LOGICLIB_TEMP
   101      !else
   102        nsExec::ExecToStack `"${_path}\ddev.exe" poweroff`
   103      !endif
   104    !macroend
   105    !define DdevDoPowerOff `!insertmacro _DdevDoPowerOff`
   106  
   107  !endif ; DDEV_NSH
   108  
   109  !verbose 3
   110  !define DDEV_VERBOSITY ${_DDEV_VERBOSITY}
   111  !undef _DDEV_VERBOSITY
   112  !verbose pop