libman, allow to register and entry from a dub proj

This commit is contained in:
Basile Burg 2015-09-19 11:01:50 +02:00
parent fb8c0495a1
commit 2aee98ace0
1 changed files with 16 additions and 20 deletions

View File

@ -36,7 +36,7 @@ type
procedure btnMoveDownClick(Sender: TObject); procedure btnMoveDownClick(Sender: TObject);
procedure ListEdited(Sender: TObject; Item: TListItem; var AValue: string); procedure ListEdited(Sender: TObject; Item: TListItem; var AValue: string);
private private
fProj: TCENativeProject; fProj: ICECommonProject;
//TODO-cDUB: register a static lib in libman via a DUB project //TODO-cDUB: register a static lib in libman via a DUB project
procedure updateRegistrable; procedure updateRegistrable;
procedure projNew(aProject: ICECommonProject); procedure projNew(aProject: ICECommonProject);
@ -79,23 +79,19 @@ end;
procedure TCELibManEditorWidget.updateRegistrable; procedure TCELibManEditorWidget.updateRegistrable;
begin begin
btnReg.Enabled := (fProj <> nil) and btnReg.Enabled := (fProj <> nil) and (fProj.binaryKind = staticlib) and
(fProj.currentConfiguration.outputOptions.binaryKind = staticlib) and FileExists(fProj.Filename);
(FileExists(fProj.Filename))
end; end;
procedure TCELibManEditorWidget.projNew(aProject: ICECommonProject); procedure TCELibManEditorWidget.projNew(aProject: ICECommonProject);
begin begin
case aProject.getFormat of fProj := aProject;
pfNative: fProj := TCENativeProject(aProject.getProject);
pfDub:fProj := nil;
end;
end; end;
procedure TCELibManEditorWidget.projChanged(aProject: ICECommonProject); procedure TCELibManEditorWidget.projChanged(aProject: ICECommonProject);
begin begin
if fProj = nil then exit; if fProj = nil then exit;
if fProj <> aProject.getProject then if fProj <> aProject then
exit; exit;
// //
updateRegistrable; updateRegistrable;
@ -103,7 +99,7 @@ end;
procedure TCELibManEditorWidget.projClosing(aProject: ICECommonProject); procedure TCELibManEditorWidget.projClosing(aProject: ICECommonProject);
begin begin
if fProj <> aProject.getProject then if fProj <> aProject then
exit; exit;
fProj := nil; fProj := nil;
updateRegistrable; updateRegistrable;
@ -111,10 +107,7 @@ end;
procedure TCELibManEditorWidget.projFocused(aProject: ICECommonProject); procedure TCELibManEditorWidget.projFocused(aProject: ICECommonProject);
begin begin
case aProject.getFormat of fProj := aProject;
pfNative: fProj := TCENativeProject(aProject.getProject);
pfDub:fProj := nil;
end;
updateRegistrable; updateRegistrable;
end; end;
@ -154,13 +147,15 @@ end;
procedure TCELibManEditorWidget.btnRegClick(Sender: TObject); procedure TCELibManEditorWidget.btnRegClick(Sender: TObject);
var var
str: TStringList; str: TStringList;
fname: string;
root: string; root: string;
lalias: string; lalias: string;
i: integer; i: integer;
begin begin
if fProj = nil then exit; if fProj = nil then exit;
// //
lalias := ExtractFileNameOnly(fProj.Filename); fname := fProj.filename;
lalias := ExtractFileNameOnly(fname);
if List.Items.FindCaption(0, lalias, false, false, false) <> nil then if List.Items.FindCaption(0, lalias, false, false, false) <> nil then
begin begin
dlgOkInfo(format('a library item with the alias "%s" already exists, delete it before trying again.', dlgOkInfo(format('a library item with the alias "%s" already exists, delete it before trying again.',
@ -170,7 +165,7 @@ begin
// //
str := TStringList.Create; str := TStringList.Create;
try try
for i := 0 to fProj.Sources.Count-1 do for i := 0 to fProj.sourcesCount-1 do
str.Add(fProj.sourceAbsolute(i)); str.Add(fProj.sourceAbsolute(i));
// single source libs usually have the structure "src/<fname>" // single source libs usually have the structure "src/<fname>"
if str.Count = 1 then if str.Count = 1 then
@ -186,13 +181,14 @@ begin
exit; exit;
end; end;
// //
fname := fProj.outputFilename;
with List.Items.Add do with List.Items.Add do
begin begin
Caption := ExtractFileNameOnly(fProj.Filename); Caption := ExtractFileNameOnly(fname);
if ExtractFileExt(fProj.outputFilename) <> libExt then if ExtractFileExt(fname) <> libExt then
SubItems.add(fProj.outputFilename + libExt) SubItems.add(fname + libExt)
else else
SubItems.add(fProj.outputFilename); SubItems.add(fname);
SubItems.add(root); SubItems.add(root);
if not FileExists(SubItems[0]) then if not FileExists(SubItems[0]) then
dlgOkInfo('the library file does not exist, maybe the project not been already compiled ?'); dlgOkInfo('the library file does not exist, maybe the project not been already compiled ?');