Recent

Author Topic: HowTo use additional packages EASY for all projects  (Read 3307 times)

Researching

  • Full Member
  • ***
  • Posts: 121
HowTo use additional packages EASY for all projects
« on: November 13, 2018, 01:28:48 pm »
What I want:
1. Create a folder somewhere like:               C:\Laz-Packs
2. Create                                        C:\Laz-ProgTemplate
3. Include the path                                  to : C:\Laz-Packs
3. On the workflow: copy LazProgTemplate, rename to present project, make a refactoring rename of files/units semantically
4. Continue developing from that point.

// Each time from start - is time-wasting.

QUESTONS:
Possible or not?
Is it possible to include Laz and FPC source inside C:\Laz-Packs ?
If not possible - any other solution?

With respect !

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: HowTo use additional packages EASY for all projects
« Reply #1 on: November 13, 2018, 01:53:15 pm »
What would that do that the IDE can't do now? You can install all the packages you want to have ready, add as default any unit/-s directory/-ies, use project/form/unit templates with the ProjTemplates package, etc.
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.

Researching

  • Full Member
  • ***
  • Posts: 121
Re: HowTo use additional packages EASY for all projects
« Reply #2 on: November 13, 2018, 02:31:54 pm »
Dear Lucamar,
Where, how?! Where to find this in help or wiki?
What is actually needed: Work with the pure source: able to browse source to the very assembler level to read-recognize-edit-correct.
To do this without recompiling the IDE itself. To work (at least at this time of learning) - with bare *.pas files and without those multiple *.pp, *.res ... etc.
« Last Edit: November 13, 2018, 02:36:45 pm by Researching »

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: HowTo use additional packages EASY for all projects
« Reply #3 on: November 13, 2018, 03:10:29 pm »
Where, how?! Where to find this in help or wiki?

Use the search of the wiki: searching for "packages" leads you to Lazarus Packages whcih, in turn, points to other pages about the topic: the category IDE Window leads you to (almost) all the pages dealing with using the IDE, including the configuration; searching "project templates" goes almost directly to Project Templates, etc. There are also other resources out there in the web, google for them!

Quote
Work with the pure source: able to browse source to the very assembler level to read-recognize-edit-correct.
To do this without recompiling the IDE itself. To work (at least at this time of learning) - with bare *.pas files and without those multiple *.pp, *.res ... etc.

I'm not at all sure whether Pascal source goes to the "very assembly level" :D Jokes apart, you can even do this, by compiling with the -al, which will give a nice assembler file including the Pascal lines which generate it. Which is explained in the manuals.

Alas! Adding packages without recompiling the IDE is not possible (yet); as for the rest, you can (mostly) forget about any file type other than the "bare" pascal sources, which can in fact be *.inc, *.lpr, *.pp or *.pas To tell the truth, most of the time I work just with my own .pas and let the IDE deal with all those *.res, *.lrj, etc.

All in all, Lazarus and FreePascal's learning curve is somewhat steep at the start ... but it quickly becomes rather "soft" and steady, accelerating the learning. Just one of its advantages. :)
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.

wp

  • Hero Member
  • *****
  • Posts: 11855
Re: HowTo use additional packages EASY for all projects
« Reply #4 on: November 13, 2018, 04:50:41 pm »
Adding packages without recompiling the IDE is not possible (yet)
This is true only for designtime packages. If you use runtime packages (or create components at runtime) then it is sufficient to compile the package only.

@Researching: Try to understand the Lazarus package system. If I understand you correctly it fulfills many of your wishes.
http://wiki.freepascal.org/Lazarus_Packages

3. Include the path                                  to : C:\Laz-Packs
...
Is it possible to include Laz and FPC source inside C:\Laz-Packs ?
Don't add paths to the search path, in particular don't add Laz/FPC paths. With improper extension of the search paths you are calling for trouble ("duplicate unit", "unit version error" or similar). Add packages to the requirements of a project instead. This is sufficient to find the compiled files.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9792
  • Debugger - SynEdit - and more
    • wiki
Re: HowTo use additional packages EASY for all projects
« Reply #5 on: November 13, 2018, 05:52:56 pm »
As already pointed out, it is possible by adding include pathes, but that reqires you do know exactly what you do. That is
- you need to recompile those packages yourself, outside the project (ideally compile with release flag, fpc options)
- ensure no duplicates
- ensure only ppu are in the path
  if you put pas in the pas, then you will quickly get duplicate ppu, and such errors.

A reasonable approach, is to put your files into packages (wiki).
Then create one package, that is empty but to that packages dependencies, you add all the other packages. So if you use that package all other packages are used too.
Only one package to add....

Or, let the IDE deal with adding packages.
Add the package "cody" to the IDE.

If you use an identifier from a package that is not yet used (does not show in completion dropdown), invoke cody's "Unit Identifier dictionary"  (add it to a keycombo of your choice).
That will automatically add the unit to the uses, and add the package to the project requirements.

The only think it will not do: If you move the identifier to another unit/package, the projects are not updated. But with any other solution, you need to at least update all the uses clauses too. And you can use cody to find the identifier again, and get everything updated. (one by one)

I do recommend to at least try the "Unit Identifier dictionary".

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: HowTo use additional packages EASY for all projects
« Reply #6 on: November 13, 2018, 05:53:27 pm »
Adding packages without recompiling the IDE is not possible (yet)
This is true only for designtime packages. If you use runtime packages (or create components at runtime) then it is sufficient to compile the package only.

Ah ... yes, that's an important remark. :-[
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.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9792
  • Debugger - SynEdit - and more
    • wiki
Re: HowTo use additional packages EASY for all projects
« Reply #7 on: November 13, 2018, 06:10:29 pm »
To see how packages work:

Start with the project inspector (project menu). It shows what packages are used by your project.
You can add any existing package (though better let cody do it, easier).

Any code/unit in those packages -> you can browse/navigate (eg go to implementation shortcut).

For your own units, that you want to be able to use in more than one project -> create your own package (package menu), save it do a new folder. 
Either:
- add new units, using the package window's toolbar (Add Toolbutton -> new)
- save/copy files into the folder and use  (Add Toolbutton -> from filesystem)
 (If they are in your project, do NOT use "save as" / copy them outside the ide)

Those units must then NOT be listed in the project inspector.

 

TinyPortal © 2005-2018