[英]How do I have a function in NSIS called just while compiling the script?
I want to call a function (which calculates my version number) when my NSIS script is compiling, but not while it's executing. 我想在编译NSIS脚本时调用一个函数(该函数会计算我的版本号),而不是在执行时调用。 Is this possible?
这可能吗? It uses
nsExec
and basic string manipulation functions. 它使用
nsExec
和基本的字符串操作功能。
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). 它的作用是:调用calculate_version.exe(这可能是一个简单的NSIS脚本,它会调用您的函数)。 This executable should output the version number to tempfile.tmp.
该可执行文件应将版本号输出到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
). 在此示例中,我选择了“ APP_VERSION = something”(可以使用
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.
然后将$ {APPVERSION}设置为在此找到的任何内容。
Sweet! 甜! It's possible: see http://nsis.sourceforge.net/Invoking_NSIS_run-time_commands_on_compile-time
有可能:请参阅http://nsis.sourceforge.net/Invoking_NSIS_run-time_commands_on_compile-time
The basic idea is: 基本思想是:
!system
, at compile time) in your main script - and this generates a text file (which !define
s whatever you need) !system
)-这将生成一个文本文件( !define
您的需要) !include
the text file in your main script !include
在主脚本中!include
文本文件 and presto! 和presto! You've got some stuff generated at compile time in your script.
脚本编译时会生成一些东西。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.