mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-07 12:07:58 +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
|
||||
begin
|
||||
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
|
||||
else
|
||||
begin
|
||||
// Generate a default configuration if it doesn't exists
|
||||
if FOptions.GlobalSection.CompilerConfig='default' then
|
||||
if FCompilerOptions.SaveInifileChanges then
|
||||
// A new fppkg.cfg has been created, try to create a new compiler-configuration
|
||||
// file too.
|
||||
begin
|
||||
pkgglobals.Log(llDebug,SLogGeneratingCompilerConfig,[S]);
|
||||
FCompilerOptions.InitCompilerDefaults;
|
||||
FCompilerOptions.SaveCompilerToFile(S);
|
||||
if FCompilerOptions.SaveInifileChanges then
|
||||
FCompilerOptions.SaveCompilerToFile(S);
|
||||
if not FCompilerOptions.SaveCompilerToFile(S) then
|
||||
Error(SErrMissingCompilerConfig,[S]);
|
||||
end
|
||||
else
|
||||
Error(SErrMissingCompilerConfig,[S]);
|
||||
@ -237,6 +241,8 @@ begin
|
||||
pkgglobals.Log(llDebug,SLogLoadingFPMakeCompilerConfig,[S]);
|
||||
FFPMakeCompilerOptions.LoadCompilerFromFile(S);
|
||||
if FFPMakeCompilerOptions.SaveInifileChanges then
|
||||
// The file is in an old format, try to update the file but ignore
|
||||
// any failures.
|
||||
FFPMakeCompilerOptions.SaveCompilerToFile(S);
|
||||
end
|
||||
else
|
||||
|
@ -163,6 +163,7 @@ Resourcestring
|
||||
SDbgPackageInstallRequired = 'Installation of package "%s" required for repository "%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';
|
||||
SProgrInstallDependencies = 'Install dependencies';
|
||||
|
@ -246,7 +246,7 @@ Type
|
||||
Destructor Destroy; override;
|
||||
Procedure InitCompilerDefaults;
|
||||
Procedure LoadCompilerFromFile(const AFileName : String);
|
||||
Procedure SaveCompilerToFile(const AFileName : String);
|
||||
function SaveCompilerToFile(const AFileName : String): Boolean;
|
||||
procedure LogValues(ALogLevel: TLogLevel; const ACfgName:string);
|
||||
procedure UpdateLocalRepositoryOption(FppkgOptions: TFppkgOptions);
|
||||
procedure CheckCompilerValues;
|
||||
@ -984,6 +984,7 @@ begin
|
||||
FOptionParser := TTemplateParser.Create;
|
||||
FOptionParser.Values['AppConfigDir'] := GetFppkgConfigDir(false);
|
||||
FOptionParser.Values['UserDir'] := GetUserDir;
|
||||
FSaveInifileChanges := True;
|
||||
{$ifdef unix}
|
||||
FLocalInstallDir:='{LocalPrefix}'+'lib'+PathDelim+'fpc'+PathDelim+'{CompilerVersion}'+PathDelim;
|
||||
FGlobalInstallDir:='{GlobalPrefix}'+'lib'+PathDelim+'fpc'+PathDelim+'{CompilerVersion}'+PathDelim;
|
||||
@ -1175,6 +1176,10 @@ begin
|
||||
FSaveInifileChanges:=true;
|
||||
if (FConfigVersion>CurrentConfigVersion) then
|
||||
Error(SErrUnsupportedConfigVersion,[AFileName]);
|
||||
end
|
||||
else
|
||||
begin
|
||||
FSaveInifileChanges:=False;
|
||||
end;
|
||||
GlobalPrefix:=ReadString(SDefaults,KeyGlobalPrefix,FGlobalPrefix);
|
||||
LocalPrefix:=ReadString(SDefaults,KeyLocalPrefix,FLocalPrefix);
|
||||
@ -1191,30 +1196,37 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
procedure TCompilerOptions.SaveCompilerToFile(const AFileName: String);
|
||||
function TCompilerOptions.SaveCompilerToFile(const AFileName: String): Boolean;
|
||||
Var
|
||||
Ini : TIniFile;
|
||||
begin
|
||||
if FileExists(AFileName) then
|
||||
BackupFile(AFileName);
|
||||
Ini:=TIniFile.Create(AFileName);
|
||||
Result := False;
|
||||
try
|
||||
With Ini do
|
||||
begin
|
||||
WriteInteger(SDefaults,KeyConfigVersion,CurrentConfigVersion);
|
||||
WriteString(SDefaults,KeyGlobalPrefix,FGlobalPrefix);
|
||||
WriteString(SDefaults,KeyLocalPrefix,FLocalPrefix);
|
||||
WriteString(SDefaults,KeyGlobalInstallDir,FGlobalInstallDir);
|
||||
WriteString(SDefaults,KeyLocalInstallDir,FLocalInstallDir);
|
||||
WriteString(SDefaults,KeyCompiler,FCompiler);
|
||||
WriteString(SDefaults,KeyCompilerOS,OSToString(CompilerOS));
|
||||
WriteString(SDefaults,KeyCompilerCPU,CPUtoString(CompilerCPU));
|
||||
WriteString(SDefaults,KeyCompilerVersion,FCompilerVersion);
|
||||
FSaveInifileChanges:=False;
|
||||
end;
|
||||
Ini.UpdateFile;
|
||||
finally
|
||||
Ini.Free;
|
||||
if FileExists(AFileName) then
|
||||
BackupFile(AFileName);
|
||||
Ini:=TIniFile.Create(AFileName);
|
||||
try
|
||||
With Ini do
|
||||
begin
|
||||
WriteInteger(SDefaults,KeyConfigVersion,CurrentConfigVersion);
|
||||
WriteString(SDefaults,KeyGlobalPrefix,FGlobalPrefix);
|
||||
WriteString(SDefaults,KeyLocalPrefix,FLocalPrefix);
|
||||
WriteString(SDefaults,KeyGlobalInstallDir,FGlobalInstallDir);
|
||||
WriteString(SDefaults,KeyLocalInstallDir,FLocalInstallDir);
|
||||
WriteString(SDefaults,KeyCompiler,FCompiler);
|
||||
WriteString(SDefaults,KeyCompilerOS,OSToString(CompilerOS));
|
||||
WriteString(SDefaults,KeyCompilerCPU,CPUtoString(CompilerCPU));
|
||||
WriteString(SDefaults,KeyCompilerVersion,FCompilerVersion);
|
||||
FSaveInifileChanges:=False;
|
||||
end;
|
||||
Ini.UpdateFile;
|
||||
finally
|
||||
Ini.Free;
|
||||
end;
|
||||
Result := True;
|
||||
except
|
||||
on E: Exception do
|
||||
log(llWarning, SWarnFailedToWriteCompConf, [AFileName, E.Message]);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user