mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-18 05:29:21 +02:00
* Added ability to use include-files in configuration-files
git-svn-id: trunk@34717 -
This commit is contained in:
parent
df8687c259
commit
41c9543ddf
@ -114,6 +114,11 @@ Resourcestring
|
|||||||
SLogRepositoryPath = ' Dir: "%s" -> "%s"';
|
SLogRepositoryPath = ' Dir: "%s" -> "%s"';
|
||||||
SLogRepositoryPrefix = ' Prefix: "%s" -> "%s"';
|
SLogRepositoryPrefix = ' Prefix: "%s" -> "%s"';
|
||||||
|
|
||||||
|
SLogIncludeFile = ' IncludeFile: "%s" -> "\%s"';
|
||||||
|
SLogIncludeFileMask = ' IncludeFileMask: "%s" -> "\%s"';
|
||||||
|
SLogIncludeFileDoesNotExist = 'The log-file "%s" does not exist';
|
||||||
|
SLogIncludeFileMaskDoesNotExist = 'The directory "%s" of the include-mask "%s" does not exist';
|
||||||
|
|
||||||
SLogPackageInfoName = 'Package: %s';
|
SLogPackageInfoName = 'Package: %s';
|
||||||
SLogPackageInfoVersion = 'Version: %s';
|
SLogPackageInfoVersion = 'Version: %s';
|
||||||
SLogPackageInfoAuthor = 'Author: %s %s';
|
SLogPackageInfoAuthor = 'Author: %s %s';
|
||||||
|
@ -32,6 +32,7 @@ Type
|
|||||||
{ TFppkgOptionSection }
|
{ TFppkgOptionSection }
|
||||||
|
|
||||||
TCompilerOptions = class;
|
TCompilerOptions = class;
|
||||||
|
TFppkgOptions = class;
|
||||||
TFppkgOptionSection = class(TPersistent)
|
TFppkgOptionSection = class(TPersistent)
|
||||||
private
|
private
|
||||||
FOptionParser: TTemplateParser;
|
FOptionParser: TTemplateParser;
|
||||||
@ -137,6 +138,25 @@ Type
|
|||||||
property Prefix: string read GetPrefix write SetPrefix;
|
property Prefix: string read GetPrefix write SetPrefix;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ TFppkgIncludeFilesOptionSection }
|
||||||
|
|
||||||
|
TFppkgIncludeFilesOptionSection = class(TFppkgOptionSection)
|
||||||
|
private
|
||||||
|
FOptions: TFppkgOptions;
|
||||||
|
// Only used for logging
|
||||||
|
FOptionCache: TStringList;
|
||||||
|
FCurrentDir: String;
|
||||||
|
|
||||||
|
procedure IncludeFile(AFileName: string);
|
||||||
|
procedure IncludeFileMask(AFileNameMask: string);
|
||||||
|
public
|
||||||
|
constructor Create(AnOptionParser: TTemplateParser; AnOptions: TFppkgOptions; ACurrentDir: string);
|
||||||
|
destructor Destroy; override;
|
||||||
|
procedure AddKeyValue(const AKey, AValue: string); override;
|
||||||
|
procedure LogValues(ALogLevel: TLogLevel); override;
|
||||||
|
function AllowDuplicate: Boolean; override;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TFppkgCommandLineOptionSection }
|
{ TFppkgCommandLineOptionSection }
|
||||||
|
|
||||||
TFppkgCommandLineOptionSection = class(TFppkgOptionSection)
|
TFppkgCommandLineOptionSection = class(TFppkgOptionSection)
|
||||||
@ -260,6 +280,7 @@ Const
|
|||||||
KeyGlobalSection = 'Global';
|
KeyGlobalSection = 'Global';
|
||||||
KeyRepositorySection = 'Repository';
|
KeyRepositorySection = 'Repository';
|
||||||
KeySrcRepositorySection = 'UninstalledSourceRepository';
|
KeySrcRepositorySection = 'UninstalledSourceRepository';
|
||||||
|
KeyIncludeFilesSection = 'IncludeFiles';
|
||||||
KeyRemoteMirrorsURL = 'RemoteMirrors';
|
KeyRemoteMirrorsURL = 'RemoteMirrors';
|
||||||
KeyRemoteRepository = 'RemoteRepository';
|
KeyRemoteRepository = 'RemoteRepository';
|
||||||
KeyLocalRepository = 'LocalRepository';
|
KeyLocalRepository = 'LocalRepository';
|
||||||
@ -277,6 +298,9 @@ Const
|
|||||||
KeyRepositoryPath = 'Path';
|
KeyRepositoryPath = 'Path';
|
||||||
KeyRepositoryPrefix = 'Prefix';
|
KeyRepositoryPrefix = 'Prefix';
|
||||||
|
|
||||||
|
KeyIncludeFile = 'File';
|
||||||
|
KeyIncludeFileMask = 'FileMask';
|
||||||
|
|
||||||
// Compiler dependent config
|
// Compiler dependent config
|
||||||
KeyGlobalPrefix = 'GlobalPrefix';
|
KeyGlobalPrefix = 'GlobalPrefix';
|
||||||
KeyLocalPrefix = 'LocalPrefix';
|
KeyLocalPrefix = 'LocalPrefix';
|
||||||
@ -287,6 +311,91 @@ Const
|
|||||||
KeyCompilerCPU = 'CPU';
|
KeyCompilerCPU = 'CPU';
|
||||||
KeyCompilerVersion = 'Version';
|
KeyCompilerVersion = 'Version';
|
||||||
|
|
||||||
|
{ TFppkgIncludeFilesOptionSection }
|
||||||
|
|
||||||
|
procedure TFppkgIncludeFilesOptionSection.IncludeFile(AFileName: string);
|
||||||
|
begin
|
||||||
|
AFileName := FOptionParser.ParseString(AFileName);
|
||||||
|
if FileExists(AFileName) then
|
||||||
|
begin
|
||||||
|
FOptions.LoadFromFile(AFileName);
|
||||||
|
end
|
||||||
|
else
|
||||||
|
log(llWarning, SLogIncludeFileDoesNotExist, [AFileName]);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TFppkgIncludeFilesOptionSection.IncludeFileMask(AFileNameMask: string);
|
||||||
|
var
|
||||||
|
FileDir: string;
|
||||||
|
SR: TSearchRec;
|
||||||
|
begin
|
||||||
|
AFileNameMask := FOptionParser.ParseString(AFileNameMask);
|
||||||
|
FileDir := IncludeTrailingPathDelimiter(ExtractFileDir(AFileNameMask));
|
||||||
|
|
||||||
|
if IsRelativePath(AFileNameMask) then
|
||||||
|
FileDir := ConcatPaths([FCurrentDir, FileDir]);
|
||||||
|
|
||||||
|
if DirectoryExists(FileDir) then
|
||||||
|
begin
|
||||||
|
if IsRelativePath(AFileNameMask) then
|
||||||
|
AFileNameMask := ConcatPaths([FCurrentDir, AFileNameMask]);
|
||||||
|
|
||||||
|
if FindFirst(AFileNameMask, faAnyFile-faDirectory, SR)=0 then
|
||||||
|
begin
|
||||||
|
repeat
|
||||||
|
IncludeFile(FileDir+SR.Name);
|
||||||
|
until FindNext(SR)<>0;
|
||||||
|
end;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
log(llWarning, SLogIncludeFileMaskDoesNotExist, [FileDir, AFileNameMask]);
|
||||||
|
end;
|
||||||
|
|
||||||
|
constructor TFppkgIncludeFilesOptionSection.Create(AnOptionParser: TTemplateParser;
|
||||||
|
AnOptions: TFppkgOptions; ACurrentDir: string);
|
||||||
|
begin
|
||||||
|
inherited Create(AnOptionParser);
|
||||||
|
FOptions := AnOptions;
|
||||||
|
FCurrentDir := ACurrentDir;
|
||||||
|
FOptionCache := TStringList.Create;
|
||||||
|
end;
|
||||||
|
|
||||||
|
destructor TFppkgIncludeFilesOptionSection.Destroy;
|
||||||
|
begin
|
||||||
|
FOptionCache.Free;
|
||||||
|
inherited Destroy;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TFppkgIncludeFilesOptionSection.AddKeyValue(const AKey, AValue: string);
|
||||||
|
begin
|
||||||
|
if SameText(AKey,KeyIncludeFile) then
|
||||||
|
begin
|
||||||
|
FOptionCache.Append(SLogIncludeFile + '=' + AValue);
|
||||||
|
IncludeFile(AValue);
|
||||||
|
end
|
||||||
|
else if SameText(AKey,KeyIncludeFileMask) then
|
||||||
|
begin
|
||||||
|
FOptionCache.Append(SLogIncludeFileMask + '=' + AValue);
|
||||||
|
IncludeFileMask(AValue);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TFppkgIncludeFilesOptionSection.LogValues(ALogLevel: TLogLevel);
|
||||||
|
var
|
||||||
|
i: Integer;
|
||||||
|
begin
|
||||||
|
inherited LogValues(ALogLevel);
|
||||||
|
for i := 0 to FOptionCache.Count -1 do
|
||||||
|
begin
|
||||||
|
log(ALogLevel, FOptionCache.Names[i], [FOptionCache.ValueFromIndex[i], FOptionParser.ParseString(FOptionCache.ValueFromIndex[i])]);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TFppkgIncludeFilesOptionSection.AllowDuplicate: Boolean;
|
||||||
|
begin
|
||||||
|
Result := inherited AllowDuplicate;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TFppkgRepositoryOptionSection }
|
{ TFppkgRepositoryOptionSection }
|
||||||
|
|
||||||
procedure TFppkgRepositoryOptionSection.SetDescription(AValue: string);
|
procedure TFppkgRepositoryOptionSection.SetDescription(AValue: string);
|
||||||
@ -697,6 +806,8 @@ begin
|
|||||||
CurrentSection := TFppkgRepositoryOptionSection.Create(FOptionParser)
|
CurrentSection := TFppkgRepositoryOptionSection.Create(FOptionParser)
|
||||||
else if SameText(s, KeySrcRepositorySection) then
|
else if SameText(s, KeySrcRepositorySection) then
|
||||||
CurrentSection := TFppkgUninstalledSourceRepositoryOptionSection.Create(FOptionParser)
|
CurrentSection := TFppkgUninstalledSourceRepositoryOptionSection.Create(FOptionParser)
|
||||||
|
else if SameText(s, KeyIncludeFilesSection) then
|
||||||
|
CurrentSection := TFppkgIncludeFilesOptionSection.Create(FOptionParser, Self, ExtractFileDir(AFileName))
|
||||||
else
|
else
|
||||||
CurrentSection := TFppkgCustomOptionSection.Create(FOptionParser);
|
CurrentSection := TFppkgCustomOptionSection.Create(FOptionParser);
|
||||||
FSectionList.Add(CurrentSection);
|
FSectionList.Add(CurrentSection);
|
||||||
|
Loading…
Reference in New Issue
Block a user