Skip to content
⌘ NSIS Forum Archive

Conditional compilation for plug-ins

4 posts

tony18#

Conditional compilation for plug-ins

Hello
I develop plug-ins for graphic host applications. And my code for conditional compilation
doesn't work properly. I need to compile the section if the application is found.
Seems like I cannot use a user variable in !define /math...
My code:
Function .onInit

ClearErrors
ReadRegStr $Path HKLM "Software\Application\Version" "PluginPath"
IfErrors 0 +3
IntOp $somedef 0 + 0
goto not_found
StrCpy $Application "Application"
IntOp $somedef 0 + 1
not_found:
!define /math result ${somedef} * 1

FunctionEnd


!if ${result} != 0

Section "$Application"

  SetOutPath $Path
  File "${PLUGIN_FILE}"

SectionEnd

!endif
Anders#
All instructions starting with ! only work at compile time, you should try the IF in logiclib.nsh
tony18#
Conditional compilation for plug-ins (Space Required🙂

Thanks. But the problem remains. Actually the problem is that the installer
shows Space Required: 5.8 Mb (in my case) even if the lines inside the section are not executed.
How can I solve this?

!include LogicLib.nsh

Function .onInit

ClearErrors
ReadRegStr $Path HKLM "Software\Application\Version" "PluginPath"
IfErrors 0 +3
IntOp $somedef 0 + 0
goto not_found
StrCpy $Application "Application"
IntOp $somedef 0 + 1
not_found:

FunctionEnd


Section "$Application"

${If} $somedef != 0

  SetOutPath $Path
  File "${PLUGIN_FILE}"

${EndIf}

SectionEnd