Old 16th May 2006, 13:19   #1
surfdabbler
Junior Member
 
Join Date: May 2006
Posts: 3
Passing data through to !included files

I have a set of similar installations based on one common NSIS script. Mostly the same fileset, but a different main exe, different product name, different Start Menu name, etc. (i.e. different versions for different customers).

I use an external script to swap in the appropriate exe to a standard name before running the script.

I have tried using 2 nsi files, as follows...

product1.nsi

!define APP_NAME "Product1"
!include "common.nsi"

And common.nsi then uses APP_NAME for the Name, install dir, StartMenu naming, etc. But, APP_NAME doesn't seem to carry through to the second file. It only works if I define it in common.nsi. Any hints on how to make this work, or different ways of doing this?

I've tried using a Var, but it doesn't seem to work either. I can define "Name" in product1.nsi, and it carries through to common.nsi, but that doesn't do everything I need it to do.
surfdabbler is offline   Reply With Quote
Old 16th May 2006, 17:08   #2
Red Wine
Forum King
 
Red Wine's Avatar
 
Join Date: Mar 2006
Location: Ath. GR
Posts: 2,078
compile common.nsi and use a header with all needed info.
i.e. !include header.nsh where header.nsh could be like this:
!define APP_NAME 'my app'
!define VERSION '1.5.0.0'
!define MAIN_EXE 'c:\temp\myapp.exe'
etc

Quick AVI Creator - Quick and easy convert from DVD/MPEG/AVI/MKV to AVI/MP4/MKV
Quick AVI Creator entirely edited with NSIS and entirely upgraded to Unicode NSIS
Red Wine is offline   Reply With Quote
Old 16th May 2006, 23:45   #3
surfdabbler
Junior Member
 
Join Date: May 2006
Posts: 3
Thanks for the reply.

I don't understand how using a header file allows me to select at compile time which values to use. I would have to somehow selectively include one of several different .nsh files, or write several common.nsi files to include the different headers, which defeats the whole purpose of common.nsi.

My external shell script knows about the different versions, but how can this information be handled in the NSI scripting?

The shell script can copy the appropriate product1.nsh or product2.nsh to a standard name, product.nsh, and common.nsi can include product.nsh, but surely there's a nicer way...?
surfdabbler is offline   Reply With Quote
Old 17th May 2006, 00:41   #4
Comperio
Major Dude
 
Comperio's Avatar
 
Join Date: Jan 2005
Location: Oregon Coast
Posts: 737
One thing that I do is create a separate EXE using an NSIS script that generates an custom page that asks the user options he/she wants to use. This EXE would then create a header file on the fly.

Then, in your main script, add the following lines of code:
code:

!system "SelectBuild.exe" ### this is the name of your EXE
!include "ProductVersion.nsh" ### this is the header that is created
; the rest of your code goes here...



The attached sample script helps illustrate the header creation file.

Anther option:
Pass a define using the '/d' command on MakeNSIS.exe and then use !ifdef blocks for each of your products.

For more ideas, have a look at the NSIS help manual, compile-time commands (chapter 5)
Attached Files
File Type: zip demo - create header.zip (968 Bytes, 264 views)
Comperio is offline   Reply With Quote
Old 17th May 2006, 04:53   #5
Red Wine
Forum King
 
Red Wine's Avatar
 
Join Date: Mar 2006
Location: Ath. GR
Posts: 2,078
Quote:
I don't understand how using a header file allows me to select at compile time which values to use. I would have to somehow selectively include one of several different .nsh files, or write several common.nsi files to include the different headers, which defeats the whole purpose of common.nsi.
use !ifdef on header.nsh

!ifdef PROG_1
<include this and that>
!endif

!ifdef PROG_2
..............
!endif

and in nsi file:
!define PROG_1

Quick AVI Creator - Quick and easy convert from DVD/MPEG/AVI/MKV to AVI/MP4/MKV
Quick AVI Creator entirely edited with NSIS and entirely upgraded to Unicode NSIS
Red Wine is offline   Reply With Quote
Old 17th May 2006, 05:15   #6
surfdabbler
Junior Member
 
Join Date: May 2006
Posts: 3
This goes back to my original solution of having multiple main files, that include common.nsi. And after trying this for several hours yesterday, I tried it again today, and it actually works now. I don't know what's different, but it is all good. Thanks for your help!
surfdabbler 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