mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-29 16:20:55 +02:00
* compile command added
* basic work for package dependencies git-svn-id: trunk@9168 -
This commit is contained in:
parent
03ec4e8b3c
commit
33b5d4d73c
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -8741,7 +8741,6 @@ utils/fppkg/lnet/sys/lkqueueeventerh.inc svneol=native#text/plain
|
|||||||
utils/fppkg/lnet/sys/lspawnfcgiunix.inc svneol=native#text/plain
|
utils/fppkg/lnet/sys/lspawnfcgiunix.inc svneol=native#text/plain
|
||||||
utils/fppkg/lnet/sys/lspawnfcgiwin.inc svneol=native#text/plain
|
utils/fppkg/lnet/sys/lspawnfcgiwin.inc svneol=native#text/plain
|
||||||
utils/fppkg/lnet/sys/osunits.inc svneol=native#text/plain
|
utils/fppkg/lnet/sys/osunits.inc svneol=native#text/plain
|
||||||
utils/fppkg/pkgarchive.pp svneol=native#text/plain
|
|
||||||
utils/fppkg/pkgcommands.pp svneol=native#text/plain
|
utils/fppkg/pkgcommands.pp svneol=native#text/plain
|
||||||
utils/fppkg/pkgdownload.pp svneol=native#text/plain
|
utils/fppkg/pkgdownload.pp svneol=native#text/plain
|
||||||
utils/fppkg/pkgfpmake.pp svneol=native#text/plain
|
utils/fppkg/pkgfpmake.pp svneol=native#text/plain
|
||||||
|
@ -13,7 +13,7 @@ uses
|
|||||||
pkgmessages, pkgglobals, pkgoptions, pkgrepos,
|
pkgmessages, pkgglobals, pkgoptions, pkgrepos,
|
||||||
// Package Handler components
|
// Package Handler components
|
||||||
pkghandler,pkgmkconv, pkgdownload,
|
pkghandler,pkgmkconv, pkgdownload,
|
||||||
pkgarchive, pkgfpmake, pkgcommands
|
pkgfpmake, pkgcommands
|
||||||
// Downloaders
|
// Downloaders
|
||||||
{$if defined(unix) or defined(windows)}
|
{$if defined(unix) or defined(windows)}
|
||||||
,pkgwget
|
,pkgwget
|
||||||
@ -25,10 +25,9 @@ Type
|
|||||||
|
|
||||||
TMakeTool = Class(TCustomApplication)
|
TMakeTool = Class(TCustomApplication)
|
||||||
Private
|
Private
|
||||||
ActionStack : TActionStack;
|
ActionStack : TActionStack;
|
||||||
ParaAction : string;
|
ParaAction : string;
|
||||||
ParaPackages : TStringList;
|
ParaPackages : TStringList;
|
||||||
procedure GenerateParaActions;
|
|
||||||
procedure MaybeCreateLocalDirs;
|
procedure MaybeCreateLocalDirs;
|
||||||
procedure ShowUsage;
|
procedure ShowUsage;
|
||||||
Public
|
Public
|
||||||
@ -248,40 +247,12 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure TMakeTool.GenerateParaActions;
|
|
||||||
var
|
|
||||||
ActionPackage : TFPPackage;
|
|
||||||
i : integer;
|
|
||||||
begin
|
|
||||||
if GetPkgHandler(ParaAction)<>nil then
|
|
||||||
begin
|
|
||||||
if ParaPackages.Count=0 then
|
|
||||||
begin
|
|
||||||
Log(vDebug,SLogCommandLineAction,['[<currentdir>]',ParaAction]);
|
|
||||||
ActionStack.Push(nil,ParaAction,[]);
|
|
||||||
end
|
|
||||||
else
|
|
||||||
begin
|
|
||||||
for i:=0 to ParaPackages.Count-1 do
|
|
||||||
begin
|
|
||||||
ActionPackage:=CurrentRepository.PackageByName(ParaPackages[i]);
|
|
||||||
Log(vDebug,SLogCommandLineAction,['['+ActionPackage.Name+']',ParaAction]);
|
|
||||||
ActionStack.Push(ActionPackage,ParaAction,[]);
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end
|
|
||||||
else
|
|
||||||
Raise EMakeToolError.CreateFmt(SErrInvalidCommand,[ParaAction]);
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
procedure TMakeTool.DoRun;
|
procedure TMakeTool.DoRun;
|
||||||
var
|
var
|
||||||
Action : string;
|
|
||||||
ActionPackage : TFPPackage;
|
ActionPackage : TFPPackage;
|
||||||
Args : TActionArgs;
|
|
||||||
OldCurrDir : String;
|
OldCurrDir : String;
|
||||||
Res : Boolean;
|
Res : Boolean;
|
||||||
|
i : Integer;
|
||||||
begin
|
begin
|
||||||
OldCurrDir:=GetCurrentDir;
|
OldCurrDir:=GetCurrentDir;
|
||||||
LoadGlobalDefaults;
|
LoadGlobalDefaults;
|
||||||
@ -290,13 +261,24 @@ begin
|
|||||||
MaybeCreateLocalDirs;
|
MaybeCreateLocalDirs;
|
||||||
LoadCompilerDefaults;
|
LoadCompilerDefaults;
|
||||||
LoadLocalRepository;
|
LoadLocalRepository;
|
||||||
GenerateParaActions;
|
|
||||||
|
|
||||||
repeat
|
if ParaPackages.Count=0 then
|
||||||
if not ActionStack.Pop(ActionPackage,Action,Args) then
|
begin
|
||||||
break;
|
Log(vDebug,SLogCommandLineAction,['[<currentdir>]',ParaAction]);
|
||||||
res:=pkghandler.ExecuteAction(ActionPackage,Action,Args);
|
res:=pkghandler.ExecuteAction(nil,ParaAction);
|
||||||
until not res;
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
for i:=0 to ParaPackages.Count-1 do
|
||||||
|
begin
|
||||||
|
ActionPackage:=CurrentRepository.PackageByName(ParaPackages[i]);
|
||||||
|
Log(vDebug,SLogCommandLineAction,['['+ActionPackage.Name+']',ParaAction]);
|
||||||
|
res:=pkghandler.ExecuteAction(ActionPackage,ParaAction);
|
||||||
|
if not res then
|
||||||
|
break;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
Terminate;
|
Terminate;
|
||||||
|
|
||||||
except
|
except
|
||||||
|
@ -26,15 +26,20 @@ Const
|
|||||||
StreamSignature = $FEEF;
|
StreamSignature = $FEEF;
|
||||||
|
|
||||||
Type
|
Type
|
||||||
TOS = (osNone,Amiga,Atari,Darwin,FreeBSD,Go32v2,Linux,MacOS,MorphOS,NetBSD,
|
// Keep syncronized with fpmkunit.pp
|
||||||
Netware,NetwLibc,OpenBSD,OS2,PalmOS,Solaris,Win32,Win64,WinCE,Emx);
|
TCpu=(cpuNone,
|
||||||
TOSes = Set of TOS;
|
i386,m68k,powerpc,sparc,x86_64,arm,powerpc64
|
||||||
|
);
|
||||||
TCPU = (cpuNone,Arm,I386,PPC,SPARC,X86_64,M68K,PPC64);
|
|
||||||
TCPUS = Set of TCPU;
|
TCPUS = Set of TCPU;
|
||||||
|
|
||||||
TCompilerMode = (cmFPC,cmTP,cmObjFPC,cmDelphi,cmMacPas);
|
// Keep syncronized with fpmkunit.pp
|
||||||
TCompilerModes = Set of TCompilerMode;
|
TOS=(osNone,
|
||||||
|
linux,go32v2,win32,os2,freebsd,beos,netbsd,
|
||||||
|
amiga,atari, solaris, qnx, netware, openbsd,wdosx,
|
||||||
|
palmos,macos,darwin,emx,watcom,morphos,netwlibc,
|
||||||
|
win64,wince,gba,nds,embedded,symbian
|
||||||
|
);
|
||||||
|
TOSes = Set of TOS;
|
||||||
|
|
||||||
{ TFPVersion }
|
{ TFPVersion }
|
||||||
|
|
||||||
@ -214,8 +219,6 @@ Function StringToOS(S : String) : TOS;
|
|||||||
Function OSesToString(S : String) : TOSes;
|
Function OSesToString(S : String) : TOSes;
|
||||||
Function StringToCPU(S : String) : TCPU;
|
Function StringToCPU(S : String) : TCPU;
|
||||||
Function StringToCPUS(S : String) : TCPUS;
|
Function StringToCPUS(S : String) : TCPUS;
|
||||||
Function ModeToString(Mode: TCompilerMode) : String;
|
|
||||||
Function StringToMode(S : String) : TCompilerMode;
|
|
||||||
Function MakeTargetString(CPU : TCPU;OS: TOS) : String;
|
Function MakeTargetString(CPU : TCPU;OS: TOS) : String;
|
||||||
Procedure StringToCPUOS(S : String; Var CPU : TCPU; Var OS: TOS);
|
Procedure StringToCPUOS(S : String; Var CPU : TCPU; Var OS: TOS);
|
||||||
|
|
||||||
@ -300,25 +303,6 @@ begin
|
|||||||
Result:=TCPUS(StringToSet(PTypeInfo(TypeInfo(TCPUS)),S));
|
Result:=TCPUS(StringToSet(PTypeInfo(TypeInfo(TCPUS)),S));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Function ModeToString(Mode: TCompilerMode) : String;
|
|
||||||
|
|
||||||
begin
|
|
||||||
Result:=LowerCase(GetenumName(TypeInfo(TCompilerMode),Ord(Mode)));
|
|
||||||
end;
|
|
||||||
|
|
||||||
Function StringToMode(S : String) : TCompilerMode;
|
|
||||||
|
|
||||||
Var
|
|
||||||
I : Integer;
|
|
||||||
|
|
||||||
begin
|
|
||||||
I:=GetEnumValue(TypeInfo(TCompilerMode),S);
|
|
||||||
if (I=-1) then
|
|
||||||
Raise EPackage.CreateFmt(SErrInvalidMode,[S]);
|
|
||||||
Result:=TCompilerMode(I);
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
Function MakeTargetString(CPU : TCPU;OS: TOS) : String;
|
Function MakeTargetString(CPU : TCPU;OS: TOS) : String;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
@ -460,9 +444,6 @@ end;
|
|||||||
|
|
||||||
procedure TFPPackage.SetName(const AValue: String);
|
procedure TFPPackage.SetName(const AValue: String);
|
||||||
|
|
||||||
Var
|
|
||||||
I : Integer;
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
If (AValue<>FName) and (AValue<>'') then
|
If (AValue<>FName) and (AValue<>'') then
|
||||||
If (Collection<>Nil) and (Collection is TFPPackages) then
|
If (Collection<>Nil) and (Collection is TFPPackages) then
|
||||||
@ -482,7 +463,7 @@ end;
|
|||||||
|
|
||||||
function TFPPackage.GetHasDependencies: Boolean;
|
function TFPPackage.GetHasDependencies: Boolean;
|
||||||
begin
|
begin
|
||||||
Result:=Assigned(FDependencies) and (FDependencies.Count>0);
|
Result:=(Dependencies<>nil) and (FDependencies.Count>0);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TFPPackage.GetFileName: String;
|
function TFPPackage.GetFileName: String;
|
||||||
@ -766,7 +747,6 @@ procedure TFPRepository.SaveToFile(AFileName: String);
|
|||||||
|
|
||||||
Var
|
Var
|
||||||
F : TFileStream;
|
F : TFileStream;
|
||||||
S : String;
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
If FileExists(AFileName) and BackupFiles then
|
If FileExists(AFileName) and BackupFiles then
|
||||||
|
@ -1,142 +0,0 @@
|
|||||||
unit pkgarchive;
|
|
||||||
|
|
||||||
{$mode objfpc}{$H+}
|
|
||||||
|
|
||||||
interface
|
|
||||||
|
|
||||||
uses
|
|
||||||
Classes,SysUtils,pkghandler;
|
|
||||||
|
|
||||||
type
|
|
||||||
{ TUnzipArchive }
|
|
||||||
|
|
||||||
TUnzipArchive = Class(TPackagehandler)
|
|
||||||
Private
|
|
||||||
Procedure UnzipArchive;
|
|
||||||
Public
|
|
||||||
Function Execute(const Args:TActionArgs):boolean;override;
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
{$ifdef OLDCREATEARCHIVE}
|
|
||||||
{ TCreateArchive }
|
|
||||||
|
|
||||||
TCreateArchive = Class(TPackagehandler)
|
|
||||||
Private
|
|
||||||
Procedure CreateArchive;
|
|
||||||
Public
|
|
||||||
Function Execute(const Args:TActionArgs):boolean;override;
|
|
||||||
end;
|
|
||||||
{$endif OLDCREATEARCHIVE}
|
|
||||||
|
|
||||||
|
|
||||||
implementation
|
|
||||||
|
|
||||||
uses
|
|
||||||
fprepos,
|
|
||||||
fpxmlrep,
|
|
||||||
zipper,
|
|
||||||
uriparser,
|
|
||||||
pkgglobals,
|
|
||||||
pkgmessages;
|
|
||||||
|
|
||||||
{ TUnzipArchive }
|
|
||||||
|
|
||||||
Procedure TUnzipArchive.UnzipArchive;
|
|
||||||
Var
|
|
||||||
BuildDir : string;
|
|
||||||
ArchiveFile : String;
|
|
||||||
begin
|
|
||||||
ArchiveFile:=PackageLocalArchive;
|
|
||||||
BuildDir:=PackageBuildPath;
|
|
||||||
{ Download file if it doesn't exists yet }
|
|
||||||
if not FileExists(ArchiveFile) then
|
|
||||||
ExecuteAction(CurrentPackage,'downloadpackage');
|
|
||||||
{ Create builddir, remove it first if needed }
|
|
||||||
if DirectoryExists(BuildDir) then
|
|
||||||
DeleteDir(BuildDir);
|
|
||||||
ForceDirectories(BuildDir);
|
|
||||||
SetCurrentDir(BuildDir);
|
|
||||||
{ Unzip Archive }
|
|
||||||
With TUnZipper.Create do
|
|
||||||
try
|
|
||||||
Log(vCommands,SLogUnzippping,[ArchiveFile]);
|
|
||||||
OutputPath:=PackageBuildPath;
|
|
||||||
UnZipAllFiles(ArchiveFile);
|
|
||||||
Finally
|
|
||||||
Free;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
function TUnzipArchive.Execute(const Args:TActionArgs):boolean;
|
|
||||||
begin
|
|
||||||
{$warning TODO Check arguments}
|
|
||||||
UnzipArchive;
|
|
||||||
result:=true;
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
{$ifdef OLDCREATEARCHIVE}
|
|
||||||
{ TCreateArchive }
|
|
||||||
|
|
||||||
procedure TCreateArchive.CreateArchive;
|
|
||||||
var
|
|
||||||
P : TFPPackage;
|
|
||||||
PS : TFPPackages;
|
|
||||||
X : TFPXMLRepositoryHandler;
|
|
||||||
SL : TStringList;
|
|
||||||
begin
|
|
||||||
if assigned(CurrentPackage) then
|
|
||||||
Error(SErrOnlyLocalDir);
|
|
||||||
{ Generate manifest.xml if it doesn't exists yet }
|
|
||||||
if not FileExists(PackageManifestFile) then
|
|
||||||
ExecuteAction(CurrentPackage,'fpmakemanifest');
|
|
||||||
{ Load manifest.xml }
|
|
||||||
PS:=TFPPackages.Create(TFPPackage);
|
|
||||||
X:=TFPXMLRepositoryHandler.Create;
|
|
||||||
With X do
|
|
||||||
try
|
|
||||||
LoadFromXml(PS,PackageManifestFile);
|
|
||||||
finally
|
|
||||||
Free;
|
|
||||||
end;
|
|
||||||
{ Create archive, currently support only 1 file per package, this
|
|
||||||
can be enhanced in the future if needed }
|
|
||||||
if PS.Count<>1 then
|
|
||||||
Error('Only one package supported per manifest');
|
|
||||||
P:=PS[0];
|
|
||||||
{ Unzip Archive }
|
|
||||||
With TZipper.Create do
|
|
||||||
try
|
|
||||||
Log(vCommands,SLogZippping,[P.FileName]);
|
|
||||||
{$warning TODO replace with files from manifest}
|
|
||||||
try
|
|
||||||
SL:=TStringList.Create;
|
|
||||||
SearchFiles(SL,AllFiles);
|
|
||||||
if SL.Count=0 then
|
|
||||||
Error('No files found');
|
|
||||||
ZipFiles(P.FileName,SL);
|
|
||||||
finally
|
|
||||||
SL.Free;
|
|
||||||
end;
|
|
||||||
Finally
|
|
||||||
Free;
|
|
||||||
end;
|
|
||||||
P.Free;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TCreateArchive.Execute(const Args: TActionArgs): boolean;
|
|
||||||
begin
|
|
||||||
CreateArchive;
|
|
||||||
Result:=true;
|
|
||||||
end;
|
|
||||||
{$endif OLDCREATEARCHIVE}
|
|
||||||
|
|
||||||
|
|
||||||
initialization
|
|
||||||
RegisterPkgHandler('unziparchive',TUnzipArchive);
|
|
||||||
{$ifdef OLDCREATEARCHIVE}
|
|
||||||
RegisterPkgHandler('createarchive',TCreateArchive);
|
|
||||||
{$endif OLDCREATEARCHIVE}
|
|
||||||
end.
|
|
@ -10,11 +10,13 @@ uses
|
|||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
|
zipper,
|
||||||
pkgmessages,
|
pkgmessages,
|
||||||
pkgglobals,
|
pkgglobals,
|
||||||
pkgoptions,
|
pkgoptions,
|
||||||
pkgdownload,
|
pkgdownload,
|
||||||
pkgrepos;
|
pkgrepos,
|
||||||
|
fprepos;
|
||||||
|
|
||||||
type
|
type
|
||||||
{ TCommandAddConfig }
|
{ TCommandAddConfig }
|
||||||
@ -59,6 +61,13 @@ type
|
|||||||
Function Execute(const Args:TActionArgs):boolean;override;
|
Function Execute(const Args:TActionArgs):boolean;override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ TCommandCompile }
|
||||||
|
|
||||||
|
TCommandCompile = Class(TPackagehandler)
|
||||||
|
Public
|
||||||
|
Function Execute(const Args:TActionArgs):boolean;override;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TCommandBuild }
|
{ TCommandBuild }
|
||||||
|
|
||||||
TCommandBuild = Class(TPackagehandler)
|
TCommandBuild = Class(TPackagehandler)
|
||||||
@ -80,6 +89,13 @@ type
|
|||||||
Function Execute(const Args:TActionArgs):boolean;override;
|
Function Execute(const Args:TActionArgs):boolean;override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ TCommandInstallDependencies }
|
||||||
|
|
||||||
|
TCommandInstallDependencies = Class(TPackagehandler)
|
||||||
|
Public
|
||||||
|
Function Execute(const Args:TActionArgs):boolean;override;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
function TCommandAddConfig.Execute(const Args:TActionArgs):boolean;
|
function TCommandAddConfig.Execute(const Args:TActionArgs):boolean;
|
||||||
begin
|
begin
|
||||||
@ -127,10 +143,42 @@ end;
|
|||||||
|
|
||||||
|
|
||||||
function TCommandUnzip.Execute(const Args:TActionArgs):boolean;
|
function TCommandUnzip.Execute(const Args:TActionArgs):boolean;
|
||||||
|
Var
|
||||||
|
BuildDir : string;
|
||||||
|
ArchiveFile : String;
|
||||||
begin
|
begin
|
||||||
|
BuildDir:=PackageBuildPath;
|
||||||
|
ArchiveFile:=PackageLocalArchive;
|
||||||
if not assigned(CurrentPackage) then
|
if not assigned(CurrentPackage) then
|
||||||
Error(SErrNoPackageSpecified);
|
Error(SErrNoPackageSpecified);
|
||||||
ExecuteAction(CurrentPackage,'unziparchive',Args);
|
if not FileExists(ArchiveFile) then
|
||||||
|
ExecuteAction(CurrentPackage,'downloadpackage');
|
||||||
|
{ Create builddir, remove it first if needed }
|
||||||
|
if DirectoryExists(BuildDir) then
|
||||||
|
DeleteDir(BuildDir);
|
||||||
|
ForceDirectories(BuildDir);
|
||||||
|
SetCurrentDir(BuildDir);
|
||||||
|
{ Unzip Archive }
|
||||||
|
With TUnZipper.Create do
|
||||||
|
try
|
||||||
|
Log(vCommands,SLogUnzippping,[ArchiveFile]);
|
||||||
|
OutputPath:=PackageBuildPath;
|
||||||
|
UnZipAllFiles(ArchiveFile);
|
||||||
|
Finally
|
||||||
|
Free;
|
||||||
|
end;
|
||||||
|
Result:=true;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function TCommandCompile.Execute(const Args:TActionArgs):boolean;
|
||||||
|
begin
|
||||||
|
if assigned(CurrentPackage) then
|
||||||
|
begin
|
||||||
|
ExecuteAction(CurrentPackage,'unzip',Args);
|
||||||
|
ExecuteAction(CurrentPackage,'installdependencies',Args);
|
||||||
|
end;
|
||||||
|
ExecuteAction(CurrentPackage,'fpmakecompile',Args);
|
||||||
Result:=true;
|
Result:=true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -139,8 +187,8 @@ function TCommandBuild.Execute(const Args:TActionArgs):boolean;
|
|||||||
begin
|
begin
|
||||||
if assigned(CurrentPackage) then
|
if assigned(CurrentPackage) then
|
||||||
begin
|
begin
|
||||||
if not DirectoryExists(PackageBuildPath) then
|
ExecuteAction(CurrentPackage,'unzip',Args);
|
||||||
ExecuteAction(CurrentPackage,'unziparchive',Args);
|
ExecuteAction(CurrentPackage,'installdependencies',Args);
|
||||||
end;
|
end;
|
||||||
ExecuteAction(CurrentPackage,'fpmakebuild',Args);
|
ExecuteAction(CurrentPackage,'fpmakebuild',Args);
|
||||||
Result:=true;
|
Result:=true;
|
||||||
@ -149,6 +197,8 @@ end;
|
|||||||
|
|
||||||
function TCommandInstall.Execute(const Args:TActionArgs):boolean;
|
function TCommandInstall.Execute(const Args:TActionArgs):boolean;
|
||||||
begin
|
begin
|
||||||
|
if assigned(CurrentPackage) then
|
||||||
|
ExecuteAction(CurrentPackage,'build',Args);
|
||||||
ExecuteAction(CurrentPackage,'fpmakeinstall',Args);
|
ExecuteAction(CurrentPackage,'fpmakeinstall',Args);
|
||||||
Result:=true;
|
Result:=true;
|
||||||
end;
|
end;
|
||||||
@ -161,13 +211,57 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function TCommandInstallDependencies.Execute(const Args:TActionArgs):boolean;
|
||||||
|
var
|
||||||
|
i : Integer;
|
||||||
|
D : TFPDependency;
|
||||||
|
DepPackage : TFPPackage;
|
||||||
|
L : TStringList;
|
||||||
|
status : string;
|
||||||
|
begin
|
||||||
|
if not assigned(CurrentPackage) then
|
||||||
|
Error(SErrNoPackageSpecified);
|
||||||
|
// List dependencies
|
||||||
|
L:=TStringList.Create;
|
||||||
|
for i:=0 to CurrentPackage.Dependencies.Count-1 do
|
||||||
|
begin
|
||||||
|
D:=CurrentPackage.Dependencies[i];
|
||||||
|
DepPackage:=CurrentRepository.PackageByName(D.PackageName);
|
||||||
|
// Need installation?
|
||||||
|
if (not DepPackage.InstalledVersion.Empty) and
|
||||||
|
(DepPackage.InstalledVersion.CompareVersion(D.MinVersion)<0) then
|
||||||
|
begin
|
||||||
|
if DepPackage.Version.CompareVersion(D.MinVersion)<0 then
|
||||||
|
status:='Required Version Not Available!'
|
||||||
|
else
|
||||||
|
status:='Needs update';
|
||||||
|
L.Add(DepPackage.Name);
|
||||||
|
end
|
||||||
|
else
|
||||||
|
status:='OK';
|
||||||
|
Log(vDebug,'Dependency '+D.PackageName+'-'+D.MinVersion.AsString+' ('+status+')');
|
||||||
|
end;
|
||||||
|
// Install needed updates
|
||||||
|
for i:=0 to L.Count-1 do
|
||||||
|
begin
|
||||||
|
DepPackage:=CurrentRepository.PackageByName(L[i]);
|
||||||
|
ExecuteAction(DepPackage,'install');
|
||||||
|
end;
|
||||||
|
|
||||||
|
FreeAndNil(L);
|
||||||
|
Result:=true;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
RegisterPkgHandler('update',TCommandUpdate);
|
RegisterPkgHandler('update',TCommandUpdate);
|
||||||
RegisterPkgHandler('avail',TCommandAvail);
|
RegisterPkgHandler('avail',TCommandAvail);
|
||||||
RegisterPkgHandler('scan',TCommandScanPackages);
|
RegisterPkgHandler('scan',TCommandScanPackages);
|
||||||
RegisterPkgHandler('download',TCommandDownload);
|
RegisterPkgHandler('download',TCommandDownload);
|
||||||
RegisterPkgHandler('unzip',TCommandUnzip);
|
RegisterPkgHandler('unzip',TCommandUnzip);
|
||||||
|
RegisterPkgHandler('compile',TCommandCompile);
|
||||||
RegisterPkgHandler('build',TCommandBuild);
|
RegisterPkgHandler('build',TCommandBuild);
|
||||||
RegisterPkgHandler('install',TCommandInstall);
|
RegisterPkgHandler('install',TCommandInstall);
|
||||||
RegisterPkgHandler('archive',TCommandArchive);
|
RegisterPkgHandler('archive',TCommandArchive);
|
||||||
|
RegisterPkgHandler('installdependencies',TCommandInstallDependencies);
|
||||||
end.
|
end.
|
||||||
|
@ -104,7 +104,6 @@ Var
|
|||||||
F : TFileStream;
|
F : TFileStream;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Log(vCommands,SLogDownloading,[URL,DestFileName]);
|
|
||||||
If FileExists(DestFileName) and BackupFiles then
|
If FileExists(DestFileName) and BackupFiles then
|
||||||
BackupFile(DestFileName);
|
BackupFile(DestFileName);
|
||||||
F:=TFileStream.Create(DestFileName,fmCreate);
|
F:=TFileStream.Create(DestFileName,fmCreate);
|
||||||
@ -141,6 +140,7 @@ function TDownloadPackage.Execute(const Args:TActionArgs):boolean;
|
|||||||
begin
|
begin
|
||||||
with DownloaderClass.Create(nil) do
|
with DownloaderClass.Create(nil) do
|
||||||
try
|
try
|
||||||
|
Log(vCommands,SLogDownloading,[PackageRemoteArchive,PackageLocalArchive]);
|
||||||
Download(PackageRemoteArchive,PackageLocalArchive);
|
Download(PackageRemoteArchive,PackageLocalArchive);
|
||||||
finally
|
finally
|
||||||
Free;
|
Free;
|
||||||
|
@ -34,6 +34,14 @@ type
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
{ TFPMakeRunnerCompile }
|
||||||
|
|
||||||
|
TFPMakeRunnerCompile = Class(TFPMakeRunner)
|
||||||
|
Public
|
||||||
|
Function Execute(const Args:TActionArgs):boolean;override;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
{ TFPMakeRunnerBuild }
|
{ TFPMakeRunnerBuild }
|
||||||
|
|
||||||
TFPMakeRunnerBuild = Class(TFPMakeRunner)
|
TFPMakeRunnerBuild = Class(TFPMakeRunner)
|
||||||
@ -276,13 +284,18 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function TFPMakeRunnerCompile.Execute(const Args:TActionArgs):boolean;
|
||||||
|
begin
|
||||||
|
result:=(RunFPMake('compile')=0);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
function TFPMakeRunnerBuild.Execute(const Args:TActionArgs):boolean;
|
function TFPMakeRunnerBuild.Execute(const Args:TActionArgs):boolean;
|
||||||
begin
|
begin
|
||||||
result:=(RunFPMake('build')=0);
|
result:=(RunFPMake('build')=0);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function TFPMakeRunnerInstall.Execute(const Args:TActionArgs):boolean;
|
function TFPMakeRunnerInstall.Execute(const Args:TActionArgs):boolean;
|
||||||
begin
|
begin
|
||||||
result:=(RunFPMake('install')=0);
|
result:=(RunFPMake('install')=0);
|
||||||
@ -305,6 +318,7 @@ end;
|
|||||||
|
|
||||||
initialization
|
initialization
|
||||||
RegisterPkgHandler('compilefpmake',TFPMakeCompiler);
|
RegisterPkgHandler('compilefpmake',TFPMakeCompiler);
|
||||||
|
RegisterPkgHandler('fpmakecompile',TFPMakeRunnerCompile);
|
||||||
RegisterPkgHandler('fpmakebuild',TFPMakeRunnerBuild);
|
RegisterPkgHandler('fpmakebuild',TFPMakeRunnerBuild);
|
||||||
RegisterPkgHandler('fpmakeinstall',TFPMakeRunnerInstall);
|
RegisterPkgHandler('fpmakeinstall',TFPMakeRunnerInstall);
|
||||||
RegisterPkgHandler('fpmakemanifest',TFPMakeRunnerManifest);
|
RegisterPkgHandler('fpmakemanifest',TFPMakeRunnerManifest);
|
||||||
|
@ -201,6 +201,9 @@ Procedure DeleteDir(const ADir:string);
|
|||||||
var
|
var
|
||||||
Info : TSearchRec;
|
Info : TSearchRec;
|
||||||
begin
|
begin
|
||||||
|
// Prevent accidently deleting all files in current or root dir
|
||||||
|
if (ADir='') or (ADir=PathDelim) then
|
||||||
|
exit;
|
||||||
if FindFirst(ADir+PathDelim+AllFiles,faAnyFile, Info)=0 then
|
if FindFirst(ADir+PathDelim+AllFiles,faAnyFile, Info)=0 then
|
||||||
try
|
try
|
||||||
repeat
|
repeat
|
||||||
|
@ -76,7 +76,8 @@ uses
|
|||||||
pkgmessages;
|
pkgmessages;
|
||||||
|
|
||||||
var
|
var
|
||||||
PkgHandlerList : TFPHashList;
|
PkgHandlerList : TFPHashList;
|
||||||
|
ExecutedActions : TFPHashList;
|
||||||
|
|
||||||
procedure RegisterPkgHandler(const AAction:string;pkghandlerclass:TPackageHandlerClass);
|
procedure RegisterPkgHandler(const AAction:string;pkghandlerclass:TPackageHandlerClass);
|
||||||
begin
|
begin
|
||||||
@ -102,8 +103,22 @@ var
|
|||||||
pkghandlerclass : TPackageHandlerClass;
|
pkghandlerclass : TPackageHandlerClass;
|
||||||
i : integer;
|
i : integer;
|
||||||
logargs : string;
|
logargs : string;
|
||||||
|
FullActionName : string;
|
||||||
begin
|
begin
|
||||||
result:=false;
|
result:=false;
|
||||||
|
// Check if we have already executed or are executing the action
|
||||||
|
if assigned(Apackage) then
|
||||||
|
FullActionName:=APackage.Name+AAction
|
||||||
|
else
|
||||||
|
FullActionName:=AAction;
|
||||||
|
if ExecutedActions.Find(FullActionName)<>nil then
|
||||||
|
begin
|
||||||
|
Log(vDebug,'Already executed or executing action '+FullActionName);
|
||||||
|
result:=true;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
ExecutedActions.Add(FullActionName,Pointer(PtrUInt(1)));
|
||||||
|
// Create action handler class
|
||||||
pkghandlerclass:=GetPkgHandler(AAction);
|
pkghandlerclass:=GetPkgHandler(AAction);
|
||||||
With pkghandlerclass.Create(nil,APackage) do
|
With pkghandlerclass.Create(nil,APackage) do
|
||||||
try
|
try
|
||||||
@ -115,8 +130,9 @@ begin
|
|||||||
else
|
else
|
||||||
logargs:=logargs+','+Args[i];
|
logargs:=logargs+','+Args[i];
|
||||||
end;
|
end;
|
||||||
Log(vDebug,SLogRunAction,[AAction,logargs]);
|
Log(vDebug,SLogRunAction+' start',[AAction,logargs]);
|
||||||
result:=Execute(Args);
|
result:=Execute(Args);
|
||||||
|
Log(vDebug,SLogRunAction+' end',[AAction,logargs]);
|
||||||
finally
|
finally
|
||||||
Free;
|
Free;
|
||||||
end;
|
end;
|
||||||
@ -278,6 +294,8 @@ end;
|
|||||||
|
|
||||||
initialization
|
initialization
|
||||||
PkgHandlerList:=TFPHashList.Create;
|
PkgHandlerList:=TFPHashList.Create;
|
||||||
|
ExecutedActions:=TFPHashList.Create;
|
||||||
finalization
|
finalization
|
||||||
FreeAndNil(PkgHandlerList);
|
FreeAndNil(PkgHandlerList);
|
||||||
|
FreeAndNil(ExecutedActions);
|
||||||
end.
|
end.
|
||||||
|
Loading…
Reference in New Issue
Block a user