Recent

Author Topic: Can the target file name be conditional on a DEFINE? (SOLVED)  (Read 3613 times)

minesadorada

  • Hero Member
  • *****
  • Posts: 605
  • Retired
The title asks the question.

Environment: Lazarus 1.2.4/fpc 2.6.2

I have a project where I can add and enable/disable  $DEFINEs in Project Options/Compiler Options/Other which is a great feature.

I would like a fully 'generalised' project file where the Target filename (-o not the directory) depends on which DEFINEs I have enabled.

In that way, I can have one 'master' project file, and compile it to different executables depending on the DEFINEs I tick or untick in Project/Options (which already affects the code of course)  That would be very handy.

Is this possible using Macros or some other technique?
« Last Edit: July 26, 2014, 05:47:32 pm by minesadorada »
GPL Apps: Health MonitorRetro Ski Run
OnlinePackageManager Components: LazAutoUpdate, LongTimer, PoweredBy, ScrollText, PlaySound, CryptINI

Bart

  • Hero Member
  • *****
  • Posts: 4045
    • Bart en Mariska's Webstek
Re: Can the target file name be conditional on a DEFINE?
« Reply #1 on: July 26, 2014, 05:12:29 pm »
Not exactly what you want, but you could do so with build modes.

Bart

minesadorada

  • Hero Member
  • *****
  • Posts: 605
  • Retired
Re: Can the target file name be conditional on a DEFINE?
« Reply #2 on: July 26, 2014, 05:40:07 pm »
Not exactly what you want, but you could do so with build modes.

Bart
Good thinking!  I'll give it a try.

=edit- Marked the topic SOLVED.  Thanks Bart  ;D

Lazarus is so flexible!  With a combination of $DEFINEs and build modes, the same codebase and project file can now now compile to 6 different executables with a couple of clicks - amazing :)

It certainly makes publishing an maintenance a lot easier.
« Last Edit: July 26, 2014, 06:48:41 pm by minesadorada »
GPL Apps: Health MonitorRetro Ski Run
OnlinePackageManager Components: LazAutoUpdate, LongTimer, PoweredBy, ScrollText, PlaySound, CryptINI

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3887
  • I like bugs.
Re: Can the target file name be conditional on a DEFINE?
« Reply #3 on: July 26, 2014, 08:01:59 pm »
Lazarus is so flexible!  With a combination of $DEFINEs and build modes, the same codebase and project file can now now compile to 6 different executables with a couple of clicks - amazing :)

Please try trunk, the development version. It allows you to build many modes at one go and it has other cool features, too. Wow-effect guaranteed.

Quote
I have a project where I can add and enable/disable  $DEFINEs in Project Options/Compiler Options/Other which is a great feature.

Good to get positive feedback about this one. I was already wondering if anybody uses the feature. Thanks.
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux.

minesadorada

  • Hero Member
  • *****
  • Posts: 605
  • Retired
Re: Can the target file name be conditional on a DEFINE?
« Reply #4 on: July 26, 2014, 08:36:20 pm »
Please try trunk, the development version. It allows you to build many modes at one go and it has other cool features, too. Wow-effect guaranteed.
I checked it out via Tortoise SVN, but I have no idea how to build the Executables in my Windows 32-bit environment.

Good to get positive feedback about this one. I was already wondering if anybody uses the feature. Thanks.

I have a simple question (I couldn't find the answer in the Wiki)
In the Build Modes dialog, why are there two rows of checkboxes - 'Active' and 'In Session' ?  I don't understand what the 'In Session' is about.

Can anyone explain, please?
GPL Apps: Health MonitorRetro Ski Run
OnlinePackageManager Components: LazAutoUpdate, LongTimer, PoweredBy, ScrollText, PlaySound, CryptINI

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3887
  • I like bugs.
Re: Can the target file name be conditional on a DEFINE?
« Reply #5 on: July 26, 2014, 10:42:29 pm »
I checked it out via Tortoise SVN, but I have no idea how to build the Executables in my Windows 32-bit environment.

On cmd line do "make bigide" or "make all" and then run the lazarus executable.

Quote
I have a simple question (I couldn't find the answer in the Wiki)
In the Build Modes dialog, why are there two rows of checkboxes - 'Active' and 'In Session' ?  I don't understand what the 'In Session' is about.

Compiler options for those modes are stored in the session .lps file instead of project .lpi file.
It means you can add local modes for a project that is otherwise shared by many people.
« Last Edit: July 27, 2014, 08:20:08 am by JuhaManninen »
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux.

 

TinyPortal © 2005-2018