Reputation: 2785
I want to build my script differently depend how I set the paramter.
I call my script like here:
makensis test.nsi -DFLAG=10
or makensis test.nsi -DFLAG=8
.
I tried to use it as a paramter like here
${If} ${FLAG} == 10
...
${IfElse} ${FLAG} == 8
....
${Else}
!error "Set the Flag."
${IfEnd}
But I still get only there error message.
I tried also to use GetParamters
from the documentation 4.12.
include FileFunc.nsh
!insertmacro GetParameters
!insertmacro GetOptions
${GetParameters} $R0
ClearErrors
${GetOptions} $R0 -DFLAG= $0
!echo $R0
But it only returns $R0
and not the value. What are the mistake or are there a besser strategy?
Upvotes: 0
Views: 101
Reputation: 101756
First off, you must execute it as makensis -DFLAG=8 test.nsi
because the parameters are parsed in same order as you pass them in. From the documentation:
Parameters are processed in order.
makensis /Ddef script.nsi
is not the same asmakensis script.nsi /Ddef
.
Secondly, you cannot mix ${If}
with !error
because the former is a run-time instruction and the latter is a compile-time instruction.
Use !if ${FLAG} = 8
or !ifdef FLAG
.
GetParameters
returns the parameters passed to the installer on the end-users system, not the compiler.
Upvotes: 1