* pkgglobals added

* prepare for recursive executeaction

git-svn-id: trunk@6474 -
This commit is contained in:
peter 2007-02-13 17:18:01 +00:00
parent 41a108bbc3
commit b928627d6d
17 changed files with 1001 additions and 464 deletions

5
.gitattributes vendored
View File

@ -8261,13 +8261,14 @@ utils/fppkg/pkgarchive.pp svneol=native#text/plain
utils/fppkg/pkgcommands.pp svneol=native#text/plain
utils/fppkg/pkgdownload.pp svneol=native#text/plain
utils/fppkg/pkgfpmake.pp svneol=native#text/plain
utils/fppkg/pkgglobals.pp svneol=native#text/plain
utils/fppkg/pkghandler.pp svneol=native#text/plain
utils/fppkg/pkglibcurl.pp svneol=native#text/plain
utils/fppkg/pkglnet.pas svneol=native#text/plain
utils/fppkg/pkglnet.pp svneol=native#text/plain
utils/fppkg/pkgmessages.pp svneol=native#text/plain
utils/fppkg/pkgmkconv.pp svneol=native#text/plain
utils/fppkg/pkgocurl.pp svneol=native#text/plain
utils/fppkg/pkgropts.pp svneol=native#text/plain
utils/fppkg/pkgoptions.pp svneol=native#text/plain
utils/fppkg/pkgsynapse.pp svneol=native#text/plain
utils/fppkg/pkgwget.pp svneol=native#text/plain
utils/fppkg/rep2xml.lpi svneol=native#text/plain

File diff suppressed because it is too large Load Diff

View File

@ -8,7 +8,8 @@ version=2.0.0
[target]
programs=fppkg
units=fpmktype fpmkunit fprepos fpxmlrep pkgropts pkghandler pkgmkconv pkgdownload
units=fpmktype fpmkunit fprepos fpxmlrep
implicitunits=pkgoptions pkgglobals pkgmessages pkghandler pkgmkconv pkgdownload pkgarchive pkgfpmake pkgcommands
units_linux=pkgwget pkglnet pkglibcurl
units_freebsd=pkgwget pkglnet pkglibcurl
units_netbsd=pkgwget pkglnet pkglibcurl
@ -19,15 +20,14 @@ units_win32=pkgwget pkglnet
units_win64=pkgwget pkglnet
units_wince=pkgwget pkglnet
examples=rep2xml
rsts=fprepos fpxmlrep fppkg
rsts=fprepos fpxmlrep pkgmessages
[compiler]
unitdir=$(FCL20) lnet
includedir=lnet/sys
[clean]
units=$(FCL20UNITS) lCommon lControlStack lEvents lTelnet lftp lhttp lhttputil lnet lstrbuffer \
pkgarchive pkgcommands pkgfpmake pkgmessages
units=$(FCL20UNITS) lCommon lControlStack lEvents lTelnet lftp lhttp lhttputil lnet lstrbuffer
[install]
fpcpackage=y

View File

@ -1,7 +1,7 @@
<?xml version="1.0"?>
<CONFIG>
<ProjectOptions>
<PathDelim Value="\"/>
<PathDelim Value="/"/>
<Version Value="5"/>
<General>
<Flags>
@ -12,7 +12,7 @@
<MainUnit Value="0"/>
<IconPath Value=".\"/>
<TargetFileExt Value=""/>
<ActiveEditorIndexAtStart Value="1"/>
<ActiveEditorIndexAtStart Value="10"/>
</General>
<VersionInfo>
<ProjectVersion Value=""/>
@ -21,7 +21,6 @@
</VersionInfo>
<PublishOptions>
<Version Value="2"/>
<DestinationDirectory Value="$(TestDir)\publishedproject\"/>
<IgnoreBinaries Value="False"/>
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
<ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
@ -29,45 +28,43 @@
<RunParams>
<local>
<FormatVersion Value="1"/>
<LaunchingApplication PathPlusParams="\usr\X11R6\bin\xterm -T 'Lazarus Run Output' -e $(LazarusDir)\tools\runwait.sh $(TargetCmdLine)"/>
<LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
</local>
</RunParams>
<Units Count="32">
<Units Count="35">
<Unit0>
<Filename Value="fppkg.pp"/>
<IsPartOfProject Value="True"/>
<UnitName Value="fppkg"/>
<CursorPos X="32" Y="21"/>
<TopLine Value="1"/>
<CursorPos X="1" Y="85"/>
<TopLine Value="58"/>
<EditorIndex Value="0"/>
<UsageCount Value="67"/>
<UsageCount Value="68"/>
<Loaded Value="True"/>
</Unit0>
<Unit1>
<Filename Value="pkgropts.pp"/>
<IsPartOfProject Value="True"/>
<UnitName Value="pkgropts"/>
<CursorPos X="1" Y="1"/>
<UnitName Value="pkgoptions"/>
<CursorPos X="41" Y="18"/>
<TopLine Value="1"/>
<EditorIndex Value="7"/>
<UsageCount Value="67"/>
<Loaded Value="True"/>
<UsageCount Value="68"/>
</Unit1>
<Unit2>
<Filename Value="fpmkcnst.inc"/>
<IsPartOfProject Value="True"/>
<CursorPos X="64" Y="8"/>
<TopLine Value="1"/>
<UsageCount Value="67"/>
<UsageCount Value="68"/>
</Unit2>
<Unit3>
<Filename Value="fpmktype.pp"/>
<IsPartOfProject Value="True"/>
<UnitName Value="fpmktype"/>
<CursorPos X="1" Y="1"/>
<CursorPos X="3" Y="41"/>
<TopLine Value="1"/>
<EditorIndex Value="12"/>
<UsageCount Value="67"/>
<EditorIndex Value="9"/>
<UsageCount Value="68"/>
<Loaded Value="True"/>
</Unit3>
<Unit4>
@ -76,9 +73,7 @@
<UnitName Value="fpmkunit"/>
<CursorPos X="1" Y="1"/>
<TopLine Value="1"/>
<EditorIndex Value="3"/>
<UsageCount Value="67"/>
<Loaded Value="True"/>
<UsageCount Value="68"/>
</Unit4>
<Unit5>
<Filename Value="fprepos.pp"/>
@ -86,9 +81,7 @@
<UnitName Value="fprepos"/>
<CursorPos X="1" Y="1"/>
<TopLine Value="1"/>
<EditorIndex Value="5"/>
<UsageCount Value="67"/>
<Loaded Value="True"/>
<UsageCount Value="68"/>
</Unit5>
<Unit6>
<Filename Value="fpxmlrep.pp"/>
@ -96,48 +89,46 @@
<UnitName Value="fpxmlrep"/>
<CursorPos X="1" Y="1"/>
<TopLine Value="1"/>
<EditorIndex Value="6"/>
<UsageCount Value="67"/>
<Loaded Value="True"/>
<UsageCount Value="68"/>
</Unit6>
<Unit7>
<Filename Value="pkghandler.pp"/>
<IsPartOfProject Value="True"/>
<UnitName Value="pkghandler"/>
<CursorPos X="1" Y="107"/>
<TopLine Value="89"/>
<EditorIndex Value="15"/>
<UsageCount Value="67"/>
<CursorPos X="125" Y="197"/>
<TopLine Value="175"/>
<EditorIndex Value="1"/>
<UsageCount Value="68"/>
<Loaded Value="True"/>
</Unit7>
<Unit8>
<Filename Value="pkgmkconv.pp"/>
<IsPartOfProject Value="True"/>
<UnitName Value="pkgmkconv"/>
<CursorPos X="36" Y="131"/>
<TopLine Value="97"/>
<EditorIndex Value="14"/>
<UsageCount Value="67"/>
<CursorPos X="14" Y="53"/>
<TopLine Value="29"/>
<EditorIndex Value="3"/>
<UsageCount Value="68"/>
<Loaded Value="True"/>
</Unit8>
<Unit9>
<Filename Value="pkgdownload.pp"/>
<IsPartOfProject Value="True"/>
<UnitName Value="pkgdownload"/>
<CursorPos X="1" Y="1"/>
<TopLine Value="1"/>
<EditorIndex Value="13"/>
<UsageCount Value="67"/>
<CursorPos X="14" Y="44"/>
<TopLine Value="28"/>
<EditorIndex Value="4"/>
<UsageCount Value="68"/>
<Loaded Value="True"/>
</Unit9>
<Unit10>
<Filename Value="pkgmessages.pp"/>
<IsPartOfProject Value="True"/>
<UnitName Value="pkgmessages"/>
<CursorPos X="1" Y="1"/>
<CursorPos X="55" Y="14"/>
<TopLine Value="1"/>
<EditorIndex Value="11"/>
<UsageCount Value="67"/>
<EditorIndex Value="8"/>
<UsageCount Value="68"/>
<Loaded Value="True"/>
</Unit10>
<Unit11>
@ -155,21 +146,19 @@
<UsageCount Value="5"/>
</Unit12>
<Unit13>
<Filename Value="..\..\..\fpc20\rtl\objpas\classes\classesh.inc"/>
<Filename Value="../../../fpc20/rtl/objpas/classes/classesh.inc"/>
<CursorPos X="14" Y="599"/>
<TopLine Value="580"/>
<EditorIndex Value="2"/>
<UsageCount Value="33"/>
<Loaded Value="True"/>
</Unit13>
<Unit14>
<Filename Value="..\..\..\fpc20\rtl\inc\objpash.inc"/>
<Filename Value="../../../fpc20/rtl/inc/objpash.inc"/>
<CursorPos X="38" Y="277"/>
<TopLine Value="269"/>
<UsageCount Value="31"/>
</Unit14>
<Unit15>
<Filename Value="..\..\..\fpc20\fcl\inc\contnrs.pp"/>
<Filename Value="../../../fpc20/fcl/inc/contnrs.pp"/>
<UnitName Value="contnrs"/>
<CursorPos X="1" Y="19"/>
<TopLine Value="1"/>
@ -185,18 +174,18 @@
<Unit17>
<Filename Value="pkgcommands.pp"/>
<UnitName Value="pkgcommands"/>
<CursorPos X="21" Y="88"/>
<TopLine Value="68"/>
<EditorIndex Value="9"/>
<CursorPos X="28" Y="50"/>
<TopLine Value="1"/>
<EditorIndex Value="7"/>
<UsageCount Value="32"/>
<Loaded Value="True"/>
</Unit17>
<Unit18>
<Filename Value="pkgwget.pp"/>
<UnitName Value="pkgwget"/>
<CursorPos X="1" Y="1"/>
<TopLine Value="1"/>
<EditorIndex Value="4"/>
<CursorPos X="14" Y="26"/>
<TopLine Value="15"/>
<EditorIndex Value="2"/>
<UsageCount Value="27"/>
<Loaded Value="True"/>
</Unit18>
@ -224,9 +213,9 @@
<Unit22>
<Filename Value="pkgarchive.pp"/>
<UnitName Value="pkgarchive"/>
<CursorPos X="32" Y="61"/>
<TopLine Value="50"/>
<EditorIndex Value="8"/>
<CursorPos X="14" Y="27"/>
<TopLine Value="1"/>
<EditorIndex Value="5"/>
<UsageCount Value="23"/>
<Loaded Value="True"/>
</Unit22>
@ -249,24 +238,22 @@
<UnitName Value="zipper"/>
<CursorPos X="21" Y="1324"/>
<TopLine Value="1303"/>
<EditorIndex Value="1"/>
<UsageCount Value="15"/>
<Loaded Value="True"/>
</Unit25>
<Unit26>
<Filename Value="..\..\..\fpc20\rtl\objpas\sysutils\filutilh.inc"/>
<Filename Value="../../../fpc20/rtl/objpas/sysutils/filutilh.inc"/>
<CursorPos X="12" Y="53"/>
<TopLine Value="40"/>
<UsageCount Value="13"/>
</Unit26>
<Unit27>
<Filename Value="..\..\..\fpc20\rtl\inc\systemh.inc"/>
<Filename Value="../../../fpc20/rtl/inc/systemh.inc"/>
<CursorPos X="3" Y="214"/>
<TopLine Value="313"/>
<UsageCount Value="13"/>
</Unit27>
<Unit28>
<Filename Value="..\..\..\fpc20\rtl\objpas\sysutils\datih.inc"/>
<Filename Value="../../../fpc20/rtl/objpas/sysutils/datih.inc"/>
<CursorPos X="16" Y="93"/>
<TopLine Value="86"/>
<UsageCount Value="13"/>
@ -279,7 +266,7 @@
<UsageCount Value="11"/>
</Unit29>
<Unit30>
<Filename Value="..\..\..\fpc20\packages\base\paszlib\paszlib.pas"/>
<Filename Value="../../../fpc20/packages/base/paszlib/paszlib.pas"/>
<UnitName Value="paszlib"/>
<CursorPos X="34" Y="139"/>
<TopLine Value="118"/>
@ -288,141 +275,167 @@
<Unit31>
<Filename Value="pkgfpmake.pp"/>
<UnitName Value="pkgfpmake"/>
<CursorPos X="1" Y="89"/>
<TopLine Value="59"/>
<EditorIndex Value="10"/>
<CursorPos X="48" Y="58"/>
<TopLine Value="47"/>
<EditorIndex Value="6"/>
<UsageCount Value="12"/>
<Loaded Value="True"/>
</Unit31>
<Unit32>
<Filename Value="pkglnet.pp"/>
<UnitName Value="pkglnet"/>
<CursorPos X="45" Y="16"/>
<TopLine Value="1"/>
<EditorIndex Value="12"/>
<UsageCount Value="11"/>
<Loaded Value="True"/>
</Unit32>
<Unit33>
<Filename Value="pkgoptions.pp"/>
<UnitName Value="pkgoptions"/>
<CursorPos X="1" Y="300"/>
<TopLine Value="286"/>
<EditorIndex Value="10"/>
<UsageCount Value="11"/>
<Loaded Value="True"/>
</Unit33>
<Unit34>
<Filename Value="pkgglobals.pp"/>
<UnitName Value="pkgglobals"/>
<CursorPos X="23" Y="81"/>
<TopLine Value="118"/>
<EditorIndex Value="11"/>
<UsageCount Value="11"/>
<Loaded Value="True"/>
</Unit34>
</Units>
<JumpHistory Count="30" HistoryIndex="29">
<Position1>
<Filename Value="zipper.pp"/>
<Caret Line="1347" Column="5" TopLine="1310"/>
<Filename Value="pkghandler.pp"/>
<Caret Line="10" Column="1" TopLine="1"/>
</Position1>
<Position2>
<Filename Value="zipper.pp"/>
<Caret Line="1" Column="1" TopLine="1"/>
<Filename Value="pkghandler.pp"/>
<Caret Line="59" Column="36" TopLine="45"/>
</Position2>
<Position3>
<Filename Value="zipper.pp"/>
<Caret Line="1095" Column="22" TopLine="1072"/>
<Filename Value="pkgmkconv.pp"/>
<Caret Line="131" Column="36" TopLine="97"/>
</Position3>
<Position4>
<Filename Value="zipper.pp"/>
<Caret Line="1308" Column="7" TopLine="1291"/>
<Filename Value="pkgmkconv.pp"/>
<Caret Line="584" Column="7" TopLine="569"/>
</Position4>
<Position5>
<Filename Value="pkgcommands.pp"/>
<Caret Line="69" Column="27" TopLine="40"/>
<Filename Value="pkgdownload.pp"/>
<Caret Line="1" Column="1" TopLine="1"/>
</Position5>
<Position6>
<Filename Value="pkgfpmake.pp"/>
<Caret Line="92" Column="36" TopLine="63"/>
<Filename Value="pkgarchive.pp"/>
<Caret Line="61" Column="32" TopLine="50"/>
</Position6>
<Position7>
<Filename Value="zipper.pp"/>
<Caret Line="41" Column="46" TopLine="13"/>
<Filename Value="pkgarchive.pp"/>
<Caret Line="67" Column="28" TopLine="54"/>
</Position7>
<Position8>
<Filename Value="zipper.pp"/>
<Caret Line="1297" Column="108" TopLine="1282"/>
<Filename Value="pkgfpmake.pp"/>
<Caret Line="89" Column="1" TopLine="59"/>
</Position8>
<Position9>
<Filename Value="zipper.pp"/>
<Caret Line="557" Column="20" TopLine="541"/>
<Filename Value="pkgcommands.pp"/>
<Caret Line="88" Column="21" TopLine="68"/>
</Position9>
<Position10>
<Filename Value="zipper.pp"/>
<Caret Line="542" Column="25" TopLine="535"/>
<Filename Value="pkgcommands.pp"/>
<Caret Line="45" Column="14" TopLine="39"/>
</Position10>
<Position11>
<Filename Value="zipper.pp"/>
<Caret Line="557" Column="30" TopLine="547"/>
<Filename Value="pkgcommands.pp"/>
<Caret Line="64" Column="1" TopLine="46"/>
</Position11>
<Position12>
<Filename Value="zipper.pp"/>
<Caret Line="268" Column="20" TopLine="249"/>
<Filename Value="pkgcommands.pp"/>
<Caret Line="46" Column="14" TopLine="41"/>
</Position12>
<Position13>
<Filename Value="zipper.pp"/>
<Caret Line="545" Column="21" TopLine="508"/>
<Filename Value="pkghandler.pp"/>
<Caret Line="185" Column="39" TopLine="172"/>
</Position13>
<Position14>
<Filename Value="zipper.pp"/>
<Caret Line="562" Column="21" TopLine="543"/>
<Filename Value="pkgcommands.pp"/>
<Caret Line="80" Column="50" TopLine="66"/>
</Position14>
<Position15>
<Filename Value="zipper.pp"/>
<Caret Line="567" Column="22" TopLine="549"/>
<Filename Value="pkgcommands.pp"/>
<Caret Line="87" Column="3" TopLine="66"/>
</Position15>
<Position16>
<Filename Value="zipper.pp"/>
<Caret Line="1" Column="1" TopLine="1"/>
<Filename Value="pkgcommands.pp"/>
<Caret Line="81" Column="35" TopLine="72"/>
</Position16>
<Position17>
<Filename Value="zipper.pp"/>
<Caret Line="519" Column="21" TopLine="500"/>
<Filename Value="pkgcommands.pp"/>
<Caret Line="83" Column="14" TopLine="69"/>
</Position17>
<Position18>
<Filename Value="zipper.pp"/>
<Caret Line="525" Column="22" TopLine="506"/>
<Filename Value="pkghandler.pp"/>
<Caret Line="73" Column="1" TopLine="73"/>
</Position18>
<Position19>
<Filename Value="zipper.pp"/>
<Caret Line="562" Column="21" TopLine="543"/>
<Filename Value="pkghandler.pp"/>
<Caret Line="197" Column="5" TopLine="164"/>
</Position19>
<Position20>
<Filename Value="zipper.pp"/>
<Caret Line="568" Column="19" TopLine="549"/>
<Filename Value="pkgwget.pp"/>
<Caret Line="1" Column="1" TopLine="1"/>
</Position20>
<Position21>
<Filename Value="zipper.pp"/>
<Caret Line="1347" Column="113" TopLine="1328"/>
<Filename Value="fppkg.pp"/>
<Caret Line="6" Column="38" TopLine="1"/>
</Position21>
<Position22>
<Filename Value="zipper.pp"/>
<Caret Line="1367" Column="1" TopLine="1349"/>
<Filename Value="fppkg.pp"/>
<Caret Line="14" Column="1" TopLine="7"/>
</Position22>
<Position23>
<Filename Value="zipper.pp"/>
<Caret Line="1" Column="1" TopLine="1"/>
<Filename Value="fppkg.pp"/>
<Caret Line="45" Column="1" TopLine="31"/>
</Position23>
<Position24>
<Filename Value="zipper.pp"/>
<Caret Line="263" Column="1" TopLine="244"/>
<Filename Value="fppkg.pp"/>
<Caret Line="312" Column="18" TopLine="298"/>
</Position24>
<Position25>
<Filename Value="zipper.pp"/>
<Caret Line="555" Column="30" TopLine="530"/>
<Filename Value="pkgoptions.pp"/>
<Caret Line="299" Column="14" TopLine="286"/>
</Position25>
<Position26>
<Filename Value="zipper.pp"/>
<Caret Line="1313" Column="19" TopLine="1302"/>
<Filename Value="fppkg.pp"/>
<Caret Line="313" Column="34" TopLine="298"/>
</Position26>
<Position27>
<Filename Value="zipper.pp"/>
<Caret Line="1322" Column="17" TopLine="1303"/>
<Filename Value="pkgoptions.pp"/>
<Caret Line="62" Column="97" TopLine="46"/>
</Position27>
<Position28>
<Filename Value="pkgcommands.pp"/>
<Caret Line="78" Column="65" TopLine="56"/>
<Filename Value="pkgoptions.pp"/>
<Caret Line="369" Column="24" TopLine="349"/>
</Position28>
<Position29>
<Filename Value="pkghandler.pp"/>
<Caret Line="253" Column="19" TopLine="231"/>
<Filename Value="pkgoptions.pp"/>
<Caret Line="308" Column="68" TopLine="286"/>
</Position29>
<Position30>
<Filename Value="pkghandler.pp"/>
<Caret Line="97" Column="13" TopLine="77"/>
<Filename Value="pkgoptions.pp"/>
<Caret Line="301" Column="43" TopLine="286"/>
</Position30>
</JumpHistory>
</ProjectOptions>
<CompilerOptions>
<Version Value="5"/>
<PathDelim Value="\"/>
<SearchPaths>
<OtherUnitFiles Value="fcl20\"/>
<OtherUnitFiles Value="fcl20/"/>
</SearchPaths>
<CodeGeneration>
<Checks>

View File

@ -9,9 +9,10 @@ uses
{$endif}
Classes, SysUtils, TypInfo, custapp,
// Repository handler objects
fprepos, fpxmlrep,fpmktype, pkgmessages, pkgropts,
fprepos, fpxmlrep,
pkgmessages, pkgglobals, pkgoptions,
// Package Handler components
pkghandler, pkgmkconv, pkgdownload,
pkghandler,pkgmkconv, pkgdownload,
pkgarchive, pkgfpmake, pkgcommands
// Downloaders
{$if defined(unix) or defined(windows)}
@ -24,9 +25,9 @@ Type
TMakeTool = Class(TCustomApplication)
Private
ActionStack : TActionStack;
ParaAction : string;
ParaPackages : TStringList;
FDefaults: TPackagerOptions;
FRepository : TFPRepository;
FCompilerConfig : String;
procedure GenerateParaActions;
@ -41,7 +42,6 @@ Type
Procedure LoadCompilerDefaults;
Procedure ProcessCommandLine;
Procedure DoRun; Override;
procedure ExecuteAction(APackage:TFPPackage; const AAction:string; const Args:TActionArgs);
end;
EMakeToolError = Class(Exception);
@ -76,23 +76,22 @@ var
begin
cfgfile:=GetConfigFileName;
GeneratedConfig:=false;
FDefaults:=TPackagerOptions.Create;
// Load file or create new default configuration
if FileExists(cfgfile) then
FDefaults.LoadGlobalFromFile(cfgfile)
Defaults.LoadGlobalFromFile(cfgfile)
else
begin
ForceDirectories(ExtractFilePath(cfgfile));
FDefaults.SaveGlobalToFile(cfgfile);
Defaults.SaveGlobalToFile(cfgfile);
GeneratedConfig:=true;
end;
// Load default verbosity from config
SL:=TStringList.Create;
SL.CommaText:=FDefaults.DefaultVerbosity;
SL.CommaText:=Defaults.DefaultVerbosity;
for i:=0 to SL.Count-1 do
Include(Verbosity,StringToVerbosity(SL[i]));
SL.Free;
FCompilerConfig:=FDefaults.DefaultCompilerConfig;
FCompilerConfig:=Defaults.DefaultCompilerConfig;
// Tracing of what we've done above, need to be done after the verbosity is set
if GeneratedConfig then
Log(vDebug,SLogGeneratingGlobalConfig,[cfgfile])
@ -103,9 +102,9 @@ end;
procedure TMakeTool.MaybeCreateLocalDirs;
begin
ForceDirectories(FDefaults.BuildDir);
ForceDirectories(FDefaults.PackagesDir);
ForceDirectories(FDefaults.CompilerConfigDir);
ForceDirectories(Defaults.BuildDir);
ForceDirectories(Defaults.PackagesDir);
ForceDirectories(Defaults.CompilerConfigDir);
end;
@ -113,17 +112,17 @@ procedure TMakeTool.LoadCompilerDefaults;
var
S : String;
begin
S:=FDefaults.CompilerConfigDir+FCompilerConfig;
S:=Defaults.CompilerConfigDir+FCompilerConfig;
if FileExists(S) then
begin
Log(vDebug,SLogLoadingCompilerConfig,[S]);
FDefaults.LoadCompilerFromFile(S)
Defaults.LoadCompilerFromFile(S)
end
else
begin
Log(vDebug,SLogGeneratingCompilerConfig,[S]);
FDefaults.InitCompilerDefaults;
FDefaults.SaveCompilerToFile(S);
Defaults.InitCompilerDefaults;
Defaults.SaveCompilerToFile(S);
end;
end;
@ -135,19 +134,19 @@ var
begin
FRepository:=TFPRepository.Create(Nil);
// Repository
Log(vDebug,SLogLoadingRepository,[FDefaults.LocalRepository]);
if FileExists(FDefaults.LocalRepository) then
Log(vDebug,SLogLoadingRepository,[Defaults.LocalRepository]);
if FileExists(Defaults.LocalRepository) then
begin
X:=TFPXMLRepositoryHandler.Create;
With X do
try
LoadFromXml(FRepository,FDefaults.LocalRepository);
LoadFromXml(FRepository,Defaults.LocalRepository);
finally
Free;
end;
end;
// Versions
S:=FDefaults.LocalVersions(FCompilerConfig);
S:=Defaults.LocalVersions(FCompilerConfig);
Log(vDebug,SLogLoadingVersions,[S]);
if FileExists(S) then
FRepository.LoadStatusFromFile(S);
@ -175,11 +174,13 @@ Constructor TMakeTool.Create;
begin
inherited Create(nil);
ParaPackages:=TStringList.Create;
ActionStack:=TActionStack.Create;
end;
Destructor TMakeTool.Destroy;
begin
FreeAndNil(ActionStack);
FreeAndNil(ParaPackages);
inherited Destroy;
end;
@ -289,31 +290,6 @@ begin
end;
procedure TMakeTool.ExecuteAction(APackage:TFPPackage;const AAction:string;const Args:TActionArgs);
var
pkghandlerclass : TPackageHandlerClass;
i : integer;
logargs : string;
begin
pkghandlerclass:=GetPkgHandler(AAction);
With pkghandlerclass.Create(Self,FDefaults,APackage) do
try
logargs:='';
for i:=Low(Args) to High(Args) do
begin
if logargs='' then
logargs:=Args[i]
else
logargs:=logargs+','+Args[i];
end;
Log(vDebug,PackageLogPrefix+SLogRunAction,[AAction,logargs]);
Execute(Args);
finally
Free;
end;
end;
procedure TMakeTool.DoRun;
var
Action : string;
@ -333,7 +309,7 @@ begin
repeat
if not ActionStack.Pop(ActionPackage,Action,Args) then
break;
ExecuteAction(ActionPackage,Action,Args);
pkghandler.ExecuteAction(ActionPackage,Action,Args);
until false;
Terminate;

View File

@ -24,6 +24,7 @@ implementation
uses
zipper,
uriparser,
pkgglobals,
pkgmessages;
Procedure DeleteDir(const ADir:string);

View File

@ -42,6 +42,8 @@ implementation
uses
pkgmessages,
pkgglobals,
pkgoptions,
fpmktype,
fprepos,
fpxmlrep;
@ -75,28 +77,31 @@ end;
function TCommandDownload.Execute(const Args:TActionArgs):boolean;
begin
ActionStack.Push(CurrentPackage,'downloadpackage',Args);
if not assigned(CurrentPackage) then
Error(SErrNoPackageSpecified);
if not FileExists(PackageArchive) then
ExecuteAction(CurrentPackage,'downloadpackage',Args);
end;
function TCommandBuild.Execute(const Args:TActionArgs):boolean;
begin
ActionStack.Push(CurrentPackage,'fpmakebuild',Args);
ActionStack.Push(CurrentPackage,'compilefpmake',Args);
if assigned(CurrentPackage) then
begin
if not DirectoryExists(PackageBuildPath) then
ActionStack.Push(CurrentPackage,'unziparchive',Args);
if not FileExists(PackageArchive) then
ActionStack.Push(CurrentPackage,'downloadpackage',Args);
ExecuteAction(CurrentPackage,'downloadpackage',Args);
if not DirectoryExists(PackageBuildPath) then
ExecuteAction(CurrentPackage,'unziparchive',Args);
end;
ExecuteAction(CurrentPackage,'fpmakebuild',Args);
ExecuteAction(CurrentPackage,'compilefpmake',Args);
end;
function TCommandInstall.Execute(const Args:TActionArgs):boolean;
begin
ActionStack.Push(CurrentPackage,'fpmakeinstall',Args);
ActionStack.Push(CurrentPackage,'build',Args);
ExecuteAction(CurrentPackage,'build',Args);
ExecuteAction(CurrentPackage,'fpmakeinstall',Args);
end;

View File

@ -39,7 +39,10 @@ Var
implementation
uses pkgmessages,uriparser;
uses
uriparser,
pkgglobals,
pkgmessages;
{ TBaseDownloader }

View File

@ -45,6 +45,8 @@ type
implementation
uses
pkgoptions,
pkgglobals,
pkgmessages;
{ TFPMakeCompiler }

145
utils/fppkg/pkgglobals.pp Normal file
View File

@ -0,0 +1,145 @@
{$mode objfpc}
{$h+}
unit pkgglobals;
interface
uses
SysUtils,
Classes;
Const
{$ifdef unix}
ExeExt = '';
{$else unix}
ExeExt = '.exe';
{$endif unix}
Type
TVerbosity = (vError,vInfo,vCommands,vDebug);
TVerbosities = Set of TVerbosity;
EPackagerError = class(Exception);
// Logging
Function StringToVerbosity (S : String) : TVerbosity;
Function VerbosityToString (V : TVerbosity): String;
Procedure Log(Level: TVerbosity;Msg : String);
Procedure Log(Level: TVerbosity;Fmt : String; const Args : array of const);
Procedure Error(Msg : String);
Procedure Error(Fmt : String; const Args : array of const);
// Utils
function maybequoted(const s:string):string;
Function FixPath(const S : String) : string;
var
Verbosity : TVerbosities;
Implementation
uses
typinfo,
contnrs,
uriparser,
pkgmessages;
function StringToVerbosity(S: String): TVerbosity;
Var
I : integer;
begin
I:=GetEnumValue(TypeInfo(TVerbosity),'v'+S);
If (I<>-1) then
Result:=TVerbosity(I)
else
Raise EPackagerError.CreateFmt(SErrInvalidVerbosity,[S]);
end;
Function VerbosityToString (V : TVerbosity): String;
begin
Result:=GetEnumName(TypeInfo(TVerbosity),Integer(V));
Delete(Result,1,1);// Delete 'v'
end;
procedure Log(Level:TVerbosity;Msg: String);
begin
if Level in Verbosity then
Writeln(stdErr,Msg);
end;
Procedure Log(Level:TVerbosity; Fmt:String; const Args:array of const);
begin
Log(Level,Format(Fmt,Args));
end;
procedure Error(Msg: String);
begin
Raise EPackagerError.Create(Msg);
end;
procedure Error(Fmt: String; const Args: array of const);
begin
Raise EPackagerError.CreateFmt(Fmt,Args);
end;
function maybequoted(const s:string):string;
const
{$IFDEF MSWINDOWS}
FORBIDDEN_CHARS = ['!', '@', '#', '$', '%', '^', '&', '*', '(', ')',
'{', '}', '''', '`', '~'];
{$ELSE}
FORBIDDEN_CHARS = ['!', '@', '#', '$', '%', '^', '&', '*', '(', ')',
'{', '}', '''', ':', '\', '`', '~'];
{$ENDIF}
var
s1 : string;
i : integer;
quoted : boolean;
begin
quoted:=false;
s1:='"';
for i:=1 to length(s) do
begin
case s[i] of
'"' :
begin
quoted:=true;
s1:=s1+'\"';
end;
' ',
#128..#255 :
begin
quoted:=true;
s1:=s1+s[i];
end;
else begin
if s[i] in FORBIDDEN_CHARS then
quoted:=True;
s1:=s1+s[i];
end;
end;
end;
if quoted then
maybequoted:=s1+'"'
else
maybequoted:=s;
end;
Function FixPath(const S : String) : string;
begin
If (S<>'') then
Result:=IncludeTrailingPathDelimiter(S)
else
Result:='';
end;
end.

View File

@ -4,19 +4,13 @@ unit pkghandler;
interface
uses Classes,SysUtils, fpmktype, pkgropts, fprepos;
Const
{$ifdef unix}
ExeExt = '';
{$else unix}
ExeExt = '.exe';
{$endif unix}
Type
TVerbosity = (vError,vInfo,vCommands,vDebug);
TVerbosities = Set of TVerbosity;
uses
Classes,SysUtils,
pkgglobals,
pkgoptions,
fprepos;
type
{ TActionStack }
TActionArgs = array of string;
@ -33,7 +27,7 @@ Type
FList : TFPList;
public
constructor Create;
destructor Destroy;
destructor Destroy;override;
procedure Push(APackage:TFPPackage;const AAction:string;const Args:TActionArgs);
procedure Push(APackage:TFPPackage;const AAction:string;const Args:array of string);
function Pop(out APackage:TFPPackage;out AAction:string;out Args:TActionArgs):boolean;
@ -44,46 +38,31 @@ Type
TPackageHandler = Class(TComponent)
private
FDefaults : TPackagerOptions;
FCurrentPackage : TFPPackage;
Protected
Procedure Log(Level: TVerbosity;Msg : String);
Procedure Log(Level: TVerbosity;Fmt : String; const Args : array of const);
Procedure Error(Msg : String);
Procedure Error(Fmt : String; const Args : array of const);
procedure ExecuteAction(APackage:TFPPackage;const AAction:string;const Args:TActionArgs);
Function ExecuteProcess(Const Prog,Args:String):Integer;
Procedure SetCurrentDir(Const ADir:String);
function PackageBuildPath:String;
function PackageArchive:String;
Public
Constructor Create(AOwner: TComponent;ADefaults:TPackagerOptions;APackage:TFPPackage); virtual;
Constructor Create(AOwner:TComponent;APackage:TFPPackage); virtual;
function PackageLogPrefix:String;
Function Execute(const Args:TActionArgs):boolean; virtual; abstract;
Property Defaults:TPackagerOptions Read FDefaults;
Property CurrentPackage:TFPPackage Read FCurrentPackage Write FCurrentPackage;
end;
TPackageHandlerClass = class of TPackageHandler;
EPackageHandler = Class(EInstallerError);
EPackageHandler = Class(Exception);
// Actions/PkgHandler
procedure RegisterPkgHandler(const AAction:string;pkghandlerclass:TPackageHandlerClass);
function GetPkgHandler(const AAction:string):TPackageHandlerClass;
// Logging
Function StringToVerbosity (S : String) : TVerbosity;
Function VerbosityToString (V : TVerbosity): String;
Procedure Log(Level: TVerbosity;Msg : String);
Procedure Log(Level: TVerbosity;Fmt : String; const Args : array of const);
Procedure Error(Msg : String);
Procedure Error(Fmt : String; const Args : array of const);
// Utils
function maybequoted(const s:ansistring):ansistring;
var
Verbosity : TVerbosities;
ActionStack : TActionStack;
procedure ExecuteAction(APackage:TFPPackage;const AAction:string;const Args:TActionArgs);
Implementation
@ -116,99 +95,36 @@ begin
end;
function StringToVerbosity(S: String): TVerbosity;
Var
I : integer;
begin
I:=GetEnumValue(TypeInfo(TVerbosity),'v'+S);
If (I<>-1) then
Result:=TVerbosity(I)
else
Raise EPackageHandler.CreateFmt(SErrInvalidVerbosity,[S]);
end;
Function VerbosityToString (V : TVerbosity): String;
begin
Result:=GetEnumName(TypeInfo(TVerbosity),Integer(V));
Delete(Result,1,1);// Delete 'v'
end;
procedure Log(Level:TVerbosity;Msg: String);
begin
if Level in Verbosity then
Writeln(stdErr,Msg);
end;
Procedure Log(Level:TVerbosity; Fmt:String; const Args:array of const);
begin
Log(Level,Format(Fmt,Args));
end;
procedure Error(Msg: String);
begin
Raise EPackageHandler.Create(Msg);
end;
procedure Error(Fmt: String; const Args: array of const);
begin
Raise EPackageHandler.CreateFmt(Fmt,Args);
end;
function maybequoted(const s:ansistring):ansistring;
const
{$IFDEF MSWINDOWS}
FORBIDDEN_CHARS = ['!', '@', '#', '$', '%', '^', '&', '*', '(', ')',
'{', '}', '''', '`', '~'];
{$ELSE}
FORBIDDEN_CHARS = ['!', '@', '#', '$', '%', '^', '&', '*', '(', ')',
'{', '}', '''', ':', '\', '`', '~'];
{$ENDIF}
procedure ExecuteAction(APackage:TFPPackage;const AAction:string;const Args:TActionArgs);
var
s1 : ansistring;
i : integer;
quoted : boolean;
pkghandlerclass : TPackageHandlerClass;
i : integer;
logargs : string;
begin
quoted:=false;
s1:='"';
for i:=1 to length(s) do
begin
case s[i] of
'"' :
begin
quoted:=true;
s1:=s1+'\"';
end;
' ',
#128..#255 :
begin
quoted:=true;
s1:=s1+s[i];
end;
else begin
if s[i] in FORBIDDEN_CHARS then
quoted:=True;
s1:=s1+s[i];
end;
end;
end;
if quoted then
maybequoted:=s1+'"'
else
maybequoted:=s;
pkghandlerclass:=GetPkgHandler(AAction);
With pkghandlerclass.Create(nil,APackage) do
try
logargs:='';
for i:=Low(Args) to High(Args) do
begin
if logargs='' then
logargs:=Args[i]
else
logargs:=logargs+','+Args[i];
end;
Log(vDebug,PackageLogPrefix+SLogRunAction,[AAction,logargs]);
Execute(Args);
finally
Free;
end;
end;
{ TPackageHandler }
constructor TPackageHandler.Create(AOwner : TComponent; ADefaults:TPackagerOptions;APackage:TFPPackage);
constructor TPackageHandler.Create(AOwner:TComponent;APackage:TFPPackage);
begin
inherited Create(AOwner);
FDefaults:=ADefaults;
FCurrentPackage:=APackage;
end;
@ -256,22 +172,31 @@ end;
Procedure TPackageHandler.Log(Level:TVerbosity; Msg:String);
begin
pkghandler.Log(Level,PackageLogPrefix+Msg);
pkgglobals.Log(Level,PackageLogPrefix+Msg);
end;
Procedure TPackageHandler.Log(Level:TVerbosity; Fmt:String; const Args:array of const);
begin
pkghandler.Log(Level,PackageLogPrefix+Fmt,Args);
pkgglobals.Log(Level,PackageLogPrefix+Fmt,Args);
end;
Procedure TPackageHandler.Error(Msg:String);
begin
pkghandler.Error(PackageLogPrefix+Msg);
pkgglobals.Error(PackageLogPrefix+Msg);
end;
Procedure TPackageHandler.Error(Fmt:String; const Args:array of const);
begin
pkghandler.Error(PackageLogPrefix+Fmt,Args);
pkgglobals.Error(PackageLogPrefix+Fmt,Args);
end;
procedure TPackageHandler.ExecuteAction(APackage: TFPPackage; const AAction: string; const Args: TActionArgs);
begin
pkghandler.ExecuteAction(APackage,AAction,Args);
end;
@ -334,12 +259,8 @@ begin
end;
initialization
PkgHandlerList:=TFPHashList.Create;
ActionStack:=TActionStack.Create;
finalization
FreeAndNil(PkgHandlerList);
FreeAndNil(ActionStack);
end.

View File

@ -4,7 +4,7 @@ unit pkglibcurl;
interface
uses Classes,pkgdownload,pkghandler;
uses Classes,pkgdownload;
Type
TLibCurlDownloader = Class(TBaseDownloader)
@ -16,7 +16,7 @@ Type
implementation
uses sysutils,uriparser,libcurl,pkgmessages,unixtype;
uses sysutils,uriparser,libcurl,pkgmessages,pkgglobals,unixtype;
Function DoStreamWrite(Ptr : Pointer; Size : size_t; nmemb: size_t; Data : Pointer) : size_t;cdecl;

View File

@ -6,7 +6,7 @@ interface
uses
SysUtils, Classes,
lnet, lftp, lhttp, pkgdownload,pkgropts, fprepos;
lnet, lftp, lhttp, pkgdownload,pkgoptions, fprepos;
Type
@ -39,7 +39,9 @@ Type
implementation
uses
pkghandler,pkgmessages, uriparser;
uriparser,
pkgglobals,
pkgmessages;
{ TLNetDownloader }

View File

@ -11,6 +11,7 @@ Resourcestring
SErrMissingFPC = 'Could not find a fpc executable in the PATH';
SErrMissingFPMake = 'Missing configuration fpmake.pp';
SErrMissingMakefilefpc = 'Missing configuration Makefile.fpc';
SErrNoPackageSpecified = 'No package specified';
SErrRunning = 'The FPC make tool encountered the following error:';
SErrActionAlreadyRegistered= 'Action "%s" is already registered';
SErrActionNotFound = 'Action "%s" is not supported';

View File

@ -48,7 +48,10 @@ Type
implementation
uses typinfo,pkgmessages;
uses
TypInfo,
pkgglobals,
pkgmessages;
Function GetWord(var S : String; Sep : Char) : String;

View File

@ -12,7 +12,7 @@
**********************************************************************}
{$mode objfpc}
{$h+}
unit pkgropts;
unit pkgoptions;
interface
@ -77,6 +77,18 @@ Type
Property CompilerCPU : TCPU Read FCompilerCPU Write SetCompilerCPU;
end;
var
Defaults : TPackagerOptions;
Implementation
uses
{$ifdef unix}
baseunix,
{$endif}
pkgglobals,
pkgmessages;
Const
DefaultMirrorsLocation = 'http://www.freepascal.org/repository/mirrors.xml';
DefaultRemoteRepository = 'fpc';
@ -105,25 +117,6 @@ Const
KeyCompilerVersion = 'Version';
Implementation
uses
{$ifdef unix}
baseunix,
{$endif}
pkghandler,
pkgmessages;
Function FixPath(S : String) : string;
begin
If (S<>'') then
Result:=IncludeTrailingPathDelimiter(S)
else
Result:='';
end;
{ TPackagerOptions }
constructor TPackagerOptions.Create;
@ -236,7 +229,7 @@ Procedure TPackagerOptions.InitCompilerDefaults;
begin
FCompiler:=FileSearch('fpc'+ExeExt,GetEnvironmentVariable('PATH'));
if FCompiler='' then
Raise EPackageHandler.Create(SErrMissingFPC);
Raise EPackagerError.Create(SErrMissingFPC);
{$warning TODO detect compiler version/target from -i options }
FCompilerVersion:='2.0.4';
FCompilerCPU:=StringToCPU({$I %FPCTARGETCPU%});
@ -377,4 +370,8 @@ begin
end;
end;
initialization
Defaults:=TPackagerOptions.Create;
finalization
FreeAndNil(Defaults);
end.

View File

@ -4,7 +4,7 @@ unit pkgwget;
interface
uses Classes,pkgdownload,pkgropts,fprepos;
uses Classes,pkgdownload,pkgoptions,fprepos;
Type
TWGetDownloader = Class(TBaseDownloader)
@ -21,7 +21,10 @@ Type
implementation
uses process,pkghandler,pkgmessages;
uses
process,
pkgglobals,
pkgmessages;
Constructor TWGetDownloader.Create(AOwner: TComponent);