more for #29, check if proj target is lib and update support

This commit is contained in:
Basile Burg 2015-09-20 02:33:26 +02:00
parent f0622f3c3f
commit 77204119f8
2 changed files with 68 additions and 51 deletions

View File

@ -1,31 +1,31 @@
inherited CELibManEditorWidget: TCELibManEditorWidget
Left = 985
Height = 349
Top = 275
Width = 466
Left = 772
Height = 297
Top = 307
Width = 641
Caption = 'Library manager'
ClientHeight = 349
ClientWidth = 466
ClientHeight = 297
ClientWidth = 641
inherited Back: TPanel
Height = 349
Width = 466
ClientHeight = 349
ClientWidth = 466
Height = 297
Width = 641
ClientHeight = 297
ClientWidth = 641
inherited Content: TPanel
Height = 349
Width = 466
ClientHeight = 349
ClientWidth = 466
Height = 297
Width = 641
ClientHeight = 297
ClientWidth = 641
object Panel1: TPanel[0]
Left = 4
Height = 26
Top = 4
Width = 458
Width = 633
Align = alTop
BorderSpacing.Around = 4
BevelOuter = bvNone
ClientHeight = 26
ClientWidth = 458
ClientWidth = 633
TabOrder = 0
object btnAddLib: TBitBtn
Left = 0
@ -50,7 +50,7 @@ inherited CELibManEditorWidget: TCELibManEditorWidget
TabOrder = 1
end
object btnSelFile: TBitBtn
Left = 374
Left = 549
Height = 26
Hint = 'select the library file'
Top = 0
@ -61,7 +61,7 @@ inherited CELibManEditorWidget: TCELibManEditorWidget
TabOrder = 2
end
object btnSelRoot: TBitBtn
Left = 430
Left = 605
Height = 26
Hint = 'select the sources root'
Top = 0
@ -72,7 +72,7 @@ inherited CELibManEditorWidget: TCELibManEditorWidget
TabOrder = 3
end
object btnEditAlias: TBitBtn
Left = 346
Left = 521
Height = 26
Hint = 'edit the library alias'
Top = 0
@ -103,7 +103,7 @@ inherited CELibManEditorWidget: TCELibManEditorWidget
TabOrder = 6
end
object btnSelfoldOfFiles: TBitBtn
Left = 402
Left = 577
Height = 26
Hint = 'select a folder of library files'
Top = 0
@ -138,9 +138,9 @@ inherited CELibManEditorWidget: TCELibManEditorWidget
end
object List: TListView[1]
Left = 4
Height = 311
Height = 259
Top = 34
Width = 458
Width = 633
Align = alClient
BorderSpacing.Around = 4
Columns = <
@ -173,5 +173,8 @@ inherited CELibManEditorWidget: TCELibManEditorWidget
inherited contextMenu: TPopupMenu
left = 184
top = 8
object MenuItem1: TMenuItem[0]
Caption = 'New Item1'
end
end
end

View File

@ -25,6 +25,7 @@ type
btnSelfoldOfFiles: TBitBtn;
btnSelRoot: TBitBtn;
List: TListView;
MenuItem1: TMenuItem;
Panel1: TPanel;
procedure btnAddLibClick(Sender: TObject);
procedure btnDubFetchClick(Sender: TObject);
@ -146,6 +147,7 @@ var
idx: integer;
prj: TCEDubProject;
cdy: string;
upd: boolean;
begin
if not InputQuery('DUB library import', 'please enter the name of the package',
nme) then exit;
@ -161,22 +163,29 @@ begin
pth := GetEnvironmentVariable('HOME') + '/.dub/packages/' + nme + '-master';
{$ENDIF}
itf := getMessageDisplay;
if DirectoryExists(pth) then
if DirectoryExists(pth) then;
begin
itf.message('the dub package is already fetched', nil, amcApp, amkInf);
exit;
upd := true;
itf.message('information, the dub package is already fetched and will be upgraded', nil, amcApp, amkInf);
end;
// fetch
// fetch / updgrade
dub := TProcess.Create(nil);
try
dub.Executable:= 'dub';
dub.Options:= [poUsePipes, poStderrToOutPut];
dub.Parameters.Add('fetch');
dub.Parameters.Add(nme);
// fetch project, version handling, pth is hard to set because of semVer suffix.
// needed: a folder monitor to detect the one created by dub.
dub.Parameters.Add('--version=~master');
if not upd then
begin
dub.Parameters.Add('fetch');
dub.Parameters.Add(nme);
// fetch project, version handling, pth is hard to set because of semVer suffix.
// needed: a folder monitor to detect the one created by dub.
dub.Parameters.Add('--version=~master');
end else
begin
dub.CurrentDirectory := pth;
dub.Parameters.Add('upgrade');
end;
dub.Execute;
while dub.Running do sleep(10);
err := dub.ExitStatus;
@ -193,7 +202,7 @@ begin
end;
if err <> 0 then
begin
itf.message('error, failed to fetch the repository using DUB', nil, amcApp, amkErr);
itf.message('error, failed to fetch or upgrade the repository', nil, amcApp, amkErr);
exit;
end;
@ -221,7 +230,7 @@ begin
end;
if err <> 0 then
begin
itf.message('error, failed to compile the library to register', nil, amcApp, amkErr);
itf.message('error, failed to compile the package to register', nil, amcApp, amkErr);
exit;
end;
@ -233,26 +242,31 @@ begin
prj.loadFromFile(pth + DirectorySeparator + 'dub.json')
else if FileExists(pth + DirectorySeparator + 'package.json') then
prj.loadFromFile(pth + DirectorySeparator + 'package.json');
str := TStringList.Create;
try
for idx := 0 to prj.sourcesCount-1 do
str.Add(prj.sourceAbsolute(idx));
with List.Items.Add do
begin
Caption := nme;
SubItems.Add(prj.outputFilename);
if str.Count = 1 then
cdy := ExtractFileDir(str.Strings[0])
else begin
cdy := commonFolder(str);
cdy := ExtractFileDir(cdy);
if (prj.filename <> '') and (prj.binaryKind = staticlib) then
begin
str := TStringList.Create;
try
for idx := 0 to prj.sourcesCount-1 do
str.Add(prj.sourceAbsolute(idx));
if not upd then with List.Items.Add do
begin
Caption := nme;
SubItems.Add(prj.outputFilename);
if str.Count = 1 then
cdy := ExtractFileDir(str.Strings[0])
else begin
cdy := commonFolder(str);
cdy := ExtractFileDir(cdy);
end;
SubItems.Add(cdy);
Selected:=true;
end;
SubItems.Add(cdy);
Selected:=true;
finally
str.Free;
end;
finally
str.Free;
end;
end else
itf.message('warning, the package to register can not be found or the target is not a static library',
nil, amcApp, amkWarn);
finally
prj.Free;
EntitiesConnector.endUpdate;