mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-18 01:29:21 +02:00
* Do not try to write a fppkg compiler-configuration file when the
fppkg.cfg file has not been written, but raise an error instead. git-svn-id: trunk@40711 -
This commit is contained in:
parent
1641585655
commit
d63f6ad9d5
@ -211,18 +211,22 @@ begin
|
|||||||
if FileExists(S) then
|
if FileExists(S) then
|
||||||
begin
|
begin
|
||||||
pkgglobals.Log(llDebug,SLogLoadingCompilerConfig,[S]);
|
pkgglobals.Log(llDebug,SLogLoadingCompilerConfig,[S]);
|
||||||
FCompilerOptions.LoadCompilerFromFile(S)
|
FCompilerOptions.LoadCompilerFromFile(S);
|
||||||
|
if FCompilerOptions.SaveInifileChanges then
|
||||||
|
// The file is in an old format, try to update the file but ignore
|
||||||
|
// any failures.
|
||||||
|
FCompilerOptions.SaveCompilerToFile(S);
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
// Generate a default configuration if it doesn't exists
|
if FCompilerOptions.SaveInifileChanges then
|
||||||
if FOptions.GlobalSection.CompilerConfig='default' then
|
// A new fppkg.cfg has been created, try to create a new compiler-configuration
|
||||||
|
// file too.
|
||||||
begin
|
begin
|
||||||
pkgglobals.Log(llDebug,SLogGeneratingCompilerConfig,[S]);
|
pkgglobals.Log(llDebug,SLogGeneratingCompilerConfig,[S]);
|
||||||
FCompilerOptions.InitCompilerDefaults;
|
FCompilerOptions.InitCompilerDefaults;
|
||||||
FCompilerOptions.SaveCompilerToFile(S);
|
if not FCompilerOptions.SaveCompilerToFile(S) then
|
||||||
if FCompilerOptions.SaveInifileChanges then
|
Error(SErrMissingCompilerConfig,[S]);
|
||||||
FCompilerOptions.SaveCompilerToFile(S);
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
Error(SErrMissingCompilerConfig,[S]);
|
Error(SErrMissingCompilerConfig,[S]);
|
||||||
@ -237,6 +241,8 @@ begin
|
|||||||
pkgglobals.Log(llDebug,SLogLoadingFPMakeCompilerConfig,[S]);
|
pkgglobals.Log(llDebug,SLogLoadingFPMakeCompilerConfig,[S]);
|
||||||
FFPMakeCompilerOptions.LoadCompilerFromFile(S);
|
FFPMakeCompilerOptions.LoadCompilerFromFile(S);
|
||||||
if FFPMakeCompilerOptions.SaveInifileChanges then
|
if FFPMakeCompilerOptions.SaveInifileChanges then
|
||||||
|
// The file is in an old format, try to update the file but ignore
|
||||||
|
// any failures.
|
||||||
FFPMakeCompilerOptions.SaveCompilerToFile(S);
|
FFPMakeCompilerOptions.SaveCompilerToFile(S);
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
@ -163,6 +163,7 @@ Resourcestring
|
|||||||
SDbgPackageInstallRequired = 'Installation of package "%s" required for repository "%s"';
|
SDbgPackageInstallRequired = 'Installation of package "%s" required for repository "%s"';
|
||||||
|
|
||||||
SWarnBrokenAfterReinstall = 'Package %s is still broken, even after re-installation. (%s)';
|
SWarnBrokenAfterReinstall = 'Package %s is still broken, even after re-installation. (%s)';
|
||||||
|
SWarnFailedToWriteCompConf = 'Failed to write compiler-configuration file "%s": %s';
|
||||||
|
|
||||||
SProgrReinstallDependent = 'Re-install packages which are dependent on just installed packages';
|
SProgrReinstallDependent = 'Re-install packages which are dependent on just installed packages';
|
||||||
SProgrInstallDependencies = 'Install dependencies';
|
SProgrInstallDependencies = 'Install dependencies';
|
||||||
|
@ -246,7 +246,7 @@ Type
|
|||||||
Destructor Destroy; override;
|
Destructor Destroy; override;
|
||||||
Procedure InitCompilerDefaults;
|
Procedure InitCompilerDefaults;
|
||||||
Procedure LoadCompilerFromFile(const AFileName : String);
|
Procedure LoadCompilerFromFile(const AFileName : String);
|
||||||
Procedure SaveCompilerToFile(const AFileName : String);
|
function SaveCompilerToFile(const AFileName : String): Boolean;
|
||||||
procedure LogValues(ALogLevel: TLogLevel; const ACfgName:string);
|
procedure LogValues(ALogLevel: TLogLevel; const ACfgName:string);
|
||||||
procedure UpdateLocalRepositoryOption(FppkgOptions: TFppkgOptions);
|
procedure UpdateLocalRepositoryOption(FppkgOptions: TFppkgOptions);
|
||||||
procedure CheckCompilerValues;
|
procedure CheckCompilerValues;
|
||||||
@ -984,6 +984,7 @@ begin
|
|||||||
FOptionParser := TTemplateParser.Create;
|
FOptionParser := TTemplateParser.Create;
|
||||||
FOptionParser.Values['AppConfigDir'] := GetFppkgConfigDir(false);
|
FOptionParser.Values['AppConfigDir'] := GetFppkgConfigDir(false);
|
||||||
FOptionParser.Values['UserDir'] := GetUserDir;
|
FOptionParser.Values['UserDir'] := GetUserDir;
|
||||||
|
FSaveInifileChanges := True;
|
||||||
{$ifdef unix}
|
{$ifdef unix}
|
||||||
FLocalInstallDir:='{LocalPrefix}'+'lib'+PathDelim+'fpc'+PathDelim+'{CompilerVersion}'+PathDelim;
|
FLocalInstallDir:='{LocalPrefix}'+'lib'+PathDelim+'fpc'+PathDelim+'{CompilerVersion}'+PathDelim;
|
||||||
FGlobalInstallDir:='{GlobalPrefix}'+'lib'+PathDelim+'fpc'+PathDelim+'{CompilerVersion}'+PathDelim;
|
FGlobalInstallDir:='{GlobalPrefix}'+'lib'+PathDelim+'fpc'+PathDelim+'{CompilerVersion}'+PathDelim;
|
||||||
@ -1175,6 +1176,10 @@ begin
|
|||||||
FSaveInifileChanges:=true;
|
FSaveInifileChanges:=true;
|
||||||
if (FConfigVersion>CurrentConfigVersion) then
|
if (FConfigVersion>CurrentConfigVersion) then
|
||||||
Error(SErrUnsupportedConfigVersion,[AFileName]);
|
Error(SErrUnsupportedConfigVersion,[AFileName]);
|
||||||
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
FSaveInifileChanges:=False;
|
||||||
end;
|
end;
|
||||||
GlobalPrefix:=ReadString(SDefaults,KeyGlobalPrefix,FGlobalPrefix);
|
GlobalPrefix:=ReadString(SDefaults,KeyGlobalPrefix,FGlobalPrefix);
|
||||||
LocalPrefix:=ReadString(SDefaults,KeyLocalPrefix,FLocalPrefix);
|
LocalPrefix:=ReadString(SDefaults,KeyLocalPrefix,FLocalPrefix);
|
||||||
@ -1191,30 +1196,37 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure TCompilerOptions.SaveCompilerToFile(const AFileName: String);
|
function TCompilerOptions.SaveCompilerToFile(const AFileName: String): Boolean;
|
||||||
Var
|
Var
|
||||||
Ini : TIniFile;
|
Ini : TIniFile;
|
||||||
begin
|
begin
|
||||||
if FileExists(AFileName) then
|
Result := False;
|
||||||
BackupFile(AFileName);
|
|
||||||
Ini:=TIniFile.Create(AFileName);
|
|
||||||
try
|
try
|
||||||
With Ini do
|
if FileExists(AFileName) then
|
||||||
begin
|
BackupFile(AFileName);
|
||||||
WriteInteger(SDefaults,KeyConfigVersion,CurrentConfigVersion);
|
Ini:=TIniFile.Create(AFileName);
|
||||||
WriteString(SDefaults,KeyGlobalPrefix,FGlobalPrefix);
|
try
|
||||||
WriteString(SDefaults,KeyLocalPrefix,FLocalPrefix);
|
With Ini do
|
||||||
WriteString(SDefaults,KeyGlobalInstallDir,FGlobalInstallDir);
|
begin
|
||||||
WriteString(SDefaults,KeyLocalInstallDir,FLocalInstallDir);
|
WriteInteger(SDefaults,KeyConfigVersion,CurrentConfigVersion);
|
||||||
WriteString(SDefaults,KeyCompiler,FCompiler);
|
WriteString(SDefaults,KeyGlobalPrefix,FGlobalPrefix);
|
||||||
WriteString(SDefaults,KeyCompilerOS,OSToString(CompilerOS));
|
WriteString(SDefaults,KeyLocalPrefix,FLocalPrefix);
|
||||||
WriteString(SDefaults,KeyCompilerCPU,CPUtoString(CompilerCPU));
|
WriteString(SDefaults,KeyGlobalInstallDir,FGlobalInstallDir);
|
||||||
WriteString(SDefaults,KeyCompilerVersion,FCompilerVersion);
|
WriteString(SDefaults,KeyLocalInstallDir,FLocalInstallDir);
|
||||||
FSaveInifileChanges:=False;
|
WriteString(SDefaults,KeyCompiler,FCompiler);
|
||||||
end;
|
WriteString(SDefaults,KeyCompilerOS,OSToString(CompilerOS));
|
||||||
Ini.UpdateFile;
|
WriteString(SDefaults,KeyCompilerCPU,CPUtoString(CompilerCPU));
|
||||||
finally
|
WriteString(SDefaults,KeyCompilerVersion,FCompilerVersion);
|
||||||
Ini.Free;
|
FSaveInifileChanges:=False;
|
||||||
|
end;
|
||||||
|
Ini.UpdateFile;
|
||||||
|
finally
|
||||||
|
Ini.Free;
|
||||||
|
end;
|
||||||
|
Result := True;
|
||||||
|
except
|
||||||
|
on E: Exception do
|
||||||
|
log(llWarning, SWarnFailedToWriteCompConf, [AFileName, E.Message]);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user