Pass custom parameters to .iss script [duplicate] - jenkins

I want to pass a path (via command line arg /D to the script compiler) to my executable to let my script determine the application version number using GetFileVersion, but my syntax isn't correct. How do I pass an argument to GetFileVersion?
The error is: Illegal character in input file: '#' (0x23)
#define srcpath SOURCEPATH
#define ApplicationVersion GetFileVersion(#srcpath)//error here!!!!!!
[Setup]
AppVersion={#ApplicationVersion}
[Files]
Source: "MyDllTesting.dll"; Flags: dontcopy
Source: "{srcpath}MyApplication1.exe"; DestDir: "{app}\MyApplication1"

First, SOURCEPATH is a Inno Setup preprocessor predefined variable, so you need to use another name for your command-line "variable". I'll be using SOURCE_PATH.
Second, the correct syntax is:
#define ApplicationVersion GetFileVersion(SOURCE_PATH)
(i.e. no hash)
Why no hash, is covered in my answer to
Why preprocessor behaves differently in #include directive then in [Files] section Inno Setup script
Though the reason is basically the same, why you use no hash before SOURCEPATH here:
#define srcpath SOURCEPATH
On the contrary you are missing the hash in the [Files] section entry. The correct syntax is:
[Files]
Source: "{#srcpath}MyApplication1.exe"; DestDir: "{app}\MyApplication1"
And there's no need to define srcpath variable. SOURCE_PATH is variable too. So you can use it directly in any expression:
#define ApplicationVersion GetFileVersion(SOURCE_PATH)
[Files]
Source: "{#SOURCE_PATH}MyApplication1.exe"; DestDir: "{app}\MyApplication1"

From the docs on "Inno Setup Preprocessor: Command Line Compiler Execution" I could define a command line parameter called "MyCustomParam" by using /D option like this:
.\ISCC.exe /DMyCustomParam=MyParamValue "MySetupScript.iss"
and then I wrote my setup script like the following, which gets the value which was defined for the parameter on the command line:
[Setup]
AppName={#MyCustomParam}

Related

Lua require does not work but file is in the trace

I'm trying to require files in Lua, in one case it is working, but when I want to simplify the requirements in updating the LUA PATH the file is not found, but it is in the trace!
To reproduce my require problem I did the test with the package.searchpath function, which takes the required key and the Lua path in arguments.
So the code :
print('MY LUA PATH')
local myLuaPath = "?;?.lua;D:\\Projets\\wow-addon\\HeyThere\\?;D:\\Projets\\wow-addon\\HeyThere\\src\\HeyThere\\?;D:\\Projets\\wow-addon\\HeyThere\\test\\HeyThere\\?"
print(myLuaPath)
print('package search core.add-test')
print(package.searchpath('core.add-test', myLuaPath))
print('package search test.HeyThere.core.add-test')
print(package.searchpath('test.HeyThere.core.add-test', myLuaPath))
The result :
MY LUA PATH
?;?.lua;D:\Projets\wow-addon\HeyThere\?;D:\Projets\wow-addon\HeyThere\src\HeyThere\?;D:\Projets\wow-addon\HeyThere\test\HeyThere\?
package search core.add-test
nil no file 'core\add-test'
no file 'core\add-test.lua'
no file 'D:\Projets\wow-addon\HeyThere\core\add-test'
no file 'D:\Projets\wow-addon\HeyThere\src\HeyThere\core\add-test'
no file 'D:\Projets\wow-addon\HeyThere\test\HeyThere\core\add-test'
package search test.HeyThere.core.add-test
test\HeyThere\core\add-test.lua
So the first try with 'core.add-test' should work with the 'D:\Projets\wow-addon\HeyThere\test\HeyThere\?' value in the path but fails...
In the trace, there is the file I want!
no file 'D:\Projets\wow-addon\HeyThere\test\HeyThere\core\add-test'
But with the same LUA PATH but starting in a parent folder the file is found... Second test with 'test.HeyThere.core.add-test' found from the 'D:\Projets\wow-addon\HeyThere\?'
-> test\HeyThere\core\add-test.lua
Can someone explains to me why it doesn't work the first time?
EDIT :
My current directory is D:\Projets\wow-addon\HeyThere
My lua.exe is in D:\Projets\wow-addon\HeyThere\bin\lua but is added to my PATH variable (I'm on Windows)
I set the LUA_PATH environment variable and execute
lua "test\test-suite.lua" -v
The code inside test-suite.lua is the test code described above
As #EgorSkriptunoff suggested, adding file extansion in the path resolve the problem...
Ex:
Wrong path D:\Projets\wow-addon\HeyThere\?
Good path D:\Projets\wow-addon\HeyThere\?.lua
The extension should be in the path variable because in the require the dot is replace and used as a folder separator.

lua bindings for bullet

are there any lua bindings for libbullet?
tried using swig and simply %includeing the BulletDynamicsCommon.h:
%module ybullet
%{
#include <btBulletDynamicsCommon.h>
%}
%include "%BULLET_inc_path%/btBulletDynamicsCommon.h"
but that doesn't work, as it also just includes other files, which is ignored by swig:
ybullet/helloWorld.lua:4: attempt to call field 'btDbvtBroadphase' (a nil value)
my lua file is ported from http://bulletphysics.org/mediawiki-1.5.8/index.php/Hello_World
found out a way using swig and a zsh script to automagically extract the %includes from the header files to get this: https://github.com/nonchip/YEngine/blob/master/ybullet/ybullet.i.tpl

Unable to concatenate defined string and the text within the path to image file

I got a problem with setting a path to image within the resource file (.rc).
For some reasone it was not possible to concatenate defined string and the text.
e.g.
File1:
#define Path "Brand_1"
File2:
#include File1
Logo BITMAP Path "\Logo.bmp"
Borland resource compiler (5.4) throws error message: 39: Cannot open file: Brand_1
EDIT:
My question would be: Is is possible to combine the path for loading image using resource string variable and a string (file name).
Also, project I'm working on relates to a file (Logo.bmp) being present in two locations. I would like to have a switch (.bat file) to generate a different resouce file depending on requirements.
Thanks.
BRCC32 accepts -i as search path seperated by semicolon, so you could create a bat file like this
compile_res.bat
brcc32 -ic:\mypath1;c:\mypath2 resource_script
and you define your resource_script as normal, for ex:
resource_script.rc
myImg BITMAP Logo.bmp
myDOC RCDATA mydoc.doc
when you run the compile_res.bat, it will run the brcc32.exe with the search path, and having the bat file saves you from retyping the search path every time.
You're not concatenating anything. You're compiling to Logo BITMAP "Brand_1" "\Logo.bmp", and "Brand_1" isn't a valid path to a bitmap file.
#define in the resource compiler acts sort of like find/replace in a text processor - not exactly, but close enough in this case.
You might get by (untested) with removing the quotes and space between them, as long as there are no space characters in either the path or filename; otherwise, you're probably out of luck. (Not sure what you're trying to accomplish, anyway.)

How do I use a macro in the data portion of a resource script?

I have the following macros header file (system.h),
#define rt_metadata 8000
#define dir_metadata "db\metadata"
and resource file (system.db.metadata.rc)
#include "system.h"
SY_ALLOWDATE rt_metadata db\metadata\SY.AllowDate.xml
How do I replace the db\metadata with dir_metadata in the resource file so that it will become something like dir_metadata\SY.AllowDate.xml?
This is done by the resource compiler (BRCC32.EXE was Borland's version, and Microsoft had one as well).
Macros are done by a precompiler just before compiling; BRCC32 handled both the precompilation and compilation steps of converting an RC file into a binary RES file.
So you can get the macro converted by using the commandline resource compiler:
brcc32 yourresourcefile.rc
You can also define the macro on the commandline as well
brcc32 -dYOURMACRO=yourstring yourresourcefile.rc

Can one use environment variables in Inno Setup scripts?

I need to find a way to reference environment variables INSIDE the Inno Setup script file (.iss)...
I've found plenty of references to MODIFYING the environment from an .iss, but none on how to actually use it. Is this possible?
I ran into the same problem when trying to specify the source location of files in the [Files] section. I used the GetEnv function to define a new constant.
#define Qt5 GetEnv('QT5')
[Files]
Source: {#Qt5}\bin\Qt5Concurrent.dll; DestDir: {app};
According to this page in the Inno Setup documentation, the value of environment variables can be retrieved using the following syntax:
{%name|default}
The syntax is different, if you want to resolve the variable on install-time or on compile-time. That's why there are two existing answers that show completely different solutions that work for some and not others. Because different readers look for different things here.
On install-time
If you need to resolve the variable on the target machine, while installing, you can use the {%NAME|DefaultValue} "constant".
[Files]
Source: "MyApp.dat"; Dest: "{%MYAPP_DATA_PATH|{app}}"
If you need to resolve the variable on the target machine in Pascal Script code, you can use GetEnv support function.
Path := GetEnv('MYAPP_DATA_PATH');
On compile-time
If you need to resolve the variable on the source machine, while compiling the installer, you can use GetEnv preprocessor function:
[Files]
Source: "MyApp.dat"; Dest: "{#GetEnv('MYAPP_DATA_PATH')}"
You can use the same syntax even in Pascal Script, though it would make sense only in very special circumstances.
Path := '{#GetEnv('MYAPP_DATA_PATH')}';
It can be even easier:
OutputDir={#GetEnv("TEMP")}\
If the variable TEMP does not exist then the default value will be used - ..\..\distr\ ))))
OutputDir={#StringChange(GetEnv("TEMP")+"\", StringChange(GetMD5OfString(GetEnv("TEMP")), "d41d8cd98f00b204e9800998ecf8427e", "\"), "..\..\distr\")}
I couldn't figure out how to use the {%name|default} syntax, so this is how I implemented the same (I needed to specify a default value when the env var is not present):
#if GetEnv('EXTRA_FILE_LOCATION') != ""
#define EXTRA_LOCATION=GetEnv('EXTRA_FILE_LOCATION')
#else
#define EXTRA_LOCATION="."
#endif
Source: {#EXTRA_LOCATION}\ExtraFile.data; DestDir: {app};

Resources