Recent

Author Topic: Using Packages  (Read 1908 times)

Grahame Grieve

  • Sr. Member
  • ****
  • Posts: 365
Using Packages
« on: November 20, 2020, 03:21:23 am »
I was advised to separate my project up into multiple packages. I've done that but doing so has raised a number of questions for me about how packages work with the IDE:

* The files in the packages aren't compiled with the same settings for assertions (eg). Do I have to go through all the packages and change the settings when I change the build profile for my project? Surely there's a better way?

* how do I do platform dependent contents of a package? there has to be small differences in the package contents across platforms, but no way to have platform dependencies on the list?

* shift-F11 doesn't list any files from the packages. That's a little annoying, but it's *persistently* annoying. That's how I open files, and now I can't. Surely I'm not the only one who has this problem?

* Search find in files, in the project... same issue. This one really is painful. Can we have search in project and packages?



lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: Using Packages
« Reply #1 on: November 20, 2020, 04:18:30 am »
I don't know about all but most of what you want can be done through Project Inspector if the package is listed as required: double click the package and a dialog appears where you can do most of what you want: open units, change package options, etc.

It might not be exactly what you want or how you like it (and yeah, it's not the most helpful possible UI), but it can be done ...
« Last Edit: November 20, 2020, 04:20:08 am by lucamar »
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

Grahame Grieve

  • Sr. Member
  • ****
  • Posts: 365
Re: Using Packages
« Reply #2 on: November 22, 2020, 09:31:42 pm »
Really, that's pretty much a non-answer, unfortunately. I know what I can do from the package manager, since that's how you build them. But I don't see how it deals with my question, particularly platform variants.

wp

  • Hero Member
  • *****
  • Posts: 11858
Re: Using Packages
« Reply #3 on: November 22, 2020, 11:24:16 pm »
* The files in the packages aren't compiled with the same settings for assertions (eg). Do I have to go through all the packages and change the settings when I change the build profile for my project? Surely there's a better way?
Use "Additions and overrides" to define settings which are applied to the project and to all packages used by the project.

* how do I do platform dependent contents of a package? there has to be small differences in the package contents across platforms, but no way to have platform dependencies on the list?
I do not fully understand what you mean. But you always can use platform-dependent {$IFDEF ...}, e.g.
Code: Pascal  [Select][+][-]
  1. {$IFDEF MSWINDOWS}
  2.   // put your windows code here
  3. {$ENDIF}
  4. {$IFDEF LINUX}
  5.   // put your Linux-only code here
  6. {$ENDIF}
See this list of platform-defines: https://wiki.freepascal.org/Platform_defines

* shift-F11 doesn't list any files from the packages. That's a little annoying, but it's *persistently* annoying. That's how I open files, and now I can't. Surely I'm not the only one who has this problem?
Sorry - what does Shift-F11 do? I use classical keyboard layout... Anyway, I always have the Project Inspector open at the right of the screen (like the Object Inspector at the left). It lists all the files of the project, and I can open each file by a double-click. When I open a package I drag it also to the right to get it away from the work area with editor and form designer; I open package files in the same way by a double-click. In case of a large project consisting of many packages you can create a "Package group" with project(s) and packages (Laz trunk only).

* Search find in files, in the project... same issue. This one really is painful. Can we have search in project and packages?
Again, using the project groups of Laz trunk you can search in all files of the project group.

Zoran

  • Hero Member
  • *****
  • Posts: 1829
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: Using Packages
« Reply #4 on: November 23, 2020, 12:17:06 am »

* The files in the packages aren't compiled with the same settings for assertions (eg). Do I have to go through all the packages and change the settings when I change the build profile for my project? Surely there's a better way?


Project options -> Additions and overrides. Read https://wiki.lazarus.freepascal.org/IDE_Window:__Compiler_Options#Additions_and_Overrides

Grahame Grieve

  • Sr. Member
  • ****
  • Posts: 365
Re: Using Packages
« Reply #5 on: November 26, 2020, 08:47:07 am »
So I don't understand the response to my question about packages and platform defines.

Sure, I can {$IFDEF MSWINDOWS} LINUX etc to my hearts content, and I do. But I have s a few units (e.g. mxsml wrapper) where the whole point of the unit is platform specific. But it's grouped with the rest  of my library/xml code, so on windows, I want it in the same package as those other units, which are totally cross platform.

But if I put it in the package, then the package only compiles on windows. I have to take it out to compile on linux.

I can't see how to $ifdef a unit in a package. Doing it in the pascal file gets overwritten by the package UI. And it doesn't appear to work anyway, though there may be a caching problem there? But it'll get wiped.

So I don't know how $IFDEF is an answer to my question about units in or out of a package on different platforms

Grahame Grieve

  • Sr. Member
  • ****
  • Posts: 365
Re: Using Packages
« Reply #6 on: November 26, 2020, 08:50:41 am »
I see how additions and overrides work. I'll have to play with the permutations to see if I can figure out how to manage debug/production builds - thanks

Grahame Grieve

  • Sr. Member
  • ****
  • Posts: 365
Re: Using Packages
« Reply #7 on: November 26, 2020, 08:53:52 am »
I can't see how searching a project group actually searches the packages the project depends on. Testing it, it doesn't seem to. Did I miss something in my set up?

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4459
  • I like bugs.
Re: Using Packages
« Reply #8 on: November 26, 2020, 12:00:32 pm »
I can't see how searching a project group actually searches the packages the project depends on. Testing it, it doesn't seem to.
The Project Group feature does not search packages. It is only a set of projects which can be built in one go.
I have not heard of a specific package group. Such a group can be made with a meta-package + its dependent packages of course.

A single project has a list of dependent packages. They (and their paths) are found after the IDE has seen them once. No search path settings are needed. Pretty neat, ha?

Currently you cannot include / exclude whole units by IFDEFs. However you can use IFDEFs freely inside a unit. For example if you put all Windows specific code inside
 {$IFDEF MSWINDOWS}
then the unit looks practically empty for other targets.
If the Windows specific code is called from inside {$IFDEF MSWINDOWS} in other units, everything works fine.
You can use IFDEFs also in uses section, so the Windows specific unit is used only when needed.

Earlier posts ... :
Shift-F11 by default adds the current editor file to the current project. It is not relevant to your problem.
« Last Edit: November 26, 2020, 12:03:34 pm by JuhaManninen »
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

wp

  • Hero Member
  • *****
  • Posts: 11858
Re: Using Packages
« Reply #9 on: November 26, 2020, 12:50:08 pm »
I can't see how searching a project group actually searches the packages the project depends on. Testing it, it doesn't seem to. Did I miss something in my set up?
The Project Group feature does not search packages.
I just tested it, and it is working. The problem may be that the package lazProjectGroups.lpk must be installed - which is not done by default.
« Last Edit: November 26, 2020, 01:44:48 pm by wp »

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4459
  • I like bugs.
Re: Using Packages
« Reply #10 on: November 26, 2020, 06:58:41 pm »
The Project Group feature does not search packages.
I just tested it, and it is working. The problem may be that the package lazProjectGroups.lpk must be installed - which is not done by default.
Ok, then I don't know how to use it. I personally don't use Project Groups much. How to search packages with it?
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

wp

  • Hero Member
  • *****
  • Posts: 11858
Re: Using Packages
« Reply #11 on: November 26, 2020, 07:17:13 pm »
In the "Find in Files" of Laz trunk there is an option "Search in project group".

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4459
  • I like bugs.
Re: Using Packages
« Reply #12 on: November 26, 2020, 09:35:23 pm »
In the "Find in Files" of Laz trunk there is an option "Search in project group".
Do you mean the paths of dependent packages are then included in the search?
Hmmm... I have not noticed, must test more later.
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

wp

  • Hero Member
  • *****
  • Posts: 11858
Re: Using Packages
« Reply #13 on: November 26, 2020, 11:10:03 pm »
In the "Find in Files" of Laz trunk there is an option "Search in project group".
Do you mean the paths of dependent packages are then included in the search?
Yes. I am attaching a simple project and a project group which contains also the two datetimectrls packages coming with the IDE. When I open "Find in files" and search for the word "Date" and select "Search in project group" text positions are found in the datetimectrls units although they are not used by the project itself.

Note before testing this demo you must manually open the project group file in an external editor and adjust the path to the datetimectrl packages. Note also that this demo requires Lazarus trunk.

 

TinyPortal © 2005-2018