added check for additional compiler config biting the standard one

git-svn-id: trunk@6623 -
This commit is contained in:
mattias 2005-01-17 13:08:12 +00:00
parent 628659f24e
commit 7cfb7c62b7
4 changed files with 58 additions and 14 deletions

View File

@ -944,7 +944,7 @@ begin
CustomConfigFile := XMLConfigFile.GetValue(p+'ConfigFile/AdditionalConfigFile/Value', false) CustomConfigFile := XMLConfigFile.GetValue(p+'ConfigFile/AdditionalConfigFile/Value', false)
else else
CustomConfigFile := XMLConfigFile.GetValue(p+'ConfigFile/CustomConfigFile/Value', false); CustomConfigFile := XMLConfigFile.GetValue(p+'ConfigFile/CustomConfigFile/Value', false);
ConfigFilePath := f(XMLConfigFile.GetValue(p+'ConfigFile/ConfigFilePath/Value', './fpc.cfg')); ConfigFilePath := f(XMLConfigFile.GetValue(p+'ConfigFile/ConfigFilePath/Value', 'extrafpc.cfg'));
CustomOptions := XMLConfigFile.GetValue(p+'CustomOptions/Value', ''); CustomOptions := XMLConfigFile.GetValue(p+'CustomOptions/Value', '');
{ Compilation } { Compilation }
@ -1081,7 +1081,7 @@ begin
p:=Path+'Other/'; p:=Path+'Other/';
XMLConfigFile.SetDeleteValue(p+'ConfigFile/DontUseConfigFile/Value', DontUseConfigFile,false); XMLConfigFile.SetDeleteValue(p+'ConfigFile/DontUseConfigFile/Value', DontUseConfigFile,false);
XMLConfigFile.SetDeleteValue(p+'ConfigFile/CustomConfigFile/Value', CustomConfigFile,false); XMLConfigFile.SetDeleteValue(p+'ConfigFile/CustomConfigFile/Value', CustomConfigFile,false);
XMLConfigFile.SetDeleteValue(p+'ConfigFile/ConfigFilePath/Value', ConfigFilePath,'./fpc.cfg'); XMLConfigFile.SetDeleteValue(p+'ConfigFile/ConfigFilePath/Value', ConfigFilePath,'extrafpc.cfg');
XMLConfigFile.SetDeleteValue(p+'CustomOptions/Value', CustomOptions,''); XMLConfigFile.SetDeleteValue(p+'CustomOptions/Value', CustomOptions,'');
{ Compilation } { Compilation }
@ -1957,7 +1957,7 @@ begin
// other // other
fDontUseConfigFile := false; fDontUseConfigFile := false;
fCustomConfigFile := false; fCustomConfigFile := false;
fConfigFilePath := './fpc.cfg'; fConfigFilePath := 'extrafpc.cfg';
CustomOptions := ''; CustomOptions := '';
// inherited // inherited

View File

@ -276,8 +276,9 @@ type
procedure GetCompilerOptions; procedure GetCompilerOptions;
procedure GetCompilerOptions(SrcCompilerOptions: TBaseCompilerOptions); procedure GetCompilerOptions(SrcCompilerOptions: TBaseCompilerOptions);
procedure PutCompilerOptions; function PutCompilerOptions(CheckAndWarn: boolean): boolean;
procedure PutCompilerOptions(DestCompilerOptions: TBaseCompilerOptions); function PutCompilerOptions(CheckAndWarn: boolean;
DestCompilerOptions: TBaseCompilerOptions): boolean;
public public
property ReadOnly: boolean read FReadOnly write SetReadOnly; property ReadOnly: boolean read FReadOnly write SetReadOnly;
property OnTest: TNotifyEvent read FOnTest write FOnTest; property OnTest: TNotifyEvent read FOnTest write FOnTest;
@ -426,9 +427,9 @@ procedure TfrmCompilerOptions.ButtonOKClicked(Sender: TObject);
begin begin
// Accept any changes // Accept any changes
Assert(False, 'Trace:Accept compiler options changes'); Assert(False, 'Trace:Accept compiler options changes');
{ Save the options and hide the dialog } { Save the options and hide the dialog }
PutCompilerOptions; if not PutCompilerOptions(true) then exit;
ModalResult:=mrOk; ModalResult:=mrOk;
end; end;
@ -449,7 +450,7 @@ end;
procedure TfrmCompilerOptions.ButtonCheckClicked(Sender: TObject); procedure TfrmCompilerOptions.ButtonCheckClicked(Sender: TObject);
begin begin
// Apply any changes and test // Apply any changes and test
PutCompilerOptions; PutCompilerOptions(true);
if Assigned(OnTest) then begin if Assigned(OnTest) then begin
btnCheck.Enabled:=false; btnCheck.Enabled:=false;
try try
@ -470,7 +471,7 @@ var
CurOptions: String; CurOptions: String;
begin begin
// Test MakeOptionsString function // Test MakeOptionsString function
PutCompilerOptions; PutCompilerOptions(true);
CurOptions := CompilerOpts.MakeOptionsString(nil, CurOptions := CompilerOpts.MakeOptionsString(nil,
CompilerOpts.DefaultMakeOptionsFlags); CompilerOpts.DefaultMakeOptionsFlags);
DebugLn('CompilerOpts.MakeOptionsString: ' + CurOptions); DebugLn('CompilerOpts.MakeOptionsString: ' + CurOptions);
@ -835,8 +836,8 @@ end;
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
{ TfrmCompilerOptions PutCompilerOptions } { TfrmCompilerOptions PutCompilerOptions }
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
procedure TfrmCompilerOptions.PutCompilerOptions( function TfrmCompilerOptions.PutCompilerOptions(CheckAndWarn: boolean;
DestCompilerOptions: TBaseCompilerOptions); DestCompilerOptions: TBaseCompilerOptions): boolean;
function MakeCompileReasons(const ACompile, ABuild, ARun: TCheckBox): TCompileReasons; function MakeCompileReasons(const ACompile, ABuild, ARun: TCheckBox): TCompileReasons;
begin begin
@ -853,7 +854,13 @@ var
OldCompOpts: TBaseCompilerOptions; OldCompOpts: TBaseCompilerOptions;
NewTargetOS: String; NewTargetOS: String;
Options: TBaseCompilerOptions; Options: TBaseCompilerOptions;
NewDontUseConfigFile: Boolean;
NewCustomConfigFile: Boolean;
NewConfigFilePath: String;
AdditionalConfig: String;
begin begin
Result:=true;
{ Put the compiler options into the TCompilerOptions class to be saved } { Put the compiler options into the TCompilerOptions class to be saved }
if DestCompilerOptions<>nil then if DestCompilerOptions<>nil then
Options:=DestCompilerOptions Options:=DestCompilerOptions
@ -861,6 +868,35 @@ begin
Options:=CompilerOpts; Options:=CompilerOpts;
if ReadOnly and (Options=CompilerOpts) then exit; if ReadOnly and (Options=CompilerOpts) then exit;
NewDontUseConfigFile:=not chkConfigFile.Checked;
NewCustomConfigFile:=chkCustomConfigFile.Checked;
NewConfigFilePath:=edtConfigPath.Text;
if CheckAndWarn then begin
if ((NewDontUseConfigFile<>Options.DontUseConfigFile)
or (NewCustomConfigFile<>Options.CustomConfigFile)
or (NewConfigFilePath<>Options.ConfigFilePath))
and (not NewDontUseConfigFile) and NewCustomConfigFile
then begin
// config file options changed
// and both additional and standard config files are used
AdditionalConfig:=ExtractFilename(edtConfigPath.Text);
if (CompareFileNames(AdditionalConfig,'fpc.cfg')=0)
or (CompareFileNames(AdditionalConfig,'ppc386.cfg')=0)
then begin
if MessageDlg(lisCOAmbigiousAdditionalCompilerConfigFile,
Format(lisCOClickOKIfAreSureToDoThat, [BreakString(
lisCOWarningTheAdditionalCompilerConfigFileHasTheSameNa,
60, 0), #13#13]),
mtWarning,[mbOk,mbCancel],0)<>mrOk
then begin
Result:=false;
exit;
end;
end;
end;
end;
OldCompOpts := TBaseCompilerOptionsClass(Options.ClassType).Create(nil); OldCompOpts := TBaseCompilerOptionsClass(Options.ClassType).Create(nil);
OldCompOpts.Assign(Options); OldCompOpts.Assign(Options);
@ -1029,9 +1065,9 @@ begin
OldCompOpts.Free; OldCompOpts.Free;
end; end;
procedure TfrmCompilerOptions.PutCompilerOptions; function TfrmCompilerOptions.PutCompilerOptions(CheckAndWarn: boolean): boolean;
begin begin
PutCompilerOptions(nil); Result:=PutCompilerOptions(CheckAndWarn,nil);
end; end;
procedure TfrmCompilerOptions.UpdateInheritedTab; procedure TfrmCompilerOptions.UpdateInheritedTab;

View File

@ -149,7 +149,7 @@ begin
if (CompOptsDialog<>nil) then begin if (CompOptsDialog<>nil) then begin
CompilerOpts:=TBaseCompilerOptions.Create(nil); CompilerOpts:=TBaseCompilerOptions.Create(nil);
FreeCompilerOpts:=true; FreeCompilerOpts:=true;
CompOptsDialog.PutCompilerOptions(CompilerOpts); CompOptsDialog.PutCompilerOptions(true,CompilerOpts);
end; end;
try try
Result:=mrCancel; Result:=mrCancel;

View File

@ -966,6 +966,14 @@ resourcestring
lisCompiler = 'Compiler'; lisCompiler = 'Compiler';
lisToFPCPath = 'Path:'; lisToFPCPath = 'Path:';
lisCOSkipCallingCompiler = 'Skip calling Compiler'; lisCOSkipCallingCompiler = 'Skip calling Compiler';
lisCOAmbigiousAdditionalCompilerConfigFile = 'Ambigious additional compiler '
+'config file';
lisCOWarningTheAdditionalCompilerConfigFileHasTheSameNa = 'Warning: The '
+'additional compiler config file has the same name, as one of the '
+'standard config filenames the FreePascal compiler is looking for. This '
+'can result in ONLY parsing the additional config and skipping the '
+'standard config.';
lisCOClickOKIfAreSureToDoThat = '%s%sClick OK if are sure to do that.';
lisCOCallOn = 'Call on:'; lisCOCallOn = 'Call on:';
lisCOCallOnCompile = 'Compile'; lisCOCallOnCompile = 'Compile';
lisCOCallOnBuild = 'Build'; lisCOCallOnBuild = 'Build';