langdon
15th November 2011 21:16 UTC
Variable Source Path
I'm trying to get my NSIS script able to be compiled on two different machines with different directory structures. I thought I could simply:
Path
>Function .OnInit
StrCpy $Path "c:\test.txt"
>FunctionEnd
Section
File "${Path}"
>SectionEnd
>
...but obviously variables are for run-time use only. What I need is some sort of compile-time constant. I was hoping to be able to create an NSH file on my machine that sets the source path to "c:\source_files", and the build machine could have the same NSH file, but point it do d:\project\latest". Or maybe even something simpler?
Any ideas?
TIA!
Anders
15th November 2011 22:12 UTC
mypath.nsh:
!define thepath "c:\foo\bar"
install.nsi:
!include "mypath.nsh"
...
File "${thepath}\somefile.exe"
MSG
16th November 2011 08:25 UTC
No real need to use an nsh for that, of course. Just put the define at the top of the script.
langdon
16th November 2011 15:24 UTC
Thanks Anders!
@MSG, putting the !define at the top of the script won't allow that same script to run on multiple environments.
demiller9
16th November 2011 17:03 UTC
You can use relative paths in the define, or directly in the FILE commands. I do this to work at home and at the office, where my NSIS folders are on different drives
!define Addons "\NSIS Installers\Addons"
!AddPluginDir "${Addons}\Plugins"
!AddIncludeDir "${Addons}\Include"
...
!define SRCDIR ".\Ipls.3177"
File "${SRCDIR}\ArchHelpUtil*.ocx"