Re: [Lazarus] Different packages for different usage
On 2015-06-19 11:22, aradeonas wrote: About Compiler Defines,until now I couldn't make them work,I don't know why! can you show me an simple example? Attached is an example which has common code (with IFDEF's), a console Server app (non GUI), and a Client (gui) app. Notes: - In both the Client and Server apps there is a IDE Macro in Project Options / Compiler Options / Additions and Overrides that defines the location of the common code. Change that to match your location. I normally set this to the root of my project directory. - In the Client app it defines a ClientApp compiler define in Project Options / Compiler Options / Other. The server app doesn't have this, and that is what allows you to separate the dependencies in the common code. No Lazarus Packages are used, other than the LCL.lpk for the client app. Save the attachment and remove the extra extension '.RemoveMe', then unpack as normal. The extra file extension is added to circumvent stupid attachment rules in some email servers. Regards, - Graeme - -- fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ exampl.tar.gz.RemoveMe Description: Binary data -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Different packages for different usage
Custom options is a plain field, simply passed to the compiler. Mostly used for uncommon options that have no GUI element in the IDE. Additions and Overrides is for complex projects with many targets and flags (e.g. release/debug, Windows/Linux, experiments, many developers). The later allows to enable/disable flags with simple mouse clicks. Understood,thank you. Ara -- http://www.fastmail.com - Faster than the air-speed velocity of an unladen european swallow -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Different packages for different usage
On 2015-06-19 12:09, aradeonas wrote: So 'Custom options' work like 'Additions and Overrides' but second one is more specific? I believe Mattias said it all. As far as I understand Additions and Overrides pass settings on to packages too. The Custom Options allows you to add any compiler settings, and only apply them to the specific project (not passed on to package dependencies). In the example I attached I didn't use packages, so the difference is probably moot. TIP: Created a new project, set your most often used IDE Macros (eg: tiopf:=/data/devel/tiopf/), then tick the Set compiler options as default and click OK. Now wherever you create a new project, your most used IDE Macros are already defined. Every little bit helps save time. ;-) Regards, - Graeme - -- fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Different packages for different usage
On Fri, Jun 19, 2015 at 1:17 PM, Graeme Geldenhuys mailingli...@geldenhuys.co.uk wrote: From what I understand Project Options can now set values on packages too. How exactly this is done, I don't know. That is the Additions and Overrides you have just discovered. Just put your custom define there and it affects all dependent packages. Additions and Overrides is versatile but also complex. The is confusing partly because of the complexity but I think it could be simplified. I have added a separate entry for setting LCLWidgetType because many people did not find it and were asking. Good ideas for the GUI are welcome, for example as mockups. Juha -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Different packages for different usage
Beautiful! Thank you Graeme and Mattias and also Juha. So summery is when I have 2 package named clientpkg and serverpkg with shared unit but fist one with graphical dependencies so when I make an server app I should declare for example -ThisIsServer and for client nothing and in code use compiler condition so when ThisIsServer declared I exclude graphical code. Correct and this is the best way? Also I want to ask how can I find out my app is running in non graphical OS?with compiler condition? Regards, Ara -- http://www.fastmail.com - The way an email service should be -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Different packages for different usage
On Fri, 19 Jun 2015 04:09:04 -0700 aradeonas aradeo...@operamail.com wrote: Thank you very much Graeme. So 'Custom options' work like 'Additions and Overrides' but second one is more specific? Custom options is a plain field, simply passed to the compiler. Mostly used for uncommon options that have no GUI element in the IDE. Additions and Overrides is for complex projects with many targets and flags (e.g. release/debug, Windows/Linux, experiments, many developers). The later allows to enable/disable flags with simple mouse clicks. Mattias -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Different packages for different usage
On 2015-06-19 12:53, Mattias Gaertner wrote: Note: The tiopf:=/data/devel/tiopf/ is an absolute path, so when you give your projects to another developer, he has to change this macro in every project and every time you give him a new copy. Yes I know it is an absolute path - as defined for my system. They don't however need to modify it every time they get a new copy (eg: from a code repository). They could override it via the Stored in session only *.lps section. So they can do a 'svn up' without loosing there customisations. As alternative you can use Addition and Overrides to add the macro to all your projects. The other developer only needs to do this once as well. Probably even better. Thanks for that info. Regards, - Graeme - -- fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Different packages for different usage
On Fri, 19 Jun 2015 03:53:10 -0700 aradeonas aradeo...@operamail.com wrote: Beautiful! Thank you Graeme and Mattias and also Juha. So summery is when I have 2 package named clientpkg and serverpkg with shared unit but fist one with graphical dependencies so when I make an server app I should declare for example -ThisIsServer and for client nothing and in code use compiler condition so when ThisIsServer declared I exclude graphical code. Yes, pass -dThisIsServer to the compiler. Correct and this is the best way? Depends. Some people don't like scattering their code with IFDEFs. Sven gave you an alternative with abstract classes. Also I want to ask how can I find out my app is running in non graphical OS?with compiler condition? The compiler run *before* the application is running. So, no there is no compiler condition. Please define what you mean with is running in non graphical OS. Mattias -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Different packages for different usage
The compiler run **before* *the application is running Agree,silly question! Please define what you mean with is running in non graphical OS. I have a simple vps with red hat os on it with only terminal so if I want to run any app that need LCL it will crash ,so all my server apps should not depend on graphical package and then it will run smoothly. Regards, Ara -- http://www.fastmail.com - A fast, anti-spam email service. -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Different packages for different usage
On Fri, 19 Jun 2015 12:38:39 +0100 Graeme Geldenhuys mailingli...@geldenhuys.co.uk wrote: On 2015-06-19 12:09, aradeonas wrote: So 'Custom options' work like 'Additions and Overrides' but second one is more specific? I believe Mattias said it all. As far as I understand Additions and Overrides pass settings on to packages too. It allows any combination. Only project, only packages, only one packages, all packages except one, etc ... The Custom Options allows you to add any compiler settings, and only apply them to the specific project (not passed on to package dependencies). In the example I attached I didn't use packages, so the difference is probably moot. TIP: Created a new project, set your most often used IDE Macros (eg: tiopf:=/data/devel/tiopf/), then tick the Set compiler options as default and click OK. Now wherever you create a new project, your most used IDE Macros are already defined. Every little bit helps save time. ;-) Note: The tiopf:=/data/devel/tiopf/ is an absolute path, so when you give your projects to another developer, he has to change this macro in every project and every time you give him a new copy. As alternative you can use Addition and Overrides to add the macro to all your projects. The other developer only needs to do this once as well. Mattias -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Different packages for different usage
Thank you very much Graeme. So 'Custom options' work like 'Additions and Overrides' but second one is more specific? Ara -- http://www.fastmail.com - Same, same, but different... -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Different packages for different usage
TIP: Created a new project, set your most often used IDE Macros (eg: tiopf:=/data/devel/tiopf/), then tick the Set compiler options as default and click OK. Now wherever you create a new project, your most used IDE Macros are already defined. Every little bit helps save time. ;-) Thank you Graeme, you helped me as always. Regards, Ara -- http://www.fastmail.com - The way an email service should be -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Different packages for different usage
Aha! That what I mean,you explained it better than me ;) About Compiler Defines,until now I couldn't make them work,I don't know why! can you show me an simple example? This project going to be big and I want just changing package from client to server change dependencies and allow me to run app in a non graphical OS. Regards, Ara -- http://www.fastmail.com - Send your email first class -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Different packages for different usage
Am 19.06.2015 10:36 schrieb aradeonas aradeo...@operamail.com: Thanks but I cant understand you. Problem is for example I have a class that will used for server and client but in client it will do some works with TPicture and in server there is no need for these functions and property and without them also class will work but I dont know how separate them so just changing a package do the job. In that case you should use inheritance. Have a class which does the common part which resides in a shared package. The client package then has a class that extends that shared class with the TPicture related functionality. Regards, Sven -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Different packages for different usage
Thanks but I cant understand you. Problem is for example I have a class that will used for server and client but in client it will do some works with TPicture and in server there is no need for these functions and property and without them also class will work but I dont know how separate them so just changing a package do the job. Regards, Ara -- http://www.fastmail.com - Accessible with your email software or over the web -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Different packages for different usage
On 2015-06-18 22:48, aradeonas wrote: units share with these two package that used TPicture in some parts but they can be removed with compiler condition. And it still boggles the mind why TPicture (essentially graphic handling) must pull in the whole LCL or VCL. Free Pascal's FCL-Image doesn't require the VCL or LCL, so why must TPicture. I had a similar issue with code I had to work on a year or two ago. Anyway, back to the point at hand... From what I understand Project Options can now set values on packages too. How exactly this is done, I don't know. Maybe the wiki could help. This should mean that if you set a compiler define in your project, that compiler define could be applied to dependency packages too. So your Client app could have the define, and the Server app doesn't. The code in your package then uses simple IFDEF's to block out some parts of the code. I have so many issues with Lazarus Packages these days - I recommend you scrap them completely and simply use IDE Macros. Build settings, Compiler Defines etc are much much easier to handle then. Each project has there own settings and is applied to all the source code involved. Regards, - Graeme - -- fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Different packages for different usage
Yes I done something like this but didn't like it so much because I dont want to have different class naming,Im looking for a way that just changing some parameter or condition with package do the job. Regards, Ara -- http://www.fastmail.com - Access all of your messages and folders wherever you are -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Different packages for different usage
On Fri, 19 Jun 2015 03:22:47 -0700 aradeonas aradeo...@operamail.com wrote: Aha! That what I mean,you explained it better than me ;) About Compiler Defines,until now I couldn't make them work,I don't know why! can you show me an simple example? In Project Options / Compiler Options / Additions and Overrides: http://wiki.lazarus.freepascal.org/IDE_Window:_Compiler_Options#Add_a_flag_to_project_and_all_packages In code you can then use: {$IFDEF SomeFlag} {$ELSE} {$ENDIF} This project going to be big and I want just changing package from client to server change dependencies and allow me to run app in a non graphical OS. Mattias -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Different packages for different usage
On 18.06.2015 23:48, aradeonas wrote: 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. In my opinion the best approach would be to put the shared units into their own package and have the code of those units /really/ be shared. This means no compiler defines that influence its behavior. And then the server and the client package depend on that package. Regards, Sven -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Different packages for different usage
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 Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
[Lazarus] Different packages for different usage
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. Regards, Ara -- http://www.fastmail.com - Faster than the air-speed velocity of an unladen european swallow -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus