mirror of https://gitlab.com/basile.b/dexed.git
import ana in runnables use dastworx
+ fix interface of several functions: TStringList -> TStrings + separate unit for the calls to dastworx
This commit is contained in:
parent
e27d216bf6
commit
7b9da4fe99
|
@ -205,7 +205,7 @@ type
|
||||||
(**
|
(**
|
||||||
* Clears then fills aList with aProcess output stream.
|
* Clears then fills aList with aProcess output stream.
|
||||||
*)
|
*)
|
||||||
procedure processOutputToStrings(aProcess: TProcess; var aList: TStringList);
|
procedure processOutputToStrings(aProcess: TProcess; aList: TStrings);
|
||||||
|
|
||||||
(**
|
(**
|
||||||
* Copy available process output to a stream.
|
* Copy available process output to a stream.
|
||||||
|
@ -856,7 +856,7 @@ begin
|
||||||
exit(ExeSearch(anExeName, env));
|
exit(ExeSearch(anExeName, env));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure processOutputToStrings(aProcess: TProcess; var aList: TStringList);
|
procedure processOutputToStrings(aProcess: TProcess; aList: TStrings);
|
||||||
var
|
var
|
||||||
str: TMemoryStream;
|
str: TMemoryStream;
|
||||||
sum: Integer = 0;
|
sum: Integer = 0;
|
||||||
|
|
|
@ -0,0 +1,87 @@
|
||||||
|
unit ce_dastworx;
|
||||||
|
{$I ce_defines.inc}
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses
|
||||||
|
Classes, SysUtils, process, ce_common;
|
||||||
|
|
||||||
|
(**
|
||||||
|
* Gets the module name and the imports of the source code located in
|
||||||
|
* "source". The first line of "import" contains the module name, double quoted.
|
||||||
|
* Each following line contain an import.
|
||||||
|
*)
|
||||||
|
procedure getModuleImports(source, imports: TStrings);
|
||||||
|
|
||||||
|
(**
|
||||||
|
* Gets the module names and the imports of the sources in "files".
|
||||||
|
* source. Each line in "import" that contains double quoted text indicates
|
||||||
|
* that a new group of import starts.
|
||||||
|
*)
|
||||||
|
procedure getModulesImports(const files: string; results: TStrings);
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
var
|
||||||
|
toolname: string;
|
||||||
|
|
||||||
|
function getToolName: string;
|
||||||
|
begin
|
||||||
|
if toolname = '' then
|
||||||
|
toolname := exeFullName('dastworx' + exeExt);
|
||||||
|
exit(toolname);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure getModuleImports(source, imports: TStrings);
|
||||||
|
var
|
||||||
|
str: string;
|
||||||
|
prc: TProcess;
|
||||||
|
begin
|
||||||
|
str := getToolName;
|
||||||
|
if str.isEmpty then
|
||||||
|
exit;
|
||||||
|
prc := TProcess.Create(nil);
|
||||||
|
try
|
||||||
|
prc.Executable := str;
|
||||||
|
prc.Parameters.Add('-i');
|
||||||
|
prc.Options := [poUsePipes{$IFDEF WINDOWS}, poNewConsole{$ENDIF}];
|
||||||
|
prc.ShowWindow := swoHIDE;
|
||||||
|
prc.Execute;
|
||||||
|
str := source.Text;
|
||||||
|
prc.Input.Write(str[1], str.length);
|
||||||
|
prc.CloseInput;
|
||||||
|
while prc.Running do
|
||||||
|
sleep(1);
|
||||||
|
processOutputToStrings(prc, imports);
|
||||||
|
finally
|
||||||
|
prc.free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure getModulesImports(const files: string; results: TStrings);
|
||||||
|
var
|
||||||
|
str: string;
|
||||||
|
prc: TProcess;
|
||||||
|
begin
|
||||||
|
str := getToolName;
|
||||||
|
if str.isEmpty then
|
||||||
|
exit;
|
||||||
|
prc := TProcess.Create(nil);
|
||||||
|
try
|
||||||
|
prc.Executable := str;
|
||||||
|
prc.Parameters.Add(files);
|
||||||
|
prc.Parameters.Add('-i');
|
||||||
|
prc.Options := [poUsePipes, poStderrToOutPut{$IFDEF WINDOWS}, poNewConsole{$ENDIF}];
|
||||||
|
prc.ShowWindow := swoHIDE;
|
||||||
|
prc.Execute;
|
||||||
|
prc.CloseInput;
|
||||||
|
while prc.Running do
|
||||||
|
sleep(1);
|
||||||
|
processOutputToStrings(prc, results);
|
||||||
|
finally
|
||||||
|
prc.free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
end.
|
||||||
|
|
|
@ -568,31 +568,30 @@ end;
|
||||||
|
|
||||||
procedure TLibraryManager.getLibsForSource(source, libs, paths: TStrings);
|
procedure TLibraryManager.getLibsForSource(source, libs, paths: TStrings);
|
||||||
var
|
var
|
||||||
tks: TLexTokenList;
|
|
||||||
imp: TStringList;
|
imp: TStringList;
|
||||||
i,j: integer;
|
i,j: integer;
|
||||||
itm: TLibraryItem;
|
itm: TLibraryItem;
|
||||||
dep: TLibraryItem;
|
dep: TLibraryItem;
|
||||||
sel: TLibraryList;
|
sel: TLibraryList;
|
||||||
begin
|
begin
|
||||||
tks := TLexTokenList.Create;
|
|
||||||
imp := TStringList.Create;
|
imp := TStringList.Create;
|
||||||
sel := TLibraryList.Create;
|
sel := TLibraryList.create;
|
||||||
try
|
try
|
||||||
lex(source.Text, tks, nil, [lxoNoComments]);
|
getModuleImports(source, imp);
|
||||||
getImports(tks, imp);
|
for i:= 1 to imp.Count-1 do
|
||||||
for i:= 0 to imp.Count-1 do
|
|
||||||
begin
|
begin
|
||||||
// get library for import I
|
// get library for import I
|
||||||
itm := libraryByImport[imp[i]];
|
itm := libraryByImport[imp[i]];
|
||||||
if itm.isNotNil then
|
if itm.isNotNil then
|
||||||
begin
|
begin
|
||||||
|
if sel.contains(itm) then
|
||||||
|
continue;
|
||||||
sel.insert(itm);
|
sel.insert(itm);
|
||||||
// get libraries for import I dependencies
|
// get libraries for import I dependencies
|
||||||
for j:= itm.dependencies.Count-1 downto 0 do
|
for j:= itm.dependencies.Count-1 downto 0 do
|
||||||
begin
|
begin
|
||||||
dep := libraryByAlias[itm.dependencies[j]];
|
dep := libraryByAlias[itm.dependencies[j]];
|
||||||
if dep.isNotNil then
|
if dep.isNotNil and not sel.contains(dep) then
|
||||||
sel.insert(dep)
|
sel.insert(dep)
|
||||||
//auto update: item removed, detect on usage that it has disapeared
|
//auto update: item removed, detect on usage that it has disapeared
|
||||||
else
|
else
|
||||||
|
@ -614,7 +613,6 @@ begin
|
||||||
end;
|
end;
|
||||||
finally
|
finally
|
||||||
sel.Free;
|
sel.Free;
|
||||||
tks.Free;
|
|
||||||
imp.Free;
|
imp.Free;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
@ -647,7 +645,9 @@ begin
|
||||||
if dep.isNil or (dep.libAlias = 'phobos') or (dep.libAlias = 'druntime') then
|
if dep.isNil or (dep.libAlias = 'phobos') or (dep.libAlias = 'druntime') then
|
||||||
continue;
|
continue;
|
||||||
// add deps
|
// add deps
|
||||||
libraryByIndex[i].dependencies.Add(dep.libAlias);
|
if lib.dependencies.IndexOf(dep.libAlias) > -1 then
|
||||||
|
continue;
|
||||||
|
lib.dependencies.Add(dep.libAlias);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
Loading…
Reference in New Issue