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)
else
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', '');
{ Compilation }
@ -1081,7 +1081,7 @@ begin
p:=Path+'Other/';
XMLConfigFile.SetDeleteValue(p+'ConfigFile/DontUseConfigFile/Value', DontUseConfigFile,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,'');
{ Compilation }
@ -1957,7 +1957,7 @@ begin
// other
fDontUseConfigFile := false;
fCustomConfigFile := false;
fConfigFilePath := './fpc.cfg';
fConfigFilePath := 'extrafpc.cfg';
CustomOptions := '';
// inherited

View File

@ -276,8 +276,9 @@ type
procedure GetCompilerOptions;
procedure GetCompilerOptions(SrcCompilerOptions: TBaseCompilerOptions);
procedure PutCompilerOptions;
procedure PutCompilerOptions(DestCompilerOptions: TBaseCompilerOptions);
function PutCompilerOptions(CheckAndWarn: boolean): boolean;
function PutCompilerOptions(CheckAndWarn: boolean;
DestCompilerOptions: TBaseCompilerOptions): boolean;
public
property ReadOnly: boolean read FReadOnly write SetReadOnly;
property OnTest: TNotifyEvent read FOnTest write FOnTest;
@ -426,9 +427,9 @@ procedure TfrmCompilerOptions.ButtonOKClicked(Sender: TObject);
begin
// Accept any changes
Assert(False, 'Trace:Accept compiler options changes');
{ Save the options and hide the dialog }
PutCompilerOptions;
if not PutCompilerOptions(true) then exit;
ModalResult:=mrOk;
end;
@ -449,7 +450,7 @@ end;
procedure TfrmCompilerOptions.ButtonCheckClicked(Sender: TObject);
begin
// Apply any changes and test
PutCompilerOptions;
PutCompilerOptions(true);
if Assigned(OnTest) then begin
btnCheck.Enabled:=false;
try
@ -470,7 +471,7 @@ var
CurOptions: String;
begin
// Test MakeOptionsString function
PutCompilerOptions;
PutCompilerOptions(true);
CurOptions := CompilerOpts.MakeOptionsString(nil,
CompilerOpts.DefaultMakeOptionsFlags);
DebugLn('CompilerOpts.MakeOptionsString: ' + CurOptions);
@ -835,8 +836,8 @@ end;
{------------------------------------------------------------------------------}
{ TfrmCompilerOptions PutCompilerOptions }
{------------------------------------------------------------------------------}
procedure TfrmCompilerOptions.PutCompilerOptions(
DestCompilerOptions: TBaseCompilerOptions);
function TfrmCompilerOptions.PutCompilerOptions(CheckAndWarn: boolean;
DestCompilerOptions: TBaseCompilerOptions): boolean;
function MakeCompileReasons(const ACompile, ABuild, ARun: TCheckBox): TCompileReasons;
begin
@ -853,7 +854,13 @@ var
OldCompOpts: TBaseCompilerOptions;
NewTargetOS: String;
Options: TBaseCompilerOptions;
NewDontUseConfigFile: Boolean;
NewCustomConfigFile: Boolean;
NewConfigFilePath: String;
AdditionalConfig: String;
begin
Result:=true;
{ Put the compiler options into the TCompilerOptions class to be saved }
if DestCompilerOptions<>nil then
Options:=DestCompilerOptions
@ -861,6 +868,35 @@ begin
Options:=CompilerOpts;
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.Assign(Options);
@ -1029,9 +1065,9 @@ begin
OldCompOpts.Free;
end;
procedure TfrmCompilerOptions.PutCompilerOptions;
function TfrmCompilerOptions.PutCompilerOptions(CheckAndWarn: boolean): boolean;
begin
PutCompilerOptions(nil);
Result:=PutCompilerOptions(CheckAndWarn,nil);
end;
procedure TfrmCompilerOptions.UpdateInheritedTab;

View File

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

View File

@ -966,6 +966,14 @@ resourcestring
lisCompiler = 'Compiler';
lisToFPCPath = 'Path:';
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:';
lisCOCallOnCompile = 'Compile';
lisCOCallOnBuild = 'Build';