Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2006-08

build unit dependency list

6 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Mario R. Carro

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

Reply by email

Mattias Gaertner
to Mario R. Carro
Show quoted text 41 lines
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?

See the codetools example finddeclaration.lpi.

BTW:
CodeToolBos already creates a code cache and many functions expect, that you only use that one. To load a file, use Buffer:=CodeToolBoss.LoadFile. And the ActivateWriteLock is only needed, when doing multiple searches.

Mattias

Reply by email

Peter Vreman
to Mario R. Carro: Hi, I have a few hand made makefiles for some (up to now) Delphi projects that I use to…
you wrote
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.

It is normally a lot faster to create a buildunit that references all other units and let the compiler decide if it needs to rebuild a unit or not.

Peter

Reply by email

Mario R. Carro
to Peter Vreman
Peter Vreman wrote 10 lines
At 14:53 4-8-2006, you wrote: >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. It is normally a lot faster to create a buildunit that references all other units and let the compiler decide if it needs to rebuild a unit or not.

Yes, but that would mean that I must manually update that unit everytime a new item is added the the uses clause of any unit of the projects... I want exactly the opposite: automatic dependency discovery for the (re)generation of the releases and for project auditing.

Thanks,
Mario

Show quoted text 6 lines
Peter _______________________________________________ fpc-devel maillist - http://lists.freepascal.org/mailman/listinfo/fpc-devel
THREADS SRL Tel: (54-291) 488-7451 e-Mail: Web: www.threads-srl.com

Reply by email

Mario R. Carro
Show quoted text 51 lines
On Fri, 4 Aug 2006 09:53:00 -0300 "Mario R. Carro" wrote: > 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? See the codetools example finddeclaration.lpi. BTW: CodeToolBoss already creates a code cache and many functions expect, that you only use that one. To load a file, use Buffer:=CodeToolBoss.LoadFile. And the ActivateWriteLock is only needed, when doing multiple searches.

Ok, great hints! But... every time I run the app I something like this:

Scanning FPC sources may take a while ...
An unhandled exception occurred at $0809BF16 :
EListError : List index (1) out of bounds

Adding the CodeToolBoss.Init(Options) line to my test app produces analog outputs. Excuse I cannot be more specific but the debugger does not seem to be working :( I verfied the gdb path and checked the linker options, but it does not stop on breakpoints.

Thanks,
Mario

Mattias

-------------------------------------------------------

Reply by email

Vincent Snijders
to Mario R. Carro: Yes, but that would mean that I must manually update that unit everytime a new item is…
Mario R. Carro wrote 20 lines
On Saturday 05 August 2006 10:39, Peter Vreman wrote: >At 14:53 4-8-2006, you wrote: > >>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. > >It is normally a lot faster to create a buildunit that references all >other units and let the compiler decide if it needs to rebuild a unit or >not. > Yes, but that would mean that I must manually update that unit everytime a new item is added the the uses clause of any unit of the projects... I want exactly the opposite: automatic dependency discovery for the (re)generation of the releases and for project auditing.

Compile the project and all dependent units get recompiled, if they need to be recompiled.

Vincent

Reply by email