Compiling Delphi: Iterate through platform and config

I currently have 4 x actions that separately compile (Delphi) each of the win32/win64 and release/debug settings for a project.

I’d like to streamline that into a single action, and figure nesting two levels of list iterators would work, each assigning variables I’ve created: %Platform% and %Config%.

I can set the Delphi Action config property to %CONFIG%, but the Platform cannot be set.

Another topic mentions Action.Platform in a VBScript, but I haven’t worked with scripting. (I only recently discovered Targets for code signing!)

Any suggestions appreciated.

Footnote: The FB project actually includes 5 Delphi programs, all with the same requirement (along with madExcept on each), thus my interest in reducing the number of Delphi actions I need to maintain.

TIA

Ian

Hi Ian

Scripting is pretty simple. Action.Platform is actually an enum, which wasn’t expose to scripting until now, however it works as an integer

TPlatform = (Win32, Win64, OSX32, Linux64);

So

Win32 = 0
Win64 = 1
OSX32 = 2
Linux64 = 3

So add a project variable called CompilerPlatform, set the type to integer, default value 0 (win32)

Then select the action, go to the script editor, on the Before Action tab, select Javascript as the language (I avoid vbscript!) :

Action.Platform = FBVariables.CompilerPlatform;

That’s all there is to it.

BTW, for code signing, I have an example project on github you can borrow ideas from - see this post https://www.finalbuilder.com/resour…s-for-2016

Thanks Vincent, I’ll give that a try.

Oh, WRT code signing - I had found that example and implemented it. So great to find something I could drop in without pulling my hair out - appreciated.

Hi Vincent

Quick feedback: That worked like a charm, thanks.

One further question: The delphi compile is followed by a madExcept action, so the EXE and MAP files path is set accordingly:

Eg.
%PROJECTDIR%\bin%ProgramName%%PLATFORM%%CompilerConfig%%ProgramName%.exe

Now that I’m an expert in the Script Editor :slight_smile: and since this is all under an interation of CompilerConfig (0,1), I’ve added the following JavaScript to resolve %PLATFORM%


if (FBVariables.CompilerPlatform == 0)
{ FBVariables.Platform = ‘Win32’}
else
{ FBVariables.Platform = ‘Win64’};


This works, but smells.
For a start, I include %PLATFORM% in the Action description but it doesn’t get resolved in the build log.

Can you suggest a more elegant way? Eg. Does TPlatform have a corresponding string representation (although I figure it is out of scope by this time).
Declaring a string array if one doesn’t exist would be a small improvement.

TIA

Ian


Hi Ian

The delphi action implements it’s own variable namespace as it needs to virtualise a bunch of variables that delphi uses (to deal with multiple delphi versions on the same machine), and Platform is one of them. So when you set FBVariables.Platform in a script event on the delphi action, it would not be seen from other actions (it would from child actions, as variable namespaces are inherited down from the parent action).

So the trick is, use a different variable name.

The scriptiong support doesn’t really know about TPlatform, as VBScript and JavaScript do not support enums. A few weeks ago I did add constants for the TPlatform values, so you will be able to use Win32, Win64, OSX32, Linux64 in scripts. We’ll try to get an update out in the next few days, working on an out of memory issue at the moment (msxml is the culprit), as soon as I solve that I’ll get a release out.

These are the variables that the Delphi action virtualises in it’s own variable namespace :

CONFIG
PLATFORM
BDS
BDSLIB
BDSBIN
BDSINCLUDE
BDSPLATFORMSDKSDIR
BDSUSERDIR
BDSPROJECTSDIR
BDSCOMMONDIR
BDSCatalogRepository
LANGDIR

That sounds very promising, thanks.

I do happen to have set the madExcept action as a (the) child of the Delphi one, so perhaps a variation of what I have might work… but will hold off for the next build.

Cheers, Ian