12
votes

I want to dynamically derive the source folder (and destination folder) for 32/64 bit installations. So how can I specify that in the [Files] section of Inno setup. The following gives a compilation error:->

[Files]
Source: {#MySourcePath}\{code:GetSourceLibFolder}\*.jar; DestDir: {code:GetAppDir}\lib\; 

I have the GetSourceLibFolder() and GetAppDir() function defined in the code section. The functions are very simple and just return a variable:

function GetSourceLibFolder(Param: String): String;
begin
  Result:= SourceLibFolder;
end;

function GetSourceBinFolder(Param: String): String;
begin
  Result:= SourceBinFolder;
end;

Thanks !

1
I am not sure whether we can call our codes from [Code] and use them in other places in InnoSetup script. How about using #define statement to create a string that applies your functions (just like in https://stackguides.com/questions/2329979/can-the-setup-filename-be-derived-from-the-executable-file-version-number) - ee.
Where is this source lib folder: is it in the source folder relative to the base folder of your InnoSetup script? Why do you concern with the destination folder when you can just use {app}? For example: let say your InnoSetup script file is in .\ folder and your jar libraries are in .\install\lib and you want them to be in lib folder of your application folder {app}, you can define Source: "install\lib\*.jar"; DestDir: "{app}\lib" The easy way: you can have a separate InnoSetup script for each 32-bit and 64-bit setup by defining different source folder in each script file. - ecle
@eee: I want to have a single installer for 32 and 64 bit systems and so I have 2 different "lib" folders, viz. lib-32 and lib-64, which I set dynamically and hence want to read them dynamically. - Saurabh
InnoSetup allows you to pass user-defined variable from its command argument so you can use it to differentiate both lib folders, in Ant task example: <exec executable="C:\Program Files\Inno Setup 5\ISCC.exe"><arg value="${basedir}\application.iss"/><arg value="/dMyLibFolder=lib-32"/></exec>. Then, in the script, you can use {#MyLibFolder} - ecle

1 Answers

6
votes

The source path needs to be used at compile time (unless you have the external flag) which means you must use ISPP and a #define. The [Code] section is only for run/install time code so will work for the target path.

If you provide the code for your GetSourceLibFolder function, someone can convert it to ISPP.