Author Topic: Clean up and build  (Read 881 times)

fpcoder

  • Hero Member
  • *****
  • Posts: 670
  • Previously kapibara
Clean up and build
« on: August 13, 2026, 02:00:50 pm »
When replacing units in a project and recompiling, sometimes not all replaced units get recompiled. Usually I do "Clean up and build" when I feel there is a risk for that. For large projects, like my current one that has +300 units, Clean up and build takes a while.

How can I make sure only replaced/changed files are compiled?

EDIT: The answer was partly in front of my eyes. "Clean up and build" has a dialog with settings for that. But still, many real project files are unchanged and get compiled anyway. Is it possible to compile only files that changed?
« Last Edit: August 13, 2026, 08:45:30 pm by kapibara »
Lazarus trunk / fpc 3.3.1 / Kubuntu 24.04 - 64 bit

n7800

  • Hero Member
  • *****
  • Posts: 773
  • Lazarus IDE contributor
    • GitLab profile
Re: Clean up and build
« Reply #1 on: August 13, 2026, 10:15:09 pm »
Is it possible to compile only files that changed?

Use a normal build by pressing [F9] ))

It should automatically detect modified files and rebuild them, as well as all dependent units.

When replacing units in a project and recompiling, sometimes not all replaced units get recompiled.

As far as I know, the compiler checks modified files by modification date. If you replace them using a program that restores modification dates, the compiler might accidentally skip them.

Or there's a compiler bug. In that case, you should check it with the trunk version of the compiler (the upcoming next release), as it contains significant changes to the project rebuilding mechanism.

fpcoder

  • Hero Member
  • *****
  • Posts: 670
  • Previously kapibara
Re: Clean up and build
« Reply #2 on: August 14, 2026, 03:15:39 am »
Quote
Use a normal build by pressing [F9]

Thats what sometimes fails to compile all units. I read about this quirk years ago, but it never bothered me until now.

Quote
As far as I know, the compiler checks modified files by modification date. If you replace them using a program that restores modification dates, the compiler might accidentally skip them.

Ah, thats almost certainly whats happening. Thanks for the reminder.
Lazarus trunk / fpc 3.3.1 / Kubuntu 24.04 - 64 bit

CM630

  • Hero Member
  • *****
  • Posts: 1788
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: Clean up and build
« Reply #3 on: August 14, 2026, 11:20:21 am »
Use a normal build by pressing [F9] ))
...
It should automatically detect modified files and rebuild them, as well as all dependent units.
...
It does not, at least when editing a component, which is used by the project, but is not part of it.
Лазар 4,8 32 bit (sometimes 64 bit); FPC3,2,2

n7800

  • Hero Member
  • *****
  • Posts: 773
  • Lazarus IDE contributor
    • GitLab profile
Re: Clean up and build
« Reply #4 on: August 14, 2026, 10:57:14 pm »
It does not, at least when editing a component, which is used by the project, but is not part of it.

I must admit that I rarely add units to a project (Project Inspector) and haven't encountered any problems. If you mean a separate package, I'm not sure (unless it's included in the package's file list).

Generally, this is a compiler feature and shouldn't depend on the IDE. Include files ("*.inc") are an exception due to their peculiarities (it seems the compiler doesn't store information about them).

Omitting their compilation caused me problems, and I had to add them to the project. A workaround was to modify the unit (update the modification date) in which they were included. But of course, doing this every time they were changed is counterproductive.

n7800

  • Hero Member
  • *****
  • Posts: 773
  • Lazarus IDE contributor
    • GitLab profile
Re: Clean up and build
« Reply #5 on: August 14, 2026, 11:03:28 pm »
Incidentally, problems can also arise with LFM files. When they are modified using an external program (like Git), even though the date is updated, the changes may not be detected. This is because an LFM file is something like an include file. Therefore, the unit it's used in also needs to be updated.

I even often warn about this in my MRs to avoid false statements like "this doesn't work" ))

 

TinyPortal © 2005-2018