mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-12 07:46:00 +02:00
* Added the ability to load multiple 'Repositories' from the configuration
file. A 'Repository' being a list of packages. (These repositories should replace the available, local and global list of packages) * The OptionParser can now be used for all options, not only the global options. git-svn-id: trunk@34354 -
This commit is contained in:
parent
37c32f4b61
commit
dc680ff49d
@ -103,6 +103,9 @@ Resourcestring
|
|||||||
SLogCompilerCfgLocalInstallDir = ' LocalInstallDir: "%s" -> "%s"';
|
SLogCompilerCfgLocalInstallDir = ' LocalInstallDir: "%s" -> "%s"';
|
||||||
SLogCompilerCfgGlobalPrefix = ' GlobalPrefix: "%s" -> "%s"';
|
SLogCompilerCfgGlobalPrefix = ' GlobalPrefix: "%s" -> "%s"';
|
||||||
SLogCompilerCfgLocalPrefix = ' LocalPrefix: "%s" -> "%s"';
|
SLogCompilerCfgLocalPrefix = ' LocalPrefix: "%s" -> "%s"';
|
||||||
|
SLogRepositoryName = ' Name: %s';
|
||||||
|
SLogRepositoryDescription = ' Description: "%s"';
|
||||||
|
SLogRepositoryPath = ' Dir: "%s" -> "%s"';
|
||||||
|
|
||||||
SLogPackageInfoName = 'Package: %s';
|
SLogPackageInfoName = 'Package: %s';
|
||||||
SLogPackageInfoVersion = 'Version: %s';
|
SLogPackageInfoVersion = 'Version: %s';
|
||||||
|
@ -33,8 +33,12 @@ Type
|
|||||||
|
|
||||||
TFppkgOptionSection = class(TPersistent)
|
TFppkgOptionSection = class(TPersistent)
|
||||||
private
|
private
|
||||||
|
FOptionParser: TTemplateParser;
|
||||||
FName: string;
|
FName: string;
|
||||||
|
protected
|
||||||
|
property OptionParser: TTemplateParser read FOptionParser;
|
||||||
public
|
public
|
||||||
|
constructor Create(AnOptionParser: TTemplateParser); virtual;
|
||||||
procedure AddKeyValue(const AKey, AValue: string); virtual;
|
procedure AddKeyValue(const AKey, AValue: string); virtual;
|
||||||
procedure SaveToStrings(AStrings: TStrings); virtual;
|
procedure SaveToStrings(AStrings: TStrings); virtual;
|
||||||
procedure LogValues(ALogLevel: TLogLevel); virtual;
|
procedure LogValues(ALogLevel: TLogLevel); virtual;
|
||||||
@ -49,7 +53,6 @@ Type
|
|||||||
TFppkgGlobalOptionSection = class(TFppkgOptionSection)
|
TFppkgGlobalOptionSection = class(TFppkgOptionSection)
|
||||||
private
|
private
|
||||||
FCustomFPMakeOptions: string;
|
FCustomFPMakeOptions: string;
|
||||||
FOptionParser: TTemplateParser;
|
|
||||||
|
|
||||||
FBuildDir: string;
|
FBuildDir: string;
|
||||||
FCompilerConfigDir: string;
|
FCompilerConfigDir: string;
|
||||||
@ -77,7 +80,7 @@ Type
|
|||||||
procedure SetRemoteMirrorsURL(AValue: string);
|
procedure SetRemoteMirrorsURL(AValue: string);
|
||||||
procedure SetRemoteRepository(AValue: string);
|
procedure SetRemoteRepository(AValue: string);
|
||||||
public
|
public
|
||||||
constructor Create;
|
constructor Create(AnOptionParser: TTemplateParser); override;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
procedure AddKeyValue(const AKey, AValue: string); override;
|
procedure AddKeyValue(const AKey, AValue: string); override;
|
||||||
procedure SaveToStrings(AStrings: TStrings); override;
|
procedure SaveToStrings(AStrings: TStrings); override;
|
||||||
@ -103,6 +106,27 @@ Type
|
|||||||
|
|
||||||
TFppkgCustomOptionSection = class(TFppkgOptionSection);
|
TFppkgCustomOptionSection = class(TFppkgOptionSection);
|
||||||
|
|
||||||
|
{ TFppkgRepositoryOptionSection }
|
||||||
|
|
||||||
|
TFppkgRepositoryOptionSection = class(TFppkgOptionSection)
|
||||||
|
private
|
||||||
|
FDescription: string;
|
||||||
|
FPath: string;
|
||||||
|
FRepositoryName: string;
|
||||||
|
function GetPath: string;
|
||||||
|
procedure SetDescription(AValue: string);
|
||||||
|
procedure SetRepositoryName(AValue: string);
|
||||||
|
procedure SetPath(AValue: string);
|
||||||
|
public
|
||||||
|
procedure AddKeyValue(const AKey, AValue: string); override;
|
||||||
|
procedure LogValues(ALogLevel: TLogLevel); override;
|
||||||
|
function AllowDuplicate: Boolean; override;
|
||||||
|
|
||||||
|
property RepositoryName: string read FRepositoryName write SetRepositoryName;
|
||||||
|
property Description: string read FDescription write SetDescription;
|
||||||
|
property Path: string read GetPath write SetPath;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TFppkgCommandLineOptionSection }
|
{ TFppkgCommandLineOptionSection }
|
||||||
|
|
||||||
TFppkgCommandLineOptionSection = class(TFppkgOptionSection)
|
TFppkgCommandLineOptionSection = class(TFppkgOptionSection)
|
||||||
@ -115,7 +139,7 @@ Type
|
|||||||
FSkipConfigurationFiles: Boolean;
|
FSkipConfigurationFiles: Boolean;
|
||||||
FSkipFixBrokenAfterInstall: Boolean;
|
FSkipFixBrokenAfterInstall: Boolean;
|
||||||
public
|
public
|
||||||
constructor Create;
|
constructor Create(AnOptionParser: TTemplateParser); override;
|
||||||
property RecoveryMode: Boolean read FRecoveryMode write FRecoveryMode;
|
property RecoveryMode: Boolean read FRecoveryMode write FRecoveryMode;
|
||||||
property InstallGlobal: Boolean read FInstallGlobal write FInstallGlobal;
|
property InstallGlobal: Boolean read FInstallGlobal write FInstallGlobal;
|
||||||
property ShowLocation: Boolean read FShowLocation write FShowLocation;
|
property ShowLocation: Boolean read FShowLocation write FShowLocation;
|
||||||
@ -128,8 +152,10 @@ Type
|
|||||||
|
|
||||||
{ TFppkgOptions }
|
{ TFppkgOptions }
|
||||||
|
|
||||||
|
TCompilerOptions = class;
|
||||||
TFppkgOptions = class(TPersistent)
|
TFppkgOptions = class(TPersistent)
|
||||||
private
|
private
|
||||||
|
FOptionParser: TTemplateParser;
|
||||||
FSectionList: TFppkgOptionSectionList;
|
FSectionList: TFppkgOptionSectionList;
|
||||||
function GetCommandLineSection: TFppkgCommandLineOptionSection;
|
function GetCommandLineSection: TFppkgCommandLineOptionSection;
|
||||||
function GetGlobalSection: TFppkgGLobalOptionSection;
|
function GetGlobalSection: TFppkgGLobalOptionSection;
|
||||||
@ -143,6 +169,8 @@ Type
|
|||||||
function GetSectionByName(const SectionName: string): TFppkgOptionSection;
|
function GetSectionByName(const SectionName: string): TFppkgOptionSection;
|
||||||
procedure LogValues(ALogLevel: TLogLevel);
|
procedure LogValues(ALogLevel: TLogLevel);
|
||||||
|
|
||||||
|
procedure BindToCompilerOptions(ACompilerOptions: TCompilerOptions);
|
||||||
|
|
||||||
property SectionList: TFppkgOptionSectionList read GetSectionList;
|
property SectionList: TFppkgOptionSectionList read GetSectionList;
|
||||||
property GlobalSection: TFppkgGLobalOptionSection read GetGlobalSection;
|
property GlobalSection: TFppkgGLobalOptionSection read GetGlobalSection;
|
||||||
property CommandLineSection: TFppkgCommandLineOptionSection read GetCommandLineSection;
|
property CommandLineSection: TFppkgCommandLineOptionSection read GetCommandLineSection;
|
||||||
@ -177,7 +205,7 @@ Type
|
|||||||
Procedure LoadCompilerFromFile(const AFileName : String);
|
Procedure LoadCompilerFromFile(const AFileName : String);
|
||||||
Procedure SaveCompilerToFile(const AFileName : String);
|
Procedure SaveCompilerToFile(const AFileName : String);
|
||||||
procedure LogValues(ALogLevel: TLogLevel; const ACfgName:string);
|
procedure LogValues(ALogLevel: TLogLevel; const ACfgName:string);
|
||||||
procedure UpdateLocalRepositoryOption;
|
procedure UpdateLocalRepositoryOption(FppkgOptions: TFppkgOptions);
|
||||||
procedure CheckCompilerValues;
|
procedure CheckCompilerValues;
|
||||||
Function LocalUnitDir:string;
|
Function LocalUnitDir:string;
|
||||||
Function GlobalUnitDir:string;
|
Function GlobalUnitDir:string;
|
||||||
@ -230,6 +258,7 @@ Const
|
|||||||
// Global config
|
// Global config
|
||||||
KeyDeprGlobalSection = 'Defaults';
|
KeyDeprGlobalSection = 'Defaults';
|
||||||
KeyGlobalSection = 'Global';
|
KeyGlobalSection = 'Global';
|
||||||
|
KeyRepositorySection = 'Repository';
|
||||||
KeyRemoteMirrorsURL = 'RemoteMirrors';
|
KeyRemoteMirrorsURL = 'RemoteMirrors';
|
||||||
KeyRemoteRepository = 'RemoteRepository';
|
KeyRemoteRepository = 'RemoteRepository';
|
||||||
KeyLocalRepository = 'LocalRepository';
|
KeyLocalRepository = 'LocalRepository';
|
||||||
@ -241,6 +270,10 @@ Const
|
|||||||
KeyDownloader = 'Downloader';
|
KeyDownloader = 'Downloader';
|
||||||
KeyCustomFPMakeOptions = 'FPMakeOptions';
|
KeyCustomFPMakeOptions = 'FPMakeOptions';
|
||||||
|
|
||||||
|
KeyRepositoryName = 'Name';
|
||||||
|
KeyRepositoryDescription = 'Description';
|
||||||
|
KeyRepositoryPath = 'Path';
|
||||||
|
|
||||||
// Compiler dependent config
|
// Compiler dependent config
|
||||||
KeyGlobalPrefix = 'GlobalPrefix';
|
KeyGlobalPrefix = 'GlobalPrefix';
|
||||||
KeyLocalPrefix = 'LocalPrefix';
|
KeyLocalPrefix = 'LocalPrefix';
|
||||||
@ -316,7 +349,7 @@ var
|
|||||||
begin
|
begin
|
||||||
// Load default compiler config
|
// Load default compiler config
|
||||||
S:=GlobalOptions.GlobalSection.CompilerConfigDir+GlobalOptions.GlobalSection.CompilerConfig;
|
S:=GlobalOptions.GlobalSection.CompilerConfigDir+GlobalOptions.GlobalSection.CompilerConfig;
|
||||||
CompilerOptions.UpdateLocalRepositoryOption;
|
CompilerOptions.UpdateLocalRepositoryOption(GlobalOptions);
|
||||||
if FileExists(S) then
|
if FileExists(S) then
|
||||||
begin
|
begin
|
||||||
pkgglobals.Log(llDebug,SLogLoadingCompilerConfig,[S]);
|
pkgglobals.Log(llDebug,SLogLoadingCompilerConfig,[S]);
|
||||||
@ -340,7 +373,7 @@ begin
|
|||||||
CompilerOptions.LogValues(llDebug,'');
|
CompilerOptions.LogValues(llDebug,'');
|
||||||
// Load FPMake compiler config, this is normally the same config as above
|
// Load FPMake compiler config, this is normally the same config as above
|
||||||
S:=GlobalOptions.GlobalSection.CompilerConfigDir+GlobalOptions.GlobalSection.FPMakeCompilerConfig;
|
S:=GlobalOptions.GlobalSection.CompilerConfigDir+GlobalOptions.GlobalSection.FPMakeCompilerConfig;
|
||||||
FPMakeCompilerOptions.UpdateLocalRepositoryOption;
|
FPMakeCompilerOptions.UpdateLocalRepositoryOption(GlobalOptions);
|
||||||
if FileExists(S) then
|
if FileExists(S) then
|
||||||
begin
|
begin
|
||||||
pkgglobals.Log(llDebug,SLogLoadingFPMakeCompilerConfig,[S]);
|
pkgglobals.Log(llDebug,SLogLoadingFPMakeCompilerConfig,[S]);
|
||||||
@ -354,10 +387,59 @@ begin
|
|||||||
FPMakeCompilerOptions.LogValues(llDebug,'fpmake-building ');
|
FPMakeCompilerOptions.LogValues(llDebug,'fpmake-building ');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ TFppkgRepositoryOptionSection }
|
||||||
|
|
||||||
|
procedure TFppkgRepositoryOptionSection.SetDescription(AValue: string);
|
||||||
|
begin
|
||||||
|
if FDescription = AValue then Exit;
|
||||||
|
FDescription := AValue;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TFppkgRepositoryOptionSection.GetPath: string;
|
||||||
|
begin
|
||||||
|
Result := OptionParser.ParseString(FPath);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TFppkgRepositoryOptionSection.SetRepositoryName(AValue: string);
|
||||||
|
begin
|
||||||
|
if FRepositoryName = AValue then Exit;
|
||||||
|
FRepositoryName := AValue;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TFppkgRepositoryOptionSection.SetPath(AValue: string);
|
||||||
|
begin
|
||||||
|
if FPath = AValue then Exit;
|
||||||
|
FPath := AValue;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TFppkgRepositoryOptionSection.AddKeyValue(const AKey, AValue: string);
|
||||||
|
begin
|
||||||
|
if SameText(AKey,KeyRepositoryName) then
|
||||||
|
RepositoryName := AValue
|
||||||
|
else if SameText(AKey,KeyRepositoryDescription) then
|
||||||
|
Description := AValue
|
||||||
|
else if SameText(AKey,KeyRepositoryPath) then
|
||||||
|
Path := AValue
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TFppkgRepositoryOptionSection.LogValues(ALogLevel: TLogLevel);
|
||||||
|
begin
|
||||||
|
inherited LogValues(ALogLevel);
|
||||||
|
log(ALogLevel,SLogRepositoryName,[FRepositoryName]);
|
||||||
|
log(ALogLevel,SLogRepositoryDescription,[FDescription]);
|
||||||
|
log(ALogLevel,SLogRepositoryPath,[FPath,Path]);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TFppkgRepositoryOptionSection.AllowDuplicate: Boolean;
|
||||||
|
begin
|
||||||
|
Result := True;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TFppkgCommandLineOptionSection }
|
{ TFppkgCommandLineOptionSection }
|
||||||
|
|
||||||
constructor TFppkgCommandLineOptionSection.Create;
|
constructor TFppkgCommandLineOptionSection.Create(AnOptionParser: TTemplateParser);
|
||||||
begin
|
begin
|
||||||
|
inherited Create(AnOptionParser);
|
||||||
// Parameter defaults
|
// Parameter defaults
|
||||||
FInstallGlobal:=False;
|
FInstallGlobal:=False;
|
||||||
FRecoveryMode:=False;
|
FRecoveryMode:=False;
|
||||||
@ -366,6 +448,11 @@ end;
|
|||||||
|
|
||||||
{ TFppkgOptionSection }
|
{ TFppkgOptionSection }
|
||||||
|
|
||||||
|
constructor TFppkgOptionSection.Create(AnOptionParser: TTemplateParser);
|
||||||
|
begin
|
||||||
|
FOptionParser:=AnOptionParser;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TFppkgOptionSection.AddKeyValue(const AKey, AValue: string);
|
procedure TFppkgOptionSection.AddKeyValue(const AKey, AValue: string);
|
||||||
begin
|
begin
|
||||||
// Do nothing
|
// Do nothing
|
||||||
@ -477,12 +564,9 @@ begin
|
|||||||
FRemoteRepository := AValue;
|
FRemoteRepository := AValue;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
constructor TFppkgGlobalOptionSection.Create;
|
constructor TFppkgGlobalOptionSection.Create(AnOptionParser: TTemplateParser);
|
||||||
begin
|
begin
|
||||||
FOptionParser := TTemplateParser.Create;
|
Inherited Create(AnOptionParser);
|
||||||
FOptionParser.Values['AppConfigDir'] := GetAppConfigDir(false);
|
|
||||||
FOptionParser.Values['UserDir'] := GetUserDir;
|
|
||||||
|
|
||||||
// Retrieve Local fppkg directory
|
// Retrieve Local fppkg directory
|
||||||
{$ifdef unix}
|
{$ifdef unix}
|
||||||
if IsSuperUser then
|
if IsSuperUser then
|
||||||
@ -520,7 +604,6 @@ end;
|
|||||||
|
|
||||||
destructor TFppkgGlobalOptionSection.Destroy;
|
destructor TFppkgGlobalOptionSection.Destroy;
|
||||||
begin
|
begin
|
||||||
FOptionParser.Free;
|
|
||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -615,7 +698,7 @@ begin
|
|||||||
|
|
||||||
if not Assigned(Result) then
|
if not Assigned(Result) then
|
||||||
begin
|
begin
|
||||||
Result := TFppkgGlobalOptionSection.Create;
|
Result := TFppkgGlobalOptionSection.Create(FOptionParser);
|
||||||
Result.Name := KeyGlobalSection;
|
Result.Name := KeyGlobalSection;
|
||||||
FSectionList.Add(Result);
|
FSectionList.Add(Result);
|
||||||
end;
|
end;
|
||||||
@ -626,7 +709,7 @@ begin
|
|||||||
Result := GetSectionByName(' Commandline ') as TFppkgCommandLineOptionSection;
|
Result := GetSectionByName(' Commandline ') as TFppkgCommandLineOptionSection;
|
||||||
if not Assigned(Result) then
|
if not Assigned(Result) then
|
||||||
begin
|
begin
|
||||||
Result := TFppkgCommandLineOptionSection.Create;
|
Result := TFppkgCommandLineOptionSection.Create(FOptionParser);
|
||||||
Result.Name := ' Commandline ';
|
Result.Name := ' Commandline ';
|
||||||
FSectionList.Add(Result);
|
FSectionList.Add(Result);
|
||||||
end;
|
end;
|
||||||
@ -634,12 +717,17 @@ end;
|
|||||||
|
|
||||||
constructor TFppkgOptions.Create;
|
constructor TFppkgOptions.Create;
|
||||||
begin
|
begin
|
||||||
|
FOptionParser := TTemplateParser.Create;
|
||||||
|
FOptionParser.Values['AppConfigDir'] := GetAppConfigDir(false);
|
||||||
|
FOptionParser.Values['UserDir'] := GetUserDir;
|
||||||
|
|
||||||
FSectionList := TFppkgOptionSectionList.Create;
|
FSectionList := TFppkgOptionSectionList.Create;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
destructor TFppkgOptions.Destroy;
|
destructor TFppkgOptions.Destroy;
|
||||||
begin
|
begin
|
||||||
FSectionList.Free;
|
FSectionList.Free;
|
||||||
|
FOptionParser.Free;
|
||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -667,9 +755,11 @@ begin
|
|||||||
if not Assigned(CurrentSection) or CurrentSection.AllowDuplicate then
|
if not Assigned(CurrentSection) or CurrentSection.AllowDuplicate then
|
||||||
begin
|
begin
|
||||||
if SameText(s, KeyGlobalSection) or SameText(s, KeyDeprGlobalSection) then
|
if SameText(s, KeyGlobalSection) or SameText(s, KeyDeprGlobalSection) then
|
||||||
CurrentSection := TFppkgGlobalOptionSection.Create
|
CurrentSection := TFppkgGlobalOptionSection.Create(FOptionParser)
|
||||||
|
else if SameText(s, KeyRepositorySection) then
|
||||||
|
CurrentSection := TFppkgRepositoryOptionSection.Create(FOptionParser)
|
||||||
else
|
else
|
||||||
CurrentSection := TFppkgCustomOptionSection.Create;
|
CurrentSection := TFppkgCustomOptionSection.Create(FOptionParser);
|
||||||
FSectionList.Add(CurrentSection);
|
FSectionList.Add(CurrentSection);
|
||||||
CurrentSection.Name := s;
|
CurrentSection.Name := s;
|
||||||
end
|
end
|
||||||
@ -732,6 +822,11 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TFppkgOptions.BindToCompilerOptions(ACompilerOptions: TCompilerOptions);
|
||||||
|
begin
|
||||||
|
FOptionParser.Values['CompilerVersion'] := ACompilerOptions.CompilerVersion;
|
||||||
|
end;
|
||||||
|
|
||||||
{*****************************************************************************
|
{*****************************************************************************
|
||||||
TCompilerOptions
|
TCompilerOptions
|
||||||
*****************************************************************************}
|
*****************************************************************************}
|
||||||
@ -820,9 +915,9 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure TCompilerOptions.UpdateLocalRepositoryOption;
|
procedure TCompilerOptions.UpdateLocalRepositoryOption(FppkgOptions: TFppkgOptions);
|
||||||
begin
|
begin
|
||||||
FOptionParser.Values['LocalRepository'] := GlobalOptions.GlobalSection.LocalRepository;
|
FOptionParser.Values['LocalRepository'] := FppkgOptions.GlobalSection.LocalRepository;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCompilerOptions.CheckCompilerValues;
|
procedure TCompilerOptions.CheckCompilerValues;
|
||||||
|
Loading…
Reference in New Issue
Block a user