[Lazarus] Adding Required Packages paths... dynamically

Marcos Douglas B. Santos md at delfire.net
Fri Jul 19 16:01:28 CEST 2019


On Fri, Jul 19, 2019 at 10:30 AM Tony Whyman via lazarus
<lazarus at lists.lazarus-ide.org> wrote:
>
> My understanding is that when you add a "required package" what actually
> happens is that the IDE adds the package unit paths to the list of unit
> paths for your project, and adds the top level .pas file for the package
> (which usually has the same name as the package) to the "uses" clause in
> your project source file. The latter may not happen if an option is set
> in the package itself.

I'm not using this option, as we don't need to add all units at the project.

> The result is that the package files get linked into your project.
> However, if you make the top level .pas file find a conditional
> reference from the uses clause then the package files only get linked in
> when the conditional is true.

Once the user set some defined (-dNOSYNDBZEOS), the conditional will
be always true.
I don't have issues compiling the Package. I can set add/remove the
defined and it gets the dependency paths or remove them.
Everything works, but only in Package context.

> Of course you also must do the same for any other units from the package
> that you include in your own unit files i.e. make their use conditional
> as well.

I don't get this part. I'm not including units, but paths:

if undefined(NOSYNDBZEOS) then
begin
  UnitPath += ';$PkgOutDir(zcore);$PkgOutDir(zdbc);$PkgOutDir(zparsesql);$PkgOutDir(zplain)';
  IncPath += ';$PkgDir(zcore)\..\..\src';
end;

And these paths do not have the sources (.pas), only the .ppu files.

If use like this and click on Show Options on the Project, I can see
correct paths to use.
if I remove this conditional and add `zcomponent`, which has all these
paths, into my package and click on Show Options on the Project,
again, I can see the *same* paths.

So, I'm thinking this is something on Lazarus context, before sending
to compiler, as the paths looks Ok.

regards,
Marcos Douglas


More information about the lazarus mailing list