# Compiling Delphi: Iterate through platform and config

**URL:** https://www.finalbuilder.com/forums/t/compiling-delphi-iterate-through-platform-and-config/2570
**Category:** Discussion
**Created:** [September 18, 2017, 1:47am UTC](https://www.finalbuilder.com/forums/t/compiling-delphi-iterate-through-platform-and-config/2570 "2017-09-18T01:47:39Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![ikrigsman](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/ikrigsman/32/1800_2.png) [@ikrigsman](https://www.finalbuilder.com/forums/u/ikrigsman)
#### Post date: [September 18, 2017, 1:47am UTC](https://www.finalbuilder.com/forums/t/compiling-delphi-iterate-through-platform-and-config/2570/1 "2017-09-18T01:47:39Z")

</div>

I currently have 4 x actions that separately compile (Delphi) each of the win32/win64 and release/debug settings for a&nbsp;project.  
  
I’d like to streamline that into a single action, and figure nesting two levels of list iterators would work, each assigning&nbsp;variables I’ve created: %Platform% and %Config%.  
  
I&nbsp;can set the Delphi Action config property to %CONFIG%, but the Platform cannot be set.  
  
Another topic mentions Action.Platform in a VBScript, but&nbsp;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

---

<div class="post-metadata">

### Author: ![Vincent](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/vincent/32/938_2.png) [@Vincent](https://www.finalbuilder.com/forums/u/Vincent)
#### Post date: [September 18, 2017, 2:08am UTC](https://www.finalbuilder.com/forums/t/compiling-delphi-iterate-through-platform-and-config/2570/2 "2017-09-18T02:08:36Z")

</div>

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](https://www.finalbuilder.com/resources/blogs/postid/742/code-signing-changes-for-2016)

---

<div class="post-metadata">

### Author: ![ikrigsman](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/ikrigsman/32/1800_2.png) [@ikrigsman](https://www.finalbuilder.com/forums/u/ikrigsman)
#### Post date: [September 18, 2017, 2:42am UTC](https://www.finalbuilder.com/forums/t/compiling-delphi-iterate-through-platform-and-config/2570/3 "2017-09-18T02:42:10Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![ikrigsman](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/ikrigsman/32/1800_2.png) [@ikrigsman](https://www.finalbuilder.com/forums/u/ikrigsman)
#### Post date: [October 10, 2017, 12:25pm UTC](https://www.finalbuilder.com/forums/t/compiling-delphi-iterate-through-platform-and-config/2570/4 "2017-10-10T12:25:34Z")

</div>

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 🙂 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

---

<div class="post-metadata">

### Author: ![Vincent](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/vincent/32/938_2.png) [@Vincent](https://www.finalbuilder.com/forums/u/Vincent)
#### Post date: [October 10, 2017, 10:43am UTC](https://www.finalbuilder.com/forums/t/compiling-delphi-iterate-through-platform-and-config/2570/5 "2017-10-10T10:43:10Z")

</div>

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

---

<div class="post-metadata">

### Author: ![ikrigsman](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/ikrigsman/32/1800_2.png) [@ikrigsman](https://www.finalbuilder.com/forums/u/ikrigsman)
#### Post date: [October 12, 2017, 5:50am UTC](https://www.finalbuilder.com/forums/t/compiling-delphi-iterate-through-platform-and-config/2570/6 "2017-10-12T05:50:52Z")

</div>

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
