Old 26th November 2002, 08:14   #1
e-novative
Junior Member
 
Join Date: Nov 2002
Location: Munich, Germany
Posts: 16
!define and environment variable

Hi all,

My installation requires a version number that is !define'd in the NSIS script. Is it possible to read a value from an environment variable (or pass a value to the compiler via command line) *at compile time*?

This would allow my "create release" batch to pass the version number to the NSIS script, thus freeing me from the need to set the version number there manually (which is rather error-prone).

Or is it, by some way, possible the other way round? Can the compiler "return" the version number to the calling batch?

I couldn't find anything useful when searching the forum and the net. Any idea or pointer would be greatly appreciated.

Regards,

Steve
e-novative is offline   Reply With Quote
Old 26th November 2002, 08:41   #2
dbareis
Member
 
Join Date: Apr 2001
Posts: 77
I don't know whether NSIS can do it or not, someone else may provide an answer, but there are other preprocessors. My free PPWIZARD will certainly allow you to do this.

Bye
Dennis
dbareis is offline   Reply With Quote
Old 26th November 2002, 12:58   #3
dselkirk
Senior Member
 
Join Date: Aug 2002
Posts: 118
Use the command line option /D to define you version.

makensis.exe /DVERSION=2 file.nsi

Make sure your script doesn't over right it though by doing the following.

!ifndef VERSION
!define VERSION 1
!endif
dselkirk is offline   Reply With Quote
Old 26th November 2002, 13:46   #4
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
Quote:
I couldn't find anything useful when searching the forum and the net. Any idea or pointer would be greatly appreciated.
Well, you didn't search hard enough... It's in the FAQ on the top of the page

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 26th November 2002, 13:58   #5
e-novative
Junior Member
 
Join Date: Nov 2002
Location: Munich, Germany
Posts: 16
Works perfect, thanks a lot.

I must have been blind, though ... shouldn't have worked so late last night!

Steve
e-novative is offline   Reply With Quote
Old 26th November 2002, 14:33   #6
dselkirk
Senior Member
 
Join Date: Aug 2002
Posts: 118
no problem and i know the feeling, hehe
dselkirk is offline   Reply With Quote
Old 11th December 2002, 18:39   #7
HelluvaEngineer
Junior Member
 
Join Date: Jun 2002
Posts: 25
Quote:
Originally posted by dselkirk
Use the command line option /D to define you version.

makensis.exe /DVERSION=2 file.nsi

Make sure your script doesn't over right it though by doing the following.

!ifndef VERSION
!define VERSION 1
!endif
Ok, you just lost me. I am using code similar to what you said above, and it's not working. It shouldn't enter the ifndef unless it's not defined, right?

Lookie here:

I call

Makensis /V3 /NOCONFIG /HDRINFO /CD /DMAJORVER=2 /DMINORVER=2 /DMICROVER=0 TechDemo.nsi

In the nsi, I have this code:

!ifndef ${MAJORVER}
!warning "MAJORVER not defined."
!define MAJORVER 0
!endif

!ifndef ${MINORVER}
!warning "MINORVER not defined."
!define MINORVER 0
!endif

!ifndef ${MICROVER}
!warning "MICROVER not defined."
!define MICROVER 0
!endif

But get this error!:

warning: !warning: MAJORVER not defined. (TechDemo.nsi:35)

!define: "MAJORVER" already defined!
Error in script "TechDemo.nsi" on line 36 -- aborting creation process

Am I overlooking something?
HelluvaEngineer is offline   Reply With Quote
Old 11th December 2002, 18:45   #8
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
You should call the ifndef like this:

!ifndef MAJORVER

${MAJORVER} translates to its value and because of that NSIS tries to see if 2 is not defined, which is of course true.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 11th December 2002, 18:51   #9
HelluvaEngineer
Junior Member
 
Join Date: Jun 2002
Posts: 25
OK, in retrospect that should have been obvious. Thank you!
HelluvaEngineer is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump