mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-19 23:19:24 +02:00
* Reading the fppkg-settings should not depend on the global
OnGetApplicationName event git-svn-id: trunk@35701 -
This commit is contained in:
parent
b52d6874d2
commit
3b58c328c7
@ -169,16 +169,16 @@ begin
|
||||
else
|
||||
begin
|
||||
// Now try if a local config-file exists
|
||||
cfgfile:=GetAppConfigFile(False,False);
|
||||
cfgfile:=GetFppkgConfigFile(False,False);
|
||||
if not FileExists(cfgfile) then
|
||||
begin
|
||||
// If not, try to find a global configuration file
|
||||
cfgfile:=GetAppConfigFile(True,False);
|
||||
cfgfile:=GetFppkgConfigFile(True,False);
|
||||
if not FileExists(cfgfile) then
|
||||
begin
|
||||
// Create a new configuration file
|
||||
if not IsSuperUser then // Make a local, not global, configuration file
|
||||
cfgfile:=GetAppConfigFile(False,False);
|
||||
cfgfile:=GetFppkgConfigFile(False,False);
|
||||
ForceDirectories(ExtractFilePath(cfgfile));
|
||||
FOptions.SaveToFile(cfgfile);
|
||||
GeneratedConfig:=true;
|
||||
|
@ -96,6 +96,10 @@ var
|
||||
LogHandler: TLogProc;
|
||||
ErrorHandler: TPkgErrorProc;
|
||||
|
||||
function GetFppkgConfigFile(Global : Boolean; SubDir : Boolean): string;
|
||||
function GetFppkgConfigDir(Global : Boolean): string;
|
||||
|
||||
|
||||
Implementation
|
||||
|
||||
// define use_shell to use sysutils.executeprocess
|
||||
@ -420,11 +424,42 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function GetFppkgConfigFile(Global : Boolean; SubDir : Boolean): string;
|
||||
var
|
||||
StoredOnGetApplicationName: TGetAppNameEvent;
|
||||
StoredOnGetVendorName: TGetVendorNameEvent;
|
||||
begin
|
||||
StoredOnGetApplicationName := OnGetApplicationName;
|
||||
StoredOnGetVendorName := OnGetVendorName;
|
||||
try
|
||||
OnGetApplicationName := @FPPkgGetApplicationName;
|
||||
OnGetVendorName := @FPPkgGetVendorName;
|
||||
result := GetAppConfigFile(Global, SubDir);
|
||||
finally
|
||||
OnGetApplicationName := StoredOnGetApplicationName;
|
||||
OnGetVendorName := StoredOnGetVendorName;
|
||||
end;
|
||||
end;
|
||||
|
||||
function GetFppkgConfigDir(Global : Boolean): string;
|
||||
var
|
||||
StoredOnGetApplicationName: TGetAppNameEvent;
|
||||
StoredOnGetVendorName: TGetVendorNameEvent;
|
||||
begin
|
||||
StoredOnGetApplicationName := OnGetApplicationName;
|
||||
StoredOnGetVendorName := OnGetVendorName;
|
||||
try
|
||||
OnGetApplicationName := @FPPkgGetApplicationName;
|
||||
OnGetVendorName := @FPPkgGetVendorName;
|
||||
result := GetAppConfigDir(Global);
|
||||
finally
|
||||
OnGetApplicationName := StoredOnGetApplicationName;
|
||||
OnGetVendorName := StoredOnGetVendorName;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
initialization
|
||||
OnGetVendorName:=@FPPkgGetVendorName;
|
||||
OnGetApplicationName:=@FPPkgGetApplicationName;
|
||||
LogHandler := @LogCmd;
|
||||
ErrorHandler := @ErrorCmd;
|
||||
|
||||
end.
|
||||
|
@ -614,7 +614,7 @@ begin
|
||||
LocalRepository:='{UserDir}.fppkg/';
|
||||
{$else}
|
||||
if IsSuperUser then
|
||||
LocalRepository:=IncludeTrailingPathDelimiter(GetAppConfigDir(true))
|
||||
LocalRepository:=IncludeTrailingPathDelimiter(GetFppkgConfigDir(true))
|
||||
else
|
||||
LocalRepository:='{AppConfigDir}';
|
||||
{$endif}
|
||||
@ -754,7 +754,7 @@ end;
|
||||
constructor TFppkgOptions.Create;
|
||||
begin
|
||||
FOptionParser := TTemplateParser.Create;
|
||||
FOptionParser.Values['AppConfigDir'] := GetAppConfigDir(false);
|
||||
FOptionParser.Values['AppConfigDir'] := GetFppkgConfigDir(false);
|
||||
FOptionParser.Values['UserDir'] := GetUserDir;
|
||||
|
||||
FSectionList := TFppkgOptionSectionList.Create;
|
||||
@ -899,7 +899,7 @@ end;
|
||||
constructor TCompilerOptions.Create;
|
||||
begin
|
||||
FOptionParser := TTemplateParser.Create;
|
||||
FOptionParser.Values['AppConfigDir'] := GetAppConfigDir(false);
|
||||
FOptionParser.Values['AppConfigDir'] := GetFppkgConfigDir(false);
|
||||
FOptionParser.Values['UserDir'] := GetUserDir;
|
||||
{$ifdef unix}
|
||||
FLocalInstallDir:='{LocalPrefix}'+'lib'+PathDelim+'fpc'+PathDelim+'{CompilerVersion}'+PathDelim;
|
||||
|
Loading…
Reference in New Issue
Block a user