Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2016-09

Failure to recompile with a different define

5 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Giuliano Colla

I have two Lazarus projects, let's call them project A and project B, which share the same sources, only with a different define: let's say -dProjA and -dProjB.

If, starting from a clean situation, I compile first project A, and then project B, most of the modules aren't recompiled, and I end up with a project B built with a mix-up of units, some compiled with project A define and some compiled with project B define.

I managed to find a way out: setting different unit paths for project A and project B solves the issue, but this situation may be rather confusing for an inexperienced user.

IMHO this is not a very unusual setup: it applies to any situation where the same base project must provide different options or features.

Is this a Lazarus issue or rather an fpc issue? Do ppu's include the defines used for compilation? If not, wouldn't it be advisable to add them somehow?

Giuliano

Reply by email

Mattias Gaertner
to Giuliano Colla
Show quoted text 19 lines
I have two Lazarus projects, let's call them project A and project B, which share the same sources, only with a different define: let's say -dProjA and -dProjB. If, starting from a clean situation, I compile first project A, and then project B, most of the modules aren't recompiled, and I end up with a project B built with a mix-up of units, some compiled with project A define and some compiled with project B define. I managed to find a way out: setting different unit paths for project A and project B solves the issue, but this situation may be rather confusing for an inexperienced user. IMHO this is not a very unusual setup: it applies to any situation where the same base project must provide different options or features. Is this a Lazarus issue or rather an fpc issue? Do ppu's include the defines used for compilation? If not, wouldn't it be advisable to add them somehow?

ppus do not include the defines, so a simple compile won't rebuild ppu files. That's by design.

How do you share units?
If you do it manually by adding unit paths to the Compiler Options then you have to clean up manually.
If you use Lazarus packages, then Lazarus will detect the changes and pass the -B automatically.

Mattias

Reply by email

Giuliano Colla
to Mattias Gaertner

Il 01/09/2016 13:12, Mattias Gaertner ha scritto:

Show quoted text 8 lines
ppus do not include the defines, so a simple compile won't rebuild ppu files. That's by design. How do you share units? If you do it manually by adding unit paths to the Compiler Options then you have to clean up manually. If you use Lazarus packages, then Lazarus will detect the changes and pass the -B automatically.

Using a package isn't a very intuitive solution, when *all* the units belong to the project.

A simple option could be to change the default unit path proposed by Lazarus: in place of lib/$(TargetCPU)-$(TargetOS), make it lib/$(ProjectName)/$(TargetCPU)-$(TargetOS)

this could make it much easier to have more than one project in the same directory, without any risk of mix-ups.

Just my 2c

Giuliano

Reply by email

Mattias Gaertner
to Giuliano Colla
[...] Using a package isn't a very intuitive solution, when *all* the units belong to the project.

Because of circular dependencies or because of company rules?

this could make it much easier to have more than one project in the same directory, without any risk of mix-ups.

Why do you must put all projects and units into a single directory?

A simple option could be to change the default unit path proposed by Lazarus: in place of lib/$(TargetCPU)-$(TargetOS), make it lib/$(ProjectName)/$(TargetCPU)-$(TargetOS)

See here:
http://wiki.lazarus.freepascal.org/IDE_Window:_Compiler_Options#Change_the_output_directory_of_project_and_all_packages

Mattias

Reply by email

Giuliano Colla
to Mattias Gaertner

Il 01/09/2016 15:25, Mattias Gaertner ha scritto:

> [...] > >Using a package isn't a very intuitive solution, when*all* the units > >belong to the project. Because of circular dependencies or because of company rules?

No, I just mean that while putting into a package a group of units which perform a given task and can be used by many project is rather intuitive, putting all the units of a project into a package isn't very intuitive for an inexperienced user. Moreover in that way *all* units would be recompiled every time one switches from one project to the other.

> >this could make it much easier to have more than one project in the same > >directory, without any risk of mix-ups. Why do you must put all projects and units into a single directory?

You don't have to, but you may happen to keep more than one project in a single directory. E.g. I have a "Sandbox" directory which I use for simple tests, and where you can find a number of small projects,

Show quoted text 5 lines
> >A simple option could be to change the default unit path proposed by > >Lazarus: in place of lib/$(TargetCPU)-$(TargetOS), make it > >lib/$(ProjectName)/$(TargetCPU)-$(TargetOS) See here: http://wiki.lazarus.freepascal.org/IDE_Window:_Compiler_Options#Change_the_output_directory_of_project_and_all_packages

Thank you, I'm aware of that, and personally I'm perfectly happy with what is provided by Lazarus.
I was just suggesting something which might help inexperienced users to avoid pitfalls.

Giuliano

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20160901/1f4d28f1/attachment.html>

Reply by email