[fpc-devel] build unit dependency list

Mario R. Carro mcarro at gmx.net
Fri Aug 4 14:53:00 CEST 2006


Hi, I have a few hand made makefiles for some (up to now) Delphi projects that 
I use to build the releases. I would want to be able to automagically 
generate the dependencies for the units in the projects. 

I found that Lazarus has a dependencies view window. So after some browsing I 
wrote the following minimal test program:

program getpdeps;
{$mode objfpc}{$H+}
uses
  Classes,
  CodeCache,
  CodeToolManager;
var
  IntfFiles, ImplFiles: TStrings;
  Cache: TCodeCache;
  Buffer: TCodeBuffer;
begin
  Cache := TCodeCache.Create;
  IntfFiles := TStringList.Create;
  ImplFiles := TStringList.Create;
  try
    Buffer := Cache.LoadFile(ParamStr(1));
    CodeToolBoss.ActivateWriteLock;
    try
      CodeToolBoss.FindUsedUnitFiles(Buffer, IntfFiles, ImplFiles);
      WriteLn('intf=' + IntfFiles.CommaText);
      WriteLn('impl=' + ImplFiles.CommaText);
    finally
      CodeToolBoss.DeactivateWriteLock;
      Buffer.Free;
    end;
  finally
    Cache.Free;
    IntfFiles.Free;
    ImplFiles.Free;
  end;
end.

It does what I need but it fails because it couldn't find some units. How do I 
tell CodeToolBoss where to find them?

Thanks in advance,
Mario



More information about the fpc-devel mailing list