@marcov,
What if the suggested check is performed only on the .ppu's residing into intermediate directory? The compiler should know that directory by its command-line parameters, I believe.
Theoretically possible. However I think it too narrow an usecase. But as said, I'm no compilerdevel.
In the IDE it is also possible with ppu scanning, but the compiler only scans required files, and that is harder in the IDE, so a file removed from the project (and a leftover ppu) could trip up this. PPU scanning could alleviate this somewhat, but depends on a build of the same project being succeeded before.
I've tried to experiment with the idea, thought that I can put on 'Project|Compiler commands|Execute before' small utility to hash the compiler options and touch the file $(ProjPath)/hash.inc
only when different. Then {$I hash.inc} in every source file should have the same effect, i.e. tried to use .ppu's entry for include dependency in place of the proposed new entry.
Then I found there is no suitable IDE macro to substitute for the compiler options...
Ditching into IDE sources I found it in function
TMainIDE.DoBuildProject():
// execute compilation tool 'Before'
if not (pbfSkipTools in Flags) then begin
ToolBefore:=TProjectCompilationToolOptions(
Project1.CompilerOptions.ExecuteBefore);
if (AReason in ToolBefore.CompileReasons) then begin
Result:=Project1.CompilerOptions.ExecuteBefore.Execute(
WorkingDir, lisProject2+lisExecutingCommandBefore,
aCompileHint);
// ... (many lines after)
CompilerParams :=
Project1.CompilerOptions.MakeOptionsString([ccloAbsolutePaths])
+ ' ' + PrepareCmdLineOption(SrcFilename);
// write state file, to avoid building clean every time
Result:=Project1.SaveStateFile(CompilerFilename,CompilerParams,false);
if Result<>mrOk then begin
debugln(['Error: (lazarus) [TMainIDE.DoBuildProject] SaveStateFile before compile failed']);
exit;
end;
WarnSuspiciousCompilerOptions('Project checks','',CompilerParams);
StartTime:=Now;
Result:=TheCompiler.Compile(Project1,
That convinced me that I have no chance of knowing them at the time of "Execute before".
In that point I wonder is there some helper docs how to write an IDE package, which eventually will be compiled with the IDE and will have access to
Project1.CompilerOptions.MakeOptionsString()?
I have seen plenty such packages (e.g. EducationLaz, AnchorDockingDsgn) which seems to be an integral part of the IDE after installed. I don't want to mess with the original IDE sources but rather to make such package for the test.