Recent

Author Topic: (SOLVED) Clean the project - remove unnecessary components  (Read 1684 times)

AsleyCruz

  • Jr. Member
  • **
  • Posts: 99
    • Graphic and web designer
(SOLVED) Clean the project - remove unnecessary components
« on: February 26, 2020, 10:27:55 pm »
Hi team

We sometimes add components in our project, but in the end, we decided not to use that component.
But we still have its unit in "Uses" section or in the section "Required packages" and this makes the .exe size increase.

Is there a way to remove automatically that unnecessary components that our project does not need?

Thanks in advance.
« Last Edit: February 27, 2020, 01:16:28 am by AsleyCruz »
Graphic & web designer

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: Clean the project - remove unnecessary components
« Reply #1 on: February 26, 2020, 10:41:35 pm »
To delete the references to the units in the uses clause(s), use the menu "Source->Refactoring->Unused units", which can also be accessed through the pop-up menu of the editor.

If that doesn't work then you'll have to do it by hand, deleting the offending references in the source. Note that hovering the mouse pointer over a control/component class will tell you (most of the time) in which unit it's declared. Also, compiling after each deletion will allow you to ascertain whether the deleted unit is still "used", somehow, in your code (look for "Identifier not found" errors).

Package dependencies can be deleted in the Project Inspector (menu Project->Project Inspector). Again. compiling after each deletion will tell you whether the dependency was really needed.

HTH!
« Last Edit: February 26, 2020, 10:48:23 pm 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.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11446
  • FPC developer.
Re: Clean the project - remove unnecessary components
« Reply #2 on: February 26, 2020, 10:41:50 pm »
No, this is not really easy to do components might be added runtime.

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: Clean the project - remove unnecessary components
« Reply #3 on: February 26, 2020, 10:44:06 pm »
There is no way to remove unnecessary components, except manual deletion.
 Only the developer knows whether a component is needed. If it is not needed, just delete it.

How can the IDE read your mind to know whether you need it or not?

jamie

  • Hero Member
  • *****
  • Posts: 6128
Re: Clean the project - remove unnecessary components
« Reply #4 on: February 26, 2020, 10:58:37 pm »
Deleting it via the OI does work but you still have the units behind in the uses list however, the warnings tell you that it's not being used and thus it should be ok.
The only true wisdom is knowing you know nothing

AsleyCruz

  • Jr. Member
  • **
  • Posts: 99
    • Graphic and web designer
Re: Clean the project - remove unnecessary components
« Reply #5 on: February 27, 2020, 01:16:04 am »
To delete the references to the units in the uses clause(s), use the menu "Source->Refactoring->Unused units", which can also be accessed through the pop-up menu of the editor.

If that doesn't work then you'll have to do it by hand, deleting the offending references in the source. Note that hovering the mouse pointer over a control/component class will tell you (most of the time) in which unit it's declared. Also, compiling after each deletion will allow you to ascertain whether the deleted unit is still "used", somehow, in your code (look for "Identifier not found" errors).

Package dependencies can be deleted in the Project Inspector (menu Project->Project Inspector). Again. compiling after each deletion will tell you whether the dependency was really needed.

HTH!

Thanks a lot guys
This helped me a lot... with maybe 1MB of my project...

Code: Text  [Select][+][-]
  1. To delete the references to the units in the uses clause(s), use the menu "Source->Refactoring->Unused units"

« Last Edit: February 27, 2020, 01:20:41 am by AsleyCruz »
Graphic & web designer

 

TinyPortal © 2005-2018