mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-14 16:49:07 +02:00
* Improved ability to generate fppkg-configuration files
git-svn-id: trunk@36442 -
This commit is contained in:
parent
19f842663b
commit
c62d3a83c8
@ -39,6 +39,9 @@ Type
|
|||||||
FOptionParser: TTemplateParser;
|
FOptionParser: TTemplateParser;
|
||||||
FName: string;
|
FName: string;
|
||||||
protected
|
protected
|
||||||
|
class function GetKey: string; virtual;
|
||||||
|
procedure AddKeyValueToStrings(AStrings: TStrings; AKey, AValue: string); overload;
|
||||||
|
procedure AddKeyValueToStrings(AStrings: TStrings; AKey: string; AValue: Integer); overload;
|
||||||
property OptionParser: TTemplateParser read FOptionParser;
|
property OptionParser: TTemplateParser read FOptionParser;
|
||||||
public
|
public
|
||||||
constructor Create(AnOptionParser: TTemplateParser); virtual;
|
constructor Create(AnOptionParser: TTemplateParser); virtual;
|
||||||
@ -128,6 +131,7 @@ Type
|
|||||||
procedure SetPath(AValue: string);
|
procedure SetPath(AValue: string);
|
||||||
protected
|
protected
|
||||||
procedure SaveToStrings(AStrings: TStrings); override;
|
procedure SaveToStrings(AStrings: TStrings); override;
|
||||||
|
class function GetKey: string; override;
|
||||||
public
|
public
|
||||||
procedure AddKeyValue(const AKey, AValue: string); override;
|
procedure AddKeyValue(const AKey, AValue: string); override;
|
||||||
procedure LogValues(ALogLevel: TLogLevel); override;
|
procedure LogValues(ALogLevel: TLogLevel); override;
|
||||||
@ -153,9 +157,12 @@ Type
|
|||||||
|
|
||||||
procedure IncludeFile(AFileName: string);
|
procedure IncludeFile(AFileName: string);
|
||||||
procedure IncludeFileMask(AFileNameMask: string);
|
procedure IncludeFileMask(AFileNameMask: string);
|
||||||
|
protected
|
||||||
|
class function GetKey: string; override;
|
||||||
public
|
public
|
||||||
constructor Create(AnOptionParser: TTemplateParser; AnOptions: TFppkgOptions; ACurrentDir: string);
|
constructor Create(AnOptionParser: TTemplateParser; AnOptions: TFppkgOptions; ACurrentDir: string);
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
|
procedure SaveToStrings(AStrings: TStrings); override;
|
||||||
procedure AddKeyValue(const AKey, AValue: string); override;
|
procedure AddKeyValue(const AKey, AValue: string); override;
|
||||||
procedure LogValues(ALogLevel: TLogLevel); override;
|
procedure LogValues(ALogLevel: TLogLevel); override;
|
||||||
function AllowDuplicate: Boolean; override;
|
function AllowDuplicate: Boolean; override;
|
||||||
@ -285,8 +292,6 @@ Const
|
|||||||
KeyDeprGlobalSection = 'Defaults';
|
KeyDeprGlobalSection = 'Defaults';
|
||||||
KeyGlobalSection = 'Global';
|
KeyGlobalSection = 'Global';
|
||||||
KeyRepositorySection = 'Repository';
|
KeyRepositorySection = 'Repository';
|
||||||
KeySrcRepositorySection = 'UninstalledSourceRepository';
|
|
||||||
KeyUninstalledRepository = 'UninstalledRepository';
|
|
||||||
KeyIncludeFilesSection = 'IncludeFiles';
|
KeyIncludeFilesSection = 'IncludeFiles';
|
||||||
KeyRemoteMirrorsURL = 'RemoteMirrors';
|
KeyRemoteMirrorsURL = 'RemoteMirrors';
|
||||||
KeyRemoteRepository = 'RemoteRepository';
|
KeyRemoteRepository = 'RemoteRepository';
|
||||||
@ -360,6 +365,17 @@ begin
|
|||||||
log(llWarning, SLogIncludeFileMaskDoesNotExist, [FileDir, AFileNameMask]);
|
log(llWarning, SLogIncludeFileMaskDoesNotExist, [FileDir, AFileNameMask]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
class function TFppkgIncludeFilesOptionSection.GetKey: string;
|
||||||
|
begin
|
||||||
|
Result := KeyIncludeFilesSection;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TFppkgIncludeFilesOptionSection.SaveToStrings(AStrings: TStrings);
|
||||||
|
begin
|
||||||
|
AStrings.Add('['+KeyIncludeFilesSection+']');
|
||||||
|
AddKeyValueToStrings(AStrings, KeyIncludeFileMask, FCurrentDir);
|
||||||
|
end;
|
||||||
|
|
||||||
constructor TFppkgIncludeFilesOptionSection.Create(AnOptionParser: TTemplateParser;
|
constructor TFppkgIncludeFilesOptionSection.Create(AnOptionParser: TTemplateParser;
|
||||||
AnOptions: TFppkgOptions; ACurrentDir: string);
|
AnOptions: TFppkgOptions; ACurrentDir: string);
|
||||||
begin
|
begin
|
||||||
@ -444,13 +460,16 @@ end;
|
|||||||
procedure TFppkgRepositoryOptionSection.SaveToStrings(AStrings: TStrings);
|
procedure TFppkgRepositoryOptionSection.SaveToStrings(AStrings: TStrings);
|
||||||
begin
|
begin
|
||||||
inherited SaveToStrings(AStrings);
|
inherited SaveToStrings(AStrings);
|
||||||
AStrings.Add('['+KeyRepositorySection+']');
|
AddKeyValueToStrings(AStrings, KeyRepositoryName, RepositoryName);
|
||||||
AStrings.Add(KeyRepositoryName+'='+RepositoryName);
|
AddKeyValueToStrings(AStrings, KeyRepositoryDescription, Description);
|
||||||
AStrings.Add(KeyRepositoryDescription+'='+Description);
|
AddKeyValueToStrings(AStrings, KeyRepositoryPath, FPath);
|
||||||
AStrings.Add(KeyRepositoryPath+'='+FPath);
|
AddKeyValueToStrings(AStrings, KeyRepositoryPrefix, FPrefix);
|
||||||
AStrings.Add(KeyRepositoryPrefix+'='+FPrefix);
|
AddKeyValueToStrings(AStrings, KeyInstallRepositoryName, InstallRepositoryName);
|
||||||
if InstallRepositoryName<>'' then
|
end;
|
||||||
AStrings.Add(KeyInstallRepositoryName+'='+InstallRepositoryName);
|
|
||||||
|
class function TFppkgRepositoryOptionSection.GetKey: string;
|
||||||
|
begin
|
||||||
|
Result := KeyRepositorySection;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TFppkgRepositoryOptionSection.AddKeyValue(const AKey, AValue: string);
|
procedure TFppkgRepositoryOptionSection.AddKeyValue(const AKey, AValue: string);
|
||||||
@ -499,6 +518,23 @@ end;
|
|||||||
|
|
||||||
{ TFppkgOptionSection }
|
{ TFppkgOptionSection }
|
||||||
|
|
||||||
|
class function TFppkgOptionSection.GetKey: string;
|
||||||
|
begin
|
||||||
|
Result := '';
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TFppkgOptionSection.AddKeyValueToStrings(AStrings: TStrings; AKey, AValue: string);
|
||||||
|
begin
|
||||||
|
if AValue<>'' then
|
||||||
|
AStrings.Add(AKey+'='+AValue);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TFppkgOptionSection.AddKeyValueToStrings(AStrings: TStrings; AKey: string; AValue: Integer);
|
||||||
|
begin
|
||||||
|
if AValue<>-1 then
|
||||||
|
AStrings.Add(AKey+'='+IntToStr(AValue));
|
||||||
|
end;
|
||||||
|
|
||||||
constructor TFppkgOptionSection.Create(AnOptionParser: TTemplateParser);
|
constructor TFppkgOptionSection.Create(AnOptionParser: TTemplateParser);
|
||||||
begin
|
begin
|
||||||
FOptionParser:=AnOptionParser;
|
FOptionParser:=AnOptionParser;
|
||||||
@ -511,7 +547,7 @@ end;
|
|||||||
|
|
||||||
procedure TFppkgOptionSection.SaveToStrings(AStrings: TStrings);
|
procedure TFppkgOptionSection.SaveToStrings(AStrings: TStrings);
|
||||||
begin
|
begin
|
||||||
// Do nothing
|
AStrings.Add('['+GetKey+']');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TFppkgOptionSection.LogValues(ALogLevel: TLogLevel);
|
procedure TFppkgOptionSection.LogValues(ALogLevel: TLogLevel);
|
||||||
@ -697,16 +733,17 @@ end;
|
|||||||
procedure TFppkgGlobalOptionSection.SaveToStrings(AStrings: TStrings);
|
procedure TFppkgGlobalOptionSection.SaveToStrings(AStrings: TStrings);
|
||||||
begin
|
begin
|
||||||
AStrings.Add('['+KeyGlobalSection+']');
|
AStrings.Add('['+KeyGlobalSection+']');
|
||||||
AStrings.Add(KeyConfigVersion+'='+IntToStr(CurrentConfigVersion));
|
AddKeyValueToStrings(AStrings, KeyConfigVersion, CurrentConfigVersion);
|
||||||
AStrings.Add(KeyBuildDir+'='+BuildDir);
|
AddKeyValueToStrings(AStrings, KeyBuildDir, BuildDir);
|
||||||
AStrings.Add(KeyDownloader+'='+Downloader);
|
AddKeyValueToStrings(AStrings, KeyDownloader, Downloader);
|
||||||
AStrings.Add(KeyCompilerConfig+'='+CompilerConfig);
|
AddKeyValueToStrings(AStrings, KeyCompilerConfig, CompilerConfig);
|
||||||
AStrings.Add(KeyFPMakeCompilerConfig+'='+FPMakeCompilerConfig);
|
AddKeyValueToStrings(AStrings, KeyFPMakeCompilerConfig, FPMakeCompilerConfig);
|
||||||
AStrings.Add(KeyCompilerConfigDir+'='+CompilerConfigDir);
|
AddKeyValueToStrings(AStrings, KeyCompilerConfigDir, CompilerConfigDir);
|
||||||
AStrings.Add(KeyRemoteMirrorsURL+'='+RemoteMirrorsURL);
|
AddKeyValueToStrings(AStrings, KeyRemoteMirrorsURL, RemoteMirrorsURL);
|
||||||
AStrings.Add(KeyRemoteRepository+'='+RemoteRepository);
|
AddKeyValueToStrings(AStrings, KeyRemoteRepository, RemoteRepository);
|
||||||
AStrings.Add(KeyLocalRepository+'='+LocalRepository);
|
AddKeyValueToStrings(AStrings, KeyLocalRepository, LocalRepository);
|
||||||
AStrings.Add(KeyArchivesDir+'='+ArchivesDir);
|
AddKeyValueToStrings(AStrings, KeyArchivesDir, ArchivesDir);
|
||||||
|
AddKeyValueToStrings(AStrings, KeyCustomFPMakeOptions, CustomFPMakeOptions);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TFppkgGlobalOptionSection.LogValues(ALogLevel: TLogLevel);
|
procedure TFppkgGlobalOptionSection.LogValues(ALogLevel: TLogLevel);
|
||||||
@ -811,13 +848,13 @@ begin
|
|||||||
CurrentSection := GetGlobalSection
|
CurrentSection := GetGlobalSection
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
if SameText(s, KeyRepositorySection) then
|
if SameText(s, TFppkgRepositoryOptionSection.GetKey) then
|
||||||
CurrentSection := TFppkgRepositoryOptionSection.Create(FOptionParser)
|
CurrentSection := TFppkgRepositoryOptionSection.Create(FOptionParser)
|
||||||
else if SameText(s, KeySrcRepositorySection) then
|
else if SameText(s, TFppkgUninstalledSourceRepositoryOptionSection.GetKey) then
|
||||||
CurrentSection := TFppkgUninstalledSourceRepositoryOptionSection.Create(FOptionParser)
|
CurrentSection := TFppkgUninstalledSourceRepositoryOptionSection.Create(FOptionParser)
|
||||||
else if SameText(s, KeyIncludeFilesSection) then
|
else if SameText(s, TFppkgIncludeFilesOptionSection.GetKey) then
|
||||||
CurrentSection := TFppkgIncludeFilesOptionSection.Create(FOptionParser, Self, ExtractFileDir(AFileName))
|
CurrentSection := TFppkgIncludeFilesOptionSection.Create(FOptionParser, Self, ExtractFileDir(AFileName))
|
||||||
else if SameText(s, KeyUninstalledRepository) then
|
else if SameText(s, TFppkgUninstalledRepositoryOptionSection.GetKey) then
|
||||||
CurrentSection := TFppkgUninstalledRepositoryOptionSection.Create(FOptionParser)
|
CurrentSection := TFppkgUninstalledRepositoryOptionSection.Create(FOptionParser)
|
||||||
else
|
else
|
||||||
CurrentSection := TFppkgCustomOptionSection.Create(FOptionParser);
|
CurrentSection := TFppkgCustomOptionSection.Create(FOptionParser);
|
||||||
|
@ -22,6 +22,8 @@ type
|
|||||||
{ TFppkgUninstalledSourceRepositoryOptionSection }
|
{ TFppkgUninstalledSourceRepositoryOptionSection }
|
||||||
|
|
||||||
TFppkgUninstalledSourceRepositoryOptionSection = class(TFppkgRepositoryOptionSection)
|
TFppkgUninstalledSourceRepositoryOptionSection = class(TFppkgRepositoryOptionSection)
|
||||||
|
protected
|
||||||
|
class function GetKey: string; override;
|
||||||
public
|
public
|
||||||
function GetRepositoryType: TFPRepositoryType; override;
|
function GetRepositoryType: TFPRepositoryType; override;
|
||||||
end;
|
end;
|
||||||
@ -43,10 +45,13 @@ type
|
|||||||
TFppkgUninstalledRepositoryOptionSection = class(TFppkgRepositoryOptionSection)
|
TFppkgUninstalledRepositoryOptionSection = class(TFppkgRepositoryOptionSection)
|
||||||
private
|
private
|
||||||
FSourceRepositoryName: string;
|
FSourceRepositoryName: string;
|
||||||
|
protected
|
||||||
|
class function GetKey: string; override;
|
||||||
public
|
public
|
||||||
procedure AddKeyValue(const AKey, AValue: string); override;
|
procedure AddKeyValue(const AKey, AValue: string); override;
|
||||||
procedure LogValues(ALogLevel: TLogLevel); override;
|
procedure LogValues(ALogLevel: TLogLevel); override;
|
||||||
function GetRepositoryType: TFPRepositoryType; override;
|
function GetRepositoryType: TFPRepositoryType; override;
|
||||||
|
procedure SaveToStrings(AStrings: TStrings); override;
|
||||||
property SourceRepositoryName: string read FSourceRepositoryName write FSourceRepositoryName;
|
property SourceRepositoryName: string read FSourceRepositoryName write FSourceRepositoryName;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -72,8 +77,10 @@ implementation
|
|||||||
|
|
||||||
const
|
const
|
||||||
KeySourceRepository = 'SourceRepository';
|
KeySourceRepository = 'SourceRepository';
|
||||||
|
|
||||||
SLogSourceRepository = ' SourceRepository:%s';
|
SLogSourceRepository = ' SourceRepository:%s';
|
||||||
|
KeySrcRepositorySection = 'UninstalledSourceRepository';
|
||||||
|
KeyUninstalledRepository = 'UninstalledRepository';
|
||||||
|
KeyRepositorySection = 'Repository';
|
||||||
|
|
||||||
{ TFPUninstalledSourcesPackagesStructure }
|
{ TFPUninstalledSourcesPackagesStructure }
|
||||||
|
|
||||||
@ -151,6 +158,11 @@ end;
|
|||||||
|
|
||||||
{ TFppkgUninstalledRepositoryOptionSection }
|
{ TFppkgUninstalledRepositoryOptionSection }
|
||||||
|
|
||||||
|
class function TFppkgUninstalledRepositoryOptionSection.GetKey: string;
|
||||||
|
begin
|
||||||
|
Result := KeyUninstalledRepository;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TFppkgUninstalledRepositoryOptionSection.AddKeyValue(const AKey, AValue: string);
|
procedure TFppkgUninstalledRepositoryOptionSection.AddKeyValue(const AKey, AValue: string);
|
||||||
begin
|
begin
|
||||||
if SameText(AKey,KeySourceRepository) then
|
if SameText(AKey,KeySourceRepository) then
|
||||||
@ -170,8 +182,20 @@ begin
|
|||||||
Result := fprtInstalled;
|
Result := fprtInstalled;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TFppkgUninstalledRepositoryOptionSection.SaveToStrings(AStrings: TStrings);
|
||||||
|
begin
|
||||||
|
inherited SaveToStrings(AStrings);
|
||||||
|
if SourceRepositoryName<>'' then
|
||||||
|
AStrings.Add(KeySourceRepository+'='+SourceRepositoryName);
|
||||||
|
end;
|
||||||
|
|
||||||
{ TFppkgUninstalledSourceRepositoryOptionSection }
|
{ TFppkgUninstalledSourceRepositoryOptionSection }
|
||||||
|
|
||||||
|
class function TFppkgUninstalledSourceRepositoryOptionSection.GetKey: string;
|
||||||
|
begin
|
||||||
|
Result := KeySrcRepositorySection;
|
||||||
|
end;
|
||||||
|
|
||||||
function TFppkgUninstalledSourceRepositoryOptionSection.GetRepositoryType: TFPRepositoryType;
|
function TFppkgUninstalledSourceRepositoryOptionSection.GetRepositoryType: TFPRepositoryType;
|
||||||
begin
|
begin
|
||||||
Result := fprtAvailable;
|
Result := fprtAvailable;
|
||||||
|
Loading…
Reference in New Issue
Block a user