* Added the option (-ie) to install the example-sources

git-svn-id: trunk@18109 -
This commit is contained in:
joost 2011-08-06 12:17:57 +00:00
parent a09a7f1b2e
commit 911a220a13

View File

@ -598,7 +598,7 @@ Type
Function GetBinOutputDir(ACPU:TCPU; AOS : TOS) : String;
Procedure GetCleanFiles(List : TStrings; ACPU:TCPU; AOS : TOS); virtual;
procedure GetInstallFiles(List: TStrings;Types : TTargetTypes;ACPU:TCPU; AOS : TOS); virtual;
procedure GetInstallSourceFiles(List: TStrings;Types : TSourceTypes); virtual;
procedure GetInstallSourceFiles(List: TStrings; SourceTypes : TSourceTypes; TargetTypes : TTargetTypes); virtual;
Procedure GetArchiveFiles(List : TStrings; ACPU:TCPU; AOS : TOS); virtual;
Procedure GetArchiveSourceFiles(List : TStrings); virtual;
Procedure GetManifest(Manifest : TStrings);
@ -680,6 +680,7 @@ Type
FCopy: String;
FFPDocOutputDir: String;
FIgnoreInvalidOptions: Boolean;
FInstallExamples: Boolean;
FMkDir: String;
FMove: String;
FOptions: TStrings;
@ -761,6 +762,8 @@ Type
Property Archive : String Read FArchive Write FArchive; // zip $(ARCHIVE) $(FILESORDIRS)
// Misc
Property IgnoreInvalidOptions: Boolean read FIgnoreInvalidOptions write FIgnoreInvalidOptions;
// Installation optioms
Property InstallExamples: Boolean read FInstallExamples write FInstallExamples;
end;
{ TBasicDefaults }
@ -821,7 +824,7 @@ Type
Function GetCompiler : String;
Function InstallPackageFiles(APAckage : TPackage; tt : TTargetType; Const Dest : String):Boolean;
Procedure InstallUnitConfigFile(APAckage : TPackage; Const Dest : String);
Function InstallPackageSourceFiles(APAckage : TPackage; tt : TSourceType; Const Dest : String):Boolean;
Function InstallPackageSourceFiles(APAckage : TPackage; stt : TSourceTypes; ttt : TTargetTypes; Const Dest : String):Boolean;
Function FileNewer(const Src,Dest : String) : Boolean;
Procedure LogSearchPath(const ASearchPathName:string;Path:TConditionalStrings; ACPU:TCPU;AOS:TOS);
Function FindFileInPath(Path:TConditionalStrings; AFileName:String; var FoundPath:String;ACPU:TCPU;AOS:TOS):Boolean;
@ -1167,6 +1170,7 @@ ResourceString
SHelpConfig = 'Use indicated config file when compiling.';
SHelpOptions = 'Pass extra options to the compiler.';
SHelpVerbose = 'Be verbose when working.';
SHelpInstExamples = 'Install the example-sources.';
SHelpIgnoreInvOpt = 'Ignore further invalid options.';
sHelpFpdocOutputDir = 'Use indicated directory as fpdoc output folder.';
@ -1195,6 +1199,7 @@ Const
KeyBinInstallDir = 'BinInstallDir';
KeyDocInstallDir = 'DocInstallDir';
KeyExamplesInstallDir = 'ExamplesInstallDir';
KeyInstallExamples = 'InstallExamples';
// Keys for unit config
KeyName = 'Name';
KeyVersion = 'Version';
@ -2381,17 +2386,24 @@ begin
end;
procedure TPackage.GetInstallSourceFiles(List: TStrings; Types: TSourceTypes);
procedure TPackage.GetInstallSourceFiles(List: TStrings; SourceTypes : TSourceTypes; TargetTypes : TTargetTypes);
Var
I : Integer;
S : TSource;
T : TTarget;
begin
For I:=0 to FSources.Count-1 do
begin
S:=FSources.SourceItems[I];
if (S.SourceType in Types) then
if (S.SourceType in SourceTypes) then
S.GetInstallFiles(List);
end;
For I:=0 to FTargets.Count-1 do
begin
T:=FTargets.TargetItems[I];
if (T.TargetType in TargetTypes) then
T.GetArchiveFiles(List,Defaults.CPU,Defaults.OS);
end;
end;
@ -3042,6 +3054,8 @@ begin
Values[KeyTarget]:=FTarget;
if FNoFPCCfg then
Values[KeyNoFPCCfg]:='Y';
if FInstallExamples then
Values[KeyInstallExamples]:='Y';
end;
L.SaveToStream(S);
Finally
@ -3099,6 +3113,7 @@ begin
FBinInstallDir:=Values[KeyBinInstallDir];
FDocInstallDir:=Values[KeyDocInstallDir];
FExamplesInstallDir:=Values[KeyExamplesInstallDir];
FInstallExamples:=(Upcase(Values[KeyInstallExamples])='Y');
FNoFPCCfg:=(Upcase(Values[KeyNoFPCCfg])='Y');
end;
Finally
@ -3361,6 +3376,8 @@ begin
Defaults.Compiler:=OptionArg(I)
else if CheckOption(I,'f','config') then
DefaultsFileName:=OptionArg(I)
else if CheckOption(I,'ie','installexamples') then
Defaults.InstallExamples:=true
else if CheckOption(I,'io','ignoreinvalidoption') then
Defaults.IgnoreInvalidOptions:=true
else if CheckOption(I,'d','doc-folder') then
@ -3419,6 +3436,7 @@ begin
LogOption('l','list-commands',SHelpList);
LogOption('n','nofpccfg',SHelpNoFPCCfg);
LogOption('v','verbose',SHelpVerbose);
LogOption('ie','installexamples',SHelpInstExamples);
LogArgOption('C','cpu',SHelpCPU);
LogArgOption('O','os',SHelpOS);
LogArgOption('t','target',SHelpTarget);
@ -4903,14 +4921,14 @@ begin
end;
end;
function TBuildEngine.InstallPackageSourceFiles(APAckage: TPackage; tt: TSourceType; const Dest: String): Boolean;
function TBuildEngine.InstallPackageSourceFiles(APAckage : TPackage; stt : TSourceTypes; ttt : TTargetTypes; Const Dest : String): Boolean;
Var
List : TStringList;
begin
Result:=False;
List:=TStringList.Create;
Try
APackage.GetInstallSourceFiles(List,[tt]);
APackage.GetInstallSourceFiles(List,stt,ttt);
if (List.Count>0) then
begin
Result:=True;
@ -4973,10 +4991,13 @@ begin
//InstallPackageFiles(APAckage,ttExampleProgram,D);
// Documentation
D:=IncludeTrailingPathDelimiter(Defaults.DocInstallDir)+'fpc-'+APackage.FileName+PathDelim;
InstallPackageSourceFiles(APackage,stDoc,D);
InstallPackageSourceFiles(APackage,[stDoc],[],D);
// Examples
D:=IncludeTrailingPathDelimiter(Defaults.ExamplesInstallDir)+'fpc-'+APackage.FileName+PathDelim;
InstallPackageSourceFiles(APackage,stExample,D);
if Defaults.InstallExamples then
begin
D:=IncludeTrailingPathDelimiter(Defaults.ExamplesInstallDir)+'fpc-'+APackage.FileName+PathDelim+'examples'+PathDelim;
InstallPackageSourceFiles(APackage,[stExample],[ttExampleProgram,ttExampleUnit],D);
end;
// Done.
APackage.FTargetState:=tsInstalled;
DoAfterInstall(APackage);