Archive: Detect script path at compile time


Detect script path at compile time
Hi folks,

I was having some trouble excluding .svn version control subdirectories from getting packages with my application, but thanks to rsegal I could solve the problem.

One question remains: I need the full absolute path to the NSIS script (resp. to the directories I choose to wrap up into the installer). Since my source is tucked away in a version control database, the actual path where the NSIS script is compiled from is not fixed, but differs from time to time (and PC to PC).

Is there a way of detecting the script directory at _compile_ time? I am thinking of something like ${__DIR__}, similar to ${__FILE__}? I was not able to find any solution in the documentation or by googling around.

Kind regards,

Steve


There is a macro in the archive which you can use to extract the directory from a file name. Use that in conjunction with ${__FILE__} to get what you need.


The only way to change Compile Time strings is to create another program and make this second program run the first program with the information you want to change in the command line as defines.


Oops, you're right- I missed the compile time reference.
To the original poster- why do you need absolute paths. If you write your NSI with relative paths, you should be OK.
I am doing the same thing as you, i.e., my NSI file is in a version control system and the absolute path may vary from PC to PC.
However, since my scripts use relative paths and the version control relative directory structure is the same on every PC, I experience no problems compiling on different PCs.
If you really want the ${__DIR__} macro, a couple of options are to:
a) Modify the makensis source code and recompile, or,
b) Create a batch file in the same folder as the NSI file. In the batch file generate an NSH file which defines the ${__DIR__} macro for you and then include the NSH file in your main NSI. You can invoke the batch file using the !system command.


Thanks for your help, folks. The relative paths I required because I use rsegal's FolderList to exclude .svn version control files from being packaged into the installer and being deployed to the target system. Originally, rsegal told me that I must use absolute paths to specify the exclude directories, but (lucky my) I tried with relative paths and they - unexpectedly - worked, too.

It's good to know a way of doing at, though, in case I should need it in the future. Thanks again for your help.

Regards,

Steve