Il 18/06/2015 23:48, aradeonas ha scritto:
Hi,
 
I made package including some units that some of them need LCL but some of them will be need in server tools and they should not use LCL or graphical stuff so I want to make 2 package one for client app and other one for server with some of tools and without any dependency on graphical stuff so for server apps I will add server package.
But I have units share with these two package that used TPicture in some parts but they can be removed with compiler condition.
 
I want to know what is the best way to declare these two package and compiler condition so I will have two package with shared units but for different usage case.

I'd suggest to avoid sharing units between packages. But different units may include a .inc file which contains the shared code.

Sort of:

server.pas:
Unit server;
{$DEFINE IS_SERVER}
{$INCLUDE common.inc}
.end
client.pas:
Unit client;
{$INCLUDE common.inc}
.end

common.inc:

Interface
{$IFDEF IS_SERVER}
..... server uses, etc.
{$ELSE}
..... client uses,etc
{$ENDIF}
....common uses,etc.

Implementation
{$IFDEF IS_SERVER}
..... server stuff
{$ELSE}
..... client stuff
{$ENDIF}
....common stuff

One package uses the "server" unit, the other the "client" unit, but all of your source is in common.inc for easier maintnance.

That way the compiler will never be confused about which units to compile, and with which conditionals.

Maybe there's a better way, but that's what I'd do.

Giuliano

-- 
Giuliano Colla

Project planning question: when it's 90% done, are we halfway or not yet?


--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to