Recent

Author Topic: How to control output exe name and location in Lazarus with build modes ?  (Read 6067 times)

440bx

  • Hero Member
  • *****
  • Posts: 3944
Hello,

This is what I would like to do:

Given a program source named "MyProgram.lpr".  I'd like Lazarus to output the exe as "MyProgram32.exe" when built in 32bit mode and "MyProgram64.exe" when built in 64bit mode.

Additionally, I'd like the executables to be output in the same directory as the source directory.

It would be particularly nice if the output name could be something like "MyProgram32d.exe" for the debug version and "MyProgram32r.exe" for the release version, of course, the same for 64bit exe generation.

Also, if the above is possible using build modes (or any other way), I'd like those build modes to be available for any project I open.  IOW, I don't want to have to create those build modes for every project I open, I want Lazarus to remember them and make them available automatically, adjusting the output names based on the name of the open project (lpr file.) 

Something tells me it is possible to do it but, I haven't figured out how to make it all work (other than manually editing the build modes for every project -  which gets cumbersome when one has more than a few projects.)

Thank you for your help.

(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

Bart

  • Hero Member
  • *****
  • Posts: 5274
    • Bart en Mariska's Webstek
Re: How to control output exe name and location in Lazarus with build modes ?
« Reply #1 on: February 15, 2019, 11:28:33 pm »
Select a build mode and then set path and executable name?

Bart

ASBzone

  • Hero Member
  • *****
  • Posts: 678
  • Automation leads to relaxation...
    • Free Console Utilities for Windows (and a few for Linux) from BrainWaveCC
Re: How to control output exe name and location in Lazarus with build modes ?
« Reply #2 on: February 15, 2019, 11:29:33 pm »

Something tells me it is possible to do it but, I haven't figured out how to make it all work (other than manually editing the build modes for every project -  which gets cumbersome when one has more than a few projects.)

Thank you for your help.


Consider this:  LazCopyOptions

I have the same concern you do.



-ASB: https://www.BrainWaveCC.com/

Lazarus v2.2.7-ada7a90186 / FPC v3.2.3-706-gaadb53e72c
(Windows 64-bit install w/Win32 and Linux/Arm cross-compiles via FpcUpDeluxe on both instances)

My Systems: Windows 10/11 Pro x64 (Current)

ASBzone

  • Hero Member
  • *****
  • Posts: 678
  • Automation leads to relaxation...
    • Free Console Utilities for Windows (and a few for Linux) from BrainWaveCC
Re: How to control output exe name and location in Lazarus with build modes ?
« Reply #3 on: February 15, 2019, 11:35:50 pm »
Select a build mode and then set path and executable name?

Bart


That was my initial read of the inquiry, and then I realized it was a request to have some parts of the build mode apply to each project by default.


Might have to make use of macros, too.  [size=78%]http://wiki.lazarus.freepascal.org/IDE_Macros_in_paths_and_filenames[/size]
-ASB: https://www.BrainWaveCC.com/

Lazarus v2.2.7-ada7a90186 / FPC v3.2.3-706-gaadb53e72c
(Windows 64-bit install w/Win32 and Linux/Arm cross-compiles via FpcUpDeluxe on both instances)

My Systems: Windows 10/11 Pro x64 (Current)

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: How to control output exe name and location in Lazarus with build modes ?
« Reply #4 on: February 16, 2019, 12:23:33 am »
Might have to make use of macros, too. http://wiki.lazarus.freepascal.org/IDE_Macros_in_paths_and_filenames

Unfortunately macros don't seem to work for the exe name. At least in my experience...

I tried to make something similar to what the OP wants by using macros ... and ended up with executables named: $(ProjDir) and alike  >:D
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

440bx

  • Hero Member
  • *****
  • Posts: 3944
Re: How to control output exe name and location in Lazarus with build modes ?
« Reply #5 on: February 16, 2019, 12:23:47 am »
I realized it was a request to have some parts of the build mode apply to each project by default.


Might have to make use of macros, too.  [size=78%]http://wiki.lazarus.freepascal.org/IDE_Macros_in_paths_and_filenames[/size]
You're right, making it happen automatically and by default is the "trick" that's eluded me so far.

I feel the way you do, I have a strong feeling it is possible using macros but, I haven't gotten it right. 

For that reason, I figured I'd ask those who obviously know a lot more about the Lazarus environment than I do.

ETA:

@Lucamar,  thank you for trying. 

At least I'm not feeling quite as "inadequate" as when I posted the question.
« Last Edit: February 16, 2019, 12:26:47 am by 440bx »
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

avra

  • Hero Member
  • *****
  • Posts: 2514
    • Additional info
Re: How to control output exe name and location in Lazarus with build modes ?
« Reply #6 on: February 16, 2019, 12:42:24 pm »
Given a program source named "MyProgram.lpr".  I'd like Lazarus to output the exe as "MyProgram32.exe" when built in 32bit mode and "MyProgram64.exe" when built in 64bit mode.
You can take a look at ct2laz project from my signature. It has $NameOnly($(ProjFile))-$(TargetCPU)-$(TargetOS) in Project / Project Options / Compiler Options / Paths. So when I cross compile I get executable names like this:
Quote
ct2laz-i386-win32.exe
ct2laz-i386-linux
ct2laz-x86_64-win64.exe
ct2laz-x86_64-linux
You can customize this to your taste...
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: How to control output exe name and location in Lazarus with build modes ?
« Reply #7 on: February 16, 2019, 01:18:34 pm »
Mea culpa. It seems I was wrong: it does in fact accept some macros for "Target name" (just tried it). Sorry.

I could swear that the last time I tried it didn't work, and it was just last summer ... :o
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

440bx

  • Hero Member
  • *****
  • Posts: 3944
Re: How to control output exe name and location in Lazarus with build modes ?
« Reply #8 on: February 16, 2019, 01:58:37 pm »
You can take a look at ct2laz project from my signature. It has $NameOnly($(ProjFile))-$(TargetCPU)-$(TargetOS) in Project / Project Options / Compiler Options / Paths. So when I cross compile I get executable names like this:
Quote
ct2laz-i386-win32.exe
ct2laz-i386-linux
ct2laz-x86_64-win64.exe
ct2laz-x86_64-linux
You can customize this to your taste...
Thank you Avra, that is great.  I am getting the executables named the way I want them. :)


Mea culpa. It seems I was wrong: it does in fact accept some macros for "Target name" (just tried it). Sorry.

I could swear that the last time I tried it didn't work, and it was just last summer ... :o
No worries, I tried everything I could think of and got it wrong every time.
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

 

TinyPortal © 2005-2018