Archive: Compile with name/version from .ini file


Compile with name/version from .ini file
  Hi !
We are using variables in our application to store application version number,so the same in NSI file.
When we build another version,we need to modify version into NSI file and also in our source code app.
Is there any way to store version in just on single place,just like .ini file ant read it also at compile time ?

Thanks !


Write a program (it can be written in NSIS) which reads the INI file and generates an NSH file with !defines in it which you !include in your main script.

Stu


Thanks !
yes this is a way but if I understood you I must again do 2 things :
1. edit ini file
2. run exe to generate new NSH


You automate the execution of the exe using !system. On the next line in your script you !include the outputted file. You can then use !delfile to delete the outputted file if you wish (or use the del command via !system).

Stu


Thanks Afrow !
This my code and seems to work :up: :
genNSH.nsi:


SilentInstall silent


>var v_major
>var v_minor
>var v_build
>var v_revis

Name "genNSH"

>OutFile "genNSH.exe"

>RequestExecutionLevel user


Section ""
SetAutoClose true
SetOverwrite on


SectionEnd

>Function .onInit
ReadINIStr $v_major "\AA\my.ini" "Versiuni" "major"
>ReadINIStr $v_minor "\AA\my.ini" "Versiuni" "minor"
>ReadINIStr $v_build "\AA\my.ini" "Versiuni" "build"
>ReadINIStr $v_revis "\AA\my.ini" "Versiuni" "revision"


>FileOpen $R0 "version.nsh" w
FileWrite $R0 "!define v_major '$v_major'"
FileWrite $R0 "$\r$\n"
FileWrite $R0 "!define v_minor '$v_minor'"
FileWrite $R0 "$\r$\n"
FileWrite $R0 "!define v_build '$v_build'"
FileWrite $R0 "$\r$\n"
FileWrite $R0 "!define v_revis '$v_revis'"
FileClose $R0
FunctionEnd
>
usage :

'\AA\genNSH.exe'


>!include "version.nsh"

>Name "Example1"
>OutFile "example_${v_major}_${v_minor}_${v_build}_${v_revis}.exe"

>InstallDir $DESKTOPExample1

RequestExecutionLevel user

>;--------------------------------


>Page directory
Page instfiles

Section ""

SetOutPath $INSTDIR

SectionEnd
>
my.ini:
[ Versiuni ]
major=1
minor=0
build=0
revision=6