Recent

Author Topic: Automation of executable suffix generation based on architecture and target?  (Read 4358 times)

avra

  • Hero Member
  • *****
  • Posts: 2514
    • Additional info
Let's say that my application project is called myappname. I would like to have compiler generate application executable names dependant on the architecture and target, something similar to this:

myappname-win32-i386.exe
myappname-win64-amd64.exe
myappname-lin32-i386
myappname-lin64-amd64

Besides these I am eventually thinking about later adding linux arm variants and osx.

Is there an easy way to achieve this, or do I have to repeat this boring work by hand each time?  :( %) :(
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

DonAlfredo

  • Hero Member
  • *****
  • Posts: 1739
Lazarus -> Project Options -> Path -> Target Filename:

bindir\$NameOnly($(ProjFile))-$(TargetCPU)-$(TargetOS)

avra

  • Hero Member
  • *****
  • Posts: 2514
    • Additional info
bindir\$NameOnly($(ProjFile))-$(TargetCPU)-$(TargetOS)
As always, you have been very helpfull. Thanks!  ;)
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

Thaddy

  • Hero Member
  • *****
  • Posts: 14360
  • Sensorship about opinions does not belong here.
It should be solvable with the macro feature too. Not pre-defined,alas. I will see if I can come up with a solution.
Code: Pascal  [Select][+][-]
  1. //not complete of course:
  2. program untitled;
  3. {$ifdef fpc}{$mode delphi}{$H+}{$endif}
  4. {$macro on}
  5. {$if Defined(linux)}
  6.   {$Define targetos:='linux'}
  7. {$elseif Defined(win32)}
  8.    {$define targetos:='win32')}
  9. {$ifend}
  10. {$if defined(cpuarm)}
  11.    {$define targetcpu:= 'arm'}
  12. {$elseif defined(i386)}
  13.   {$define targetcpu := 'i386'}
  14. {$ifend}
  15.  
  16. begin
  17.   writeln(targetcpu,'-',targetos);
  18. end.

You can easily put something like that in an include file. It works when cross-compiling too.
« Last Edit: January 23, 2017, 03:00:47 pm by Thaddy »
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

avra

  • Hero Member
  • *****
  • Posts: 2514
    • Additional info
It should be solvable with the macro feature too. Not pre-defined,alas.
Thanks Thaddy for your time and effort. Please forgive me but I do not see how your proposal would help generate proper suffix for executable during project compilation. I see how to make use of such info in run time, but that's not what I need.
 %)

I have tested DonAlfredo's solution and it does exactly what I need.  :D
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

tr_escape

  • Sr. Member
  • ****
  • Posts: 432
  • sector name toys | respect to spectre
    • Github:
Hello is it possible to target file options as "binaryname_$(buildnumber).exe" ?

Is there a $(BuildNumber) or similar macro/define?

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Hello is it possible to target file options as "binaryname_$(buildnumber).exe" ?

Is there a $(BuildNumber) or similar macro/define?
None that I know and documented of.

 

TinyPortal © 2005-2018