fix #265 - In the libman allow to register projects that are not libraries

This commit is contained in:
Basile Burg 2018-03-04 17:19:08 +01:00
parent e1b07c6168
commit f8c5e686c8
3 changed files with 60 additions and 18 deletions

View File

@ -479,11 +479,14 @@ procedure TLibraryManager.getLibFiles(aliases, list: TStrings);
procedure add(lib: TLibraryItem);
var
j: integer;
e: string;
f: string;
x: string;
dir: string;
lst: TstringList;
begin
// as a trick a folder can be set as source, this allows to pass
// multiple sources in an automated way.
// multiple sources | static libs in an automated way.
if lib.libFile.dirExists then
begin
lst := TStringList.Create;
@ -491,12 +494,20 @@ procedure TLibraryManager.getLibFiles(aliases, list: TStrings);
dir := lib.libFile;
if lib.libFile[dir.length] = DirectorySeparator then
dir := dir[1..dir.length-1];
listFiles(lst, dir);
listFiles(lst, dir, true);
for j:= 0 to lst.Count-1 do
begin
if lst[j].extractFileExt = libExt then
if list.IndexOf(lst[j]) = -1 then
list.Add(lst[j]);
f := lst[j];
x := f.extractFileName;
// The libman allows registration of projects thate not libs and using
// a folder of sources instead of the *.a / *.lib file.
// Following DUB conventions here are filtered out named supposed to
// contain the __Dmain() func, which is not wanted for runnables mods.
if (x = 'app.d') or (x = 'main.d') then
continue;
e := f.extractFileExt;
if ((e = libExt) or (e = '.d')) and (list.IndexOf(f) = -1) then
list.Add(f);
end;
finally
lst.Free;

View File

@ -13,14 +13,14 @@ inherited CELibManEditorWidget: TCELibManEditorWidget
ClientHeight = 297
ClientWidth = 641
inherited Content: TPanel
Height = 263
Top = 34
Height = 261
Top = 36
Width = 641
ClientHeight = 263
ClientHeight = 261
ClientWidth = 641
object List: TListView[0]
Left = 4
Height = 255
Height = 253
Top = 4
Width = 633
Align = alClient
@ -58,7 +58,6 @@ inherited CELibManEditorWidget: TCELibManEditorWidget
end
end
inherited toolbar: TCEToolBar
Height = 28
Width = 633
object btnSelProj: TCEToolButton[0]
Left = 342

View File

@ -91,6 +91,15 @@ const
notav: string = '< n/a >';
enableStr: array [boolean] of string = ('false','true');
function YesOrNoAddProjSourceFolder: TModalResult;
begin
result :=
dlgYesNo('The registered project is not a library '+
'however it is possible to make its sources accessible for unittesting and executing runnable modules. ' +
'If you click `YES` this will be done, otherwise the new entry will only be used for the completions.');
end;
constructor TCELibManEditorWidget.Create(aOwner: TComponent);
begin
inherited;
@ -101,8 +110,7 @@ procedure TCELibManEditorWidget.updateButtonsState;
var
i: TIconScaledSize;
begin
btnReg.Enabled := (fProj <> nil) and (fProj.binaryKind = staticlib) and
fProj.Filename.fileExists;
btnReg.Enabled := (fProj <> nil) and fProj.Filename.fileExists;
btnOpenProj.Enabled := List.Selected.isNotNil and
List.Selected.SubItems[2].fileExists;
i := GetIconScaledSize;
@ -595,7 +603,7 @@ begin
prj := TCEDubProject.create(nil);
try
prj.loadFromFile(dfn);
if prj.filename.isNotEmpty and (prj.binaryKind = staticlib) then
if prj.filename.isNotEmpty then
begin
if (ovw and not List.items.findCaption(nme, row)) or not ovw then
row := List.Items.Add;
@ -603,7 +611,15 @@ begin
row.Data := LibMan.libraries.Add;
row.Caption := nme;
row.SubItems.Clear;
row.SubItems.Add(prj.outputFilename);
if prj.binaryKind = staticlib then
row.SubItems.Add(prj.outputFilename)
else
begin
if YesOrNoAddProjSourceFolder() = mrYes then
row.SubItems.add(projectSourcePath(prj))
else
row.SubItems.Add('');
end;
row.SubItems.Add(projectSourcePath(prj as ICECommonProject));
row.SubItems.Add(prj.filename);
row.SubItems.Add(enableStr[true]);
@ -695,6 +711,7 @@ var
root: string;
lalias: string;
row: TListItem;
itf: ICEMessagesDisplay;
begin
if fProj = nil then
exit;
@ -708,6 +725,8 @@ begin
exit;
end;
itf := getMessageDisplay;
str := TStringList.Create;
try
root := projectSourcePath(fProj);
@ -720,15 +739,28 @@ begin
row := List.Items.Add;
row.Data := LibMan.libraries.Add;
row.Caption := lalias;
if fname.extractFileExt <> libExt then
row.SubItems.add(fname + libExt)
if (fname.extractFileExt <> libExt) then
begin
if (fname + libExt).fileExists then
begin
row.SubItems.add(fname + libExt);
if not row.SubItems[0].fileExists then
itf.message('warning, the library file does not exist, maybe the project not been already compiled ?',
nil, amcMisc, amkWarn);
end
else
begin
if YesOrNoAddProjSourceFolder() = mrYes then
row.SubItems.add(projectSourcePath(fProj))
else
row.SubItems.add('');
end;
end
else
row.SubItems.add(fname);
row.SubItems.add(root);
row.SubItems.add(fProj.filename);
row.SubItems.add(enableStr[true]);
if not row.SubItems[0].fileExists then
dlgOkInfo('the library file does not exist, maybe the project not been already compiled ?');
row.Selected:= true;
row.MakeVisible(false);
SetFocus;