* * *

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

avra

  • Hero Member
  • *****
  • Posts: 1150
    • 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 - Easily convert components and projects between Lazarus and CodeTyphon

DonAlfredo

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

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

avra

  • Hero Member
  • *****
  • Posts: 1150
    • Additional info
bindir\$NameOnly($(ProjFile))-$(TargetCPU)-$(TargetOS)
As always, you have been very helpfull. Thanks!  ;)
ct2laz - Easily convert components and projects between Lazarus and CodeTyphon

Thaddy

  • Hero Member
  • *****
  • Posts: 4638
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 »
"Logically, no number of positive outcomes at the level of experimental testing can confirm a scientific theory, but a single counterexample is logically decisive."

avra

  • Hero Member
  • *****
  • Posts: 1150
    • 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 - Easily convert components and projects between Lazarus and CodeTyphon

tr_escape

  • Sr. Member
  • ****
  • Posts: 280
  • sector name toys
    • 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: 7721
  • 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.

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus