libman, uses dastworx to analyze the library imports

This commit is contained in:
Basile Burg 2016-07-04 20:36:40 +02:00
parent 31d2f6d724
commit 029f9bd751
3 changed files with 55 additions and 31 deletions

View File

@ -226,7 +226,7 @@
<PackageName Value="LCL"/> <PackageName Value="LCL"/>
</Item7> </Item7>
</RequiredPackages> </RequiredPackages>
<Units Count="51"> <Units Count="52">
<Unit0> <Unit0>
<Filename Value="coedit.lpr"/> <Filename Value="coedit.lpr"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
@ -492,6 +492,10 @@
<Filename Value="..\src\ce_d2synpresets.pas"/> <Filename Value="..\src\ce_d2synpresets.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
</Unit50> </Unit50>
<Unit51>
<Filename Value="..\src\ce_dastworx.pas"/>
<IsPartOfProject Value="True"/>
</Unit51>
</Units> </Units>
</ProjectOptions> </ProjectOptions>
<CompilerOptions> <CompilerOptions>

View File

@ -11,7 +11,8 @@ uses
ce_writableComponent, ce_staticmacro, ce_inspectors, ce_editoroptions, ce_writableComponent, ce_staticmacro, ce_inspectors, ce_editoroptions,
ce_dockoptions, ce_shortcutseditor, ce_mru, ce_processes, ce_dubproject, ce_dockoptions, ce_shortcutseditor, ce_mru, ce_processes, ce_dubproject,
ce_dialogs, ce_dubprojeditor, ce_controls, ce_dfmt, ce_lcldragdrop, ce_dialogs, ce_dubprojeditor, ce_controls, ce_dfmt, ce_lcldragdrop,
ce_stringrange, ce_dlangmaps, ce_projgroup, ce_projutils, ce_d2synpresets; ce_stringrange, ce_dlangmaps, ce_projgroup, ce_projutils, ce_d2synpresets,
ce_dastworx;
{$R *.res} {$R *.res}

View File

@ -5,8 +5,9 @@ unit ce_libman;
interface interface
uses uses
Classes, SysUtils, FileUtil, ce_common, ce_writableComponent, ce_dcd, LazFileUtils, Classes, SysUtils, FileUtil, ce_common, ce_writableComponent, LazFileUtils,
ce_dialogs, ce_projutils, ce_interfaces, ce_dlang, ghashmap, ghashset; ghashmap, ghashset, process,
ce_dcd, ce_dialogs, ce_projutils, ce_interfaces, ce_dlang, ce_dastworx;
type type
@ -220,11 +221,11 @@ end;
procedure TLibraryItem.updateModulesInfo; procedure TLibraryItem.updateModulesInfo;
var var
prj: ICECommonProject; prj: ICECommonProject;
tks: TLexTokenList;
str: TStringList; str: TStringList;
lst: TStringList; mdi: TModuleInfo = nil;
mdi: TModuleInfo; fls: string = '';
fle: string; fle: string;
lne: string;
i: integer; i: integer;
begin begin
fModules.Clear; fModules.Clear;
@ -233,52 +234,70 @@ begin
if hasValidLibProject then if hasValidLibProject then
begin begin
prj := loadProject(fLibProject, true); prj := loadProject(fLibProject, true);
tks := TLexTokenList.Create;
str := TStringList.Create; str := TStringList.Create;
try try
for i:= 0 to prj.sourcesCount-1 do for i:= 0 to prj.sourcesCount-1 do
begin begin
fle := prj.sourceAbsolute(i); fle := prj.sourceAbsolute(i);
// note: in CE, object files are considered as source since they're taken in the cmdline file list
if not hasDlangSyntax(fle.extractFileExt) then if not hasDlangSyntax(fle.extractFileExt) then
continue; continue;
str.LoadFromFile(fle); fls += fle;
lex(str.Text, tks, nil, [lxoNoComments]); if i <> prj.sourcesCount-1 then
mdi := addModuleInfo; fls += PathSeparator;
mdi.name := getModuleName(tks); end;
fModulesByName.insert(mdi.name, mdi); getModulesImports(fls, str);
getImports(tks, mdi.imports); for i := 0 to str.Count-1 do
tks.Clear; begin
lne := str[i];
if lne[1] = '"' then
begin
lne := lne[2..lne.length-1];
mdi := addModuleInfo;
mdi.name:= lne;
fModulesByName.insert(lne, mdi);
end else
begin
if not lne.isEmpty and mdi.isNotNil then
mdi.imports.Add(lne);
end;
end; end;
finally finally
tks.Free;
str.Free; str.Free;
prj.getProject.Free; prj.getProject.Free;
end; end;
end else if hasValidLibSourcePath then end else if hasValidLibSourcePath then
begin begin
lst := TStringList.Create;
str := TStringList.Create; str := TStringList.Create;
tks := TLexTokenList.Create;
try try
listFiles(lst, fLibSourcePath, true); listFiles(str, fLibSourcePath, true);
for i := 0 to lst.Count-1 do for i:= 0 to str.Count-1 do
begin begin
fle := lst[i]; fle := str[i];
if not hasDlangSyntax(fle.extractFileExt) then if not hasDlangSyntax(fle.extractFileExt) then
continue; continue;
str.LoadFromFile(fle); fls += fle;
lex(str.Text, tks, nil, [lxoNoComments]); if i <> str.Count-1 then
mdi := addModuleInfo; fls += PathSeparator;
mdi.name := getModuleName(tks); end;
fModulesByName.insert(mdi.name, mdi); str.Clear;
getImports(tks, mdi.imports); getModulesImports(fls, str);
tks.Clear; for i := 0 to str.Count-1 do
begin
lne := str[i];
if lne[1] = '"' then
begin
lne := lne[2..lne.length-1];
mdi := addModuleInfo;
mdi.name:= lne;
fModulesByName.insert(lne, mdi);
end else
begin
if not lne.isEmpty and mdi.isNotNil then
mdi.imports.Add(lne);
end;
end; end;
finally finally
lst.Free;
str.Free; str.Free;
tks.Free;
end; end;
end; end;
end; end;