mirror of https://gitlab.com/basile.b/dexed.git
additional sources can be indicated using \*
project inspector add source folder is now recursive
This commit is contained in:
parent
9ab21f2050
commit
a21d334810
|
@ -15,6 +15,10 @@ const
|
||||||
|
|
||||||
DdiagFilter = 'D source|*.d|D interface|*.di|All files|*.*';
|
DdiagFilter = 'D source|*.d|D interface|*.di|All files|*.*';
|
||||||
|
|
||||||
|
var
|
||||||
|
DExtList: TStringList;
|
||||||
|
DCompiler: string = 'dmd';
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
(**
|
(**
|
||||||
|
@ -121,7 +125,7 @@ type
|
||||||
(**
|
(**
|
||||||
* Fills aList with the names of the files located in aPath.
|
* Fills aList with the names of the files located in aPath.
|
||||||
*)
|
*)
|
||||||
procedure listFiles(const aList: TStrings; const aPath: string);
|
procedure listFiles(const aList: TStrings; const aPath: string; recursive: boolean = false);
|
||||||
|
|
||||||
(**
|
(**
|
||||||
* Fills aList with the names of the folders located in aPath.
|
* Fills aList with the names of the folders located in aPath.
|
||||||
|
@ -129,7 +133,7 @@ type
|
||||||
procedure listFolders(const aList: TStrings; const aPath: string);
|
procedure listFolders(const aList: TStrings; const aPath: string);
|
||||||
|
|
||||||
(**
|
(**
|
||||||
* Checks if aPath contains at least one sub-folder
|
* Checks if aPath contains at least one sub-folder.
|
||||||
*)
|
*)
|
||||||
function hasFolder(const aPath: string): boolean;
|
function hasFolder(const aPath: string): boolean;
|
||||||
|
|
||||||
|
@ -138,6 +142,12 @@ type
|
||||||
*)
|
*)
|
||||||
procedure listDrives(const aList: TStrings);
|
procedure listDrives(const aList: TStrings);
|
||||||
|
|
||||||
|
(**
|
||||||
|
* If aPath ends with an asterisk then fills aList with the names of the files located in aPath.
|
||||||
|
* Returns true if aPath was 'asterisk-ifyed'.
|
||||||
|
*)
|
||||||
|
function listAsteriskPath(const aPath: string; const aList: TStrings; const someExts: TStrings = nil): boolean;
|
||||||
|
|
||||||
(**
|
(**
|
||||||
* Lets the shell open a file
|
* Lets the shell open a file
|
||||||
*)
|
*)
|
||||||
|
@ -455,7 +465,13 @@ begin
|
||||||
result += directorySeparator + 'Coedit' + directorySeparator;
|
result += directorySeparator + 'Coedit' + directorySeparator;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure listFiles(const aList: TStrings; const aPath: string);
|
function isFolder(sr: TSearchRec): boolean;
|
||||||
|
begin
|
||||||
|
result := (sr.Name <> '.') and (sr.Name <> '..' )and (sr.Name <> '' ) and
|
||||||
|
(sr.Attr and faDirectory = faDirectory);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure listFiles(const aList: TStrings; const aPath: string; recursive: boolean = false);
|
||||||
var
|
var
|
||||||
sr: TSearchrec;
|
sr: TSearchrec;
|
||||||
procedure tryAdd;
|
procedure tryAdd;
|
||||||
|
@ -466,19 +482,17 @@ end;
|
||||||
begin
|
begin
|
||||||
if findFirst(aPath + directorySeparator + '*.*', faAnyFile, sr) = 0 then
|
if findFirst(aPath + directorySeparator + '*.*', faAnyFile, sr) = 0 then
|
||||||
try
|
try
|
||||||
repeat tryAdd;
|
repeat
|
||||||
until findNext(sr) <> 0;
|
tryAdd;
|
||||||
|
if recursive then if isFolder(sr) then
|
||||||
|
listFiles(aList, aPath + directorySeparator + sr.Name, recursive);
|
||||||
|
until
|
||||||
|
findNext(sr) <> 0;
|
||||||
finally
|
finally
|
||||||
sysutils.FindClose(sr);
|
sysutils.FindClose(sr);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function isFolder(sr: TSearchRec): boolean;
|
|
||||||
begin
|
|
||||||
result := (sr.Name <> '.') and (sr.Name <> '..' )and (sr.Name <> '' ) and
|
|
||||||
(sr.Attr and faDirectory = faDirectory);
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure listFolders(const aList: TStrings; const aPath: string);
|
procedure listFolders(const aList: TStrings; const aPath: string);
|
||||||
var
|
var
|
||||||
sr: TSearchrec;
|
sr: TSearchrec;
|
||||||
|
@ -513,6 +527,38 @@ begin
|
||||||
result := res;
|
result := res;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function listAsteriskPath(const aPath: string; const aList: TStrings; const someExts: TStrings = nil): boolean;
|
||||||
|
var
|
||||||
|
pth, ext, fname: string;
|
||||||
|
files: TStringList;
|
||||||
|
begin
|
||||||
|
if aPath[length(aPath)] = '*' then
|
||||||
|
begin
|
||||||
|
pth := aPath[1..length(aPath)-2];
|
||||||
|
if not directoryExists(pth) then exit(false);
|
||||||
|
//
|
||||||
|
files := TStringList.Create;
|
||||||
|
try
|
||||||
|
listFiles(files, pth, true);
|
||||||
|
for fname in files do
|
||||||
|
begin
|
||||||
|
if someExts = nil then
|
||||||
|
aList.Add(fname)
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
ext := extractFileExt(fname);
|
||||||
|
if someExts.IndexOf(ext) <> -1 then
|
||||||
|
aList.Add(fname);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
finally
|
||||||
|
files.Free;
|
||||||
|
end;
|
||||||
|
exit(true);
|
||||||
|
end;
|
||||||
|
exit(false);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure listDrives(const aList: TStrings);
|
procedure listDrives(const aList: TStrings);
|
||||||
{$IFDEF WINDOWS}
|
{$IFDEF WINDOWS}
|
||||||
var
|
var
|
||||||
|
@ -555,5 +601,10 @@ begin
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
initialization
|
||||||
|
DExtList := TStringList.Create;
|
||||||
|
DExtList.Add('.d');
|
||||||
|
DExtList.Add('.di');
|
||||||
|
finalization
|
||||||
|
DExtList.Free;
|
||||||
end.
|
end.
|
||||||
|
|
|
@ -7,6 +7,8 @@ interface
|
||||||
uses
|
uses
|
||||||
classes, sysutils, process;
|
classes, sysutils, process;
|
||||||
|
|
||||||
|
//TODO-cfeature: scanner for -I and -J sources is the item is a folder.
|
||||||
|
|
||||||
(*
|
(*
|
||||||
|
|
||||||
procedure to add a new compiler option:
|
procedure to add a new compiler option:
|
||||||
|
@ -837,7 +839,12 @@ var
|
||||||
str: string;
|
str: string;
|
||||||
begin
|
begin
|
||||||
for str in fSrcs do if str <> '' then
|
for str in fSrcs do if str <> '' then
|
||||||
|
begin
|
||||||
|
if not
|
||||||
|
listAsteriskPath(str, aList, DExtList)
|
||||||
|
then
|
||||||
aList.Add(str);
|
aList.Add(str);
|
||||||
|
end;
|
||||||
for str in fIncl do if str <> '' then
|
for str in fIncl do if str <> '' then
|
||||||
aList.Add('-I'+ str);
|
aList.Add('-I'+ str);
|
||||||
for str in fImpt do if str <> '' then
|
for str in fImpt do if str <> '' then
|
||||||
|
|
|
@ -980,7 +980,7 @@ begin
|
||||||
dmdProc.ShowWindow := swoHIDE;
|
dmdProc.ShowWindow := swoHIDE;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
dmdproc.Options := [poStdErrToOutput, poUsePipes];
|
dmdproc.Options := [poStdErrToOutput, poUsePipes];
|
||||||
dmdproc.Executable:= 'dmd';
|
dmdproc.Executable := DCompiler;
|
||||||
dmdproc.Parameters.Add(fname + '.d');
|
dmdproc.Parameters.Add(fname + '.d');
|
||||||
dmdproc.Parameters.Add('-w');
|
dmdproc.Parameters.Add('-w');
|
||||||
dmdproc.Parameters.Add('-wi');
|
dmdproc.Parameters.Add('-wi');
|
||||||
|
@ -1086,7 +1086,7 @@ begin
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
dmdproc.Options := [{$IFDEF WINDOWS}poNewConsole,{$ENDIF} poStdErrToOutput, poUsePipes];
|
dmdproc.Options := [{$IFDEF WINDOWS}poNewConsole,{$ENDIF} poStdErrToOutput, poUsePipes];
|
||||||
|
|
||||||
dmdproc.Executable := 'dmd';
|
dmdproc.Executable := DCompiler;
|
||||||
aProject.getOpts(dmdproc.Parameters);
|
aProject.getOpts(dmdproc.Parameters);
|
||||||
try
|
try
|
||||||
dmdproc.Execute;
|
dmdproc.Execute;
|
||||||
|
|
|
@ -189,7 +189,7 @@ begin
|
||||||
begin
|
begin
|
||||||
lst := TStringList.Create;
|
lst := TStringList.Create;
|
||||||
try
|
try
|
||||||
listFiles(lst, dir);
|
listFiles(lst, dir, true);
|
||||||
for i := 0 to lst.Count-1 do
|
for i := 0 to lst.Count-1 do
|
||||||
begin
|
begin
|
||||||
fname := lst.Strings[i];
|
fname := lst.Strings[i];
|
||||||
|
|
Loading…
Reference in New Issue