I want to call a function (which calculates my version number) when my NSIS script is compiling, but not while it's executing. Is this possible? It uses nsExec
and basic string manipulation functions.
views:
373answers:
2
+1
A:
Sweet! It's possible: see http://nsis.sourceforge.net/Invoking_NSIS_run-time_commands_on_compile-time
The basic idea is:
- Compile a separate script that generates an executable
- Run the executable (via
!system
, at compile time) in your main script - and this generates a text file (which!define
s whatever you need) !include
the text file in your main script
and presto! You've got some stuff generated at compile time in your script.
Jesse Beder
2009-02-09 08:06:37
+2
A:
You could do this:
!system '"calculate_version.exe" "tempfile.tmp"'
!searchparse /file "tempfile.tmp" `APP_VERSION=` APPVERSION
What this does: calls calculate_version.exe (this could be a simple NSIS script which calls your function). This executable should output the version number to tempfile.tmp. The format of the version doesn't matter; in this example I've chosen "APP_VERSION=something" (this could be written using WriteINIStr
).
In the next line, we open the temp file and search it for the line we wrote; then we set ${APPVERSION} to whatever we find there.
Piskvor
2009-02-09 08:07:06
I actually prefer the idea in the article I cited (it's almost the same as yours) since the hard work gets done in the associated script (writing the !defines, and so on) instead of having to parse what you need in the main script.
Jesse Beder
2009-02-09 08:44:47
You have a point. On the other hand, I don't really like the idea of compiling in a file which may or may not be the output of the given program. A matter of preference, I guess =)
Piskvor
2009-02-09 10:03:01