IDE: GetParsedFPCSourceDirerectory: use GetParsedValue

git-svn-id: trunk@36055 -
This commit is contained in:
mattias 2012-03-16 00:53:28 +00:00
parent 119fa0682e
commit 68d89b080f
2 changed files with 41 additions and 18 deletions

View File

@ -265,9 +265,6 @@ type
FCompilerFilenameParsed: string; FCompilerFilenameParsed: string;
FCompilerFilenameParsedStamp: integer; FCompilerFilenameParsedStamp: integer;
FCompilerFileHistory: TStringList; FCompilerFileHistory: TStringList;
FFPCSourceDirectory: string;
FFPCSrcDirParsed: string;
FFPCSrcDirParsedStamp: integer;
FFPCSourceDirHistory: TStringList; FFPCSourceDirHistory: TStringList;
FMakeFileName: string; FMakeFileName: string;
FMakeFileHistory: TStringList; FMakeFileHistory: TStringList;
@ -335,6 +332,7 @@ type
FFileDialogFilter: string; FFileDialogFilter: string;
function GetDebuggerEventLogColors(AIndex: TDBGEventType): TDebuggerEventLogColor; function GetDebuggerEventLogColors(AIndex: TDBGEventType): TDebuggerEventLogColor;
function GetFPCSourceDirectory: string;
function GetLazarusDirectory: string; function GetLazarusDirectory: string;
procedure SetCompilerFilename(const AValue: string); procedure SetCompilerFilename(const AValue: string);
procedure SetDebuggerEventLogColors(AIndex: TDBGEventType; procedure SetDebuggerEventLogColors(AIndex: TDBGEventType;
@ -484,7 +482,7 @@ type
write SetCompilerFilename; write SetCompilerFilename;
property CompilerFileHistory: TStringList read FCompilerFileHistory property CompilerFileHistory: TStringList read FCompilerFileHistory
write FCompilerFileHistory; write FCompilerFileHistory;
property FPCSourceDirectory: string read FFPCSourceDirectory property FPCSourceDirectory: string read GetFPCSourceDirectory
write SetFPCSourceDirectory; write SetFPCSourceDirectory;
property FPCSourceDirHistory: TStringList read FFPCSourceDirHistory property FPCSourceDirHistory: TStringList read FFPCSourceDirHistory
write FFPCSourceDirHistory; write FFPCSourceDirHistory;
@ -743,8 +741,12 @@ end;
{ TEnvironmentOptions } { TEnvironmentOptions }
constructor TEnvironmentOptions.Create; constructor TEnvironmentOptions.Create;
var
o: TEnvOptParseType;
begin begin
inherited Create; inherited Create;
for o:=low(FParseValues) to high(FParseValues) do
FParseValues[o].ParseStamp:=CTInvalidChangeStamp;
FFilename:=''; FFilename:='';
@ -823,7 +825,6 @@ begin
FCompilerFilenameParsedStamp:=CTInvalidChangeStamp; FCompilerFilenameParsedStamp:=CTInvalidChangeStamp;
FCompilerFileHistory:=TStringList.Create; FCompilerFileHistory:=TStringList.Create;
FPCSourceDirectory:=''; FPCSourceDirectory:='';
FFPCSrcDirParsedStamp:=CTInvalidChangeStamp;
FFPCSourceDirHistory:=TStringList.Create; FFPCSourceDirHistory:=TStringList.Create;
MakeFilename:=''; MakeFilename:='';
FMakeFileHistory:=TStringList.Create; FMakeFileHistory:=TStringList.Create;
@ -1133,7 +1134,7 @@ begin
if FCompilerFileHistory.Count=0 then if FCompilerFileHistory.Count=0 then
GetDefaultCompilerFilenames(FCompilerFileHistory); GetDefaultCompilerFilenames(FCompilerFileHistory);
FPCSourceDirectory:=XMLConfig.GetValue( FPCSourceDirectory:=XMLConfig.GetValue(
Path+'FPCSourceDirectory/Value',FFPCSourceDirectory); Path+'FPCSourceDirectory/Value',FPCSourceDirectory);
LoadRecentList(XMLConfig,FFPCSourceDirHistory, LoadRecentList(XMLConfig,FFPCSourceDirHistory,
Path+'FPCSourceDirectory/History/'); Path+'FPCSourceDirectory/History/');
if FFPCSourceDirHistory.Count=0 then begin if FFPCSourceDirHistory.Count=0 then begin
@ -1477,7 +1478,7 @@ begin
SaveRecentList(XMLConfig,FCompilerFileHistory, SaveRecentList(XMLConfig,FCompilerFileHistory,
Path+'CompilerFilename/History/'); Path+'CompilerFilename/History/');
XMLConfig.SetValue( XMLConfig.SetValue(
Path+'FPCSourceDirectory/Value',FFPCSourceDirectory); Path+'FPCSourceDirectory/Value',FPCSourceDirectory);
SaveRecentList(XMLConfig,FFPCSourceDirHistory, SaveRecentList(XMLConfig,FFPCSourceDirHistory,
Path+'FPCSourceDirectory/History/'); Path+'FPCSourceDirectory/History/');
XMLConfig.SetDeleteValue( XMLConfig.SetDeleteValue(
@ -1686,14 +1687,7 @@ end;
function TEnvironmentOptions.GetParsedFPCSourceDirectory: string; function TEnvironmentOptions.GetParsedFPCSourceDirectory: string;
begin begin
if (FFPCSrcDirParsedStamp=CTInvalidChangeStamp) Result:=GetParsedValue(eopFPCSourceDirectory);
or (FFPCSrcDirParsedStamp<>CompilerParseStamp)
then begin
FFPCSrcDirParsed:=FFPCSourceDirectory;
GlobalMacroList.SubstituteStr(FFPCSrcDirParsed);
FFPCSrcDirParsedStamp:=CompilerParseStamp;
end;
Result:=FFPCSrcDirParsed;
end; end;
function TEnvironmentOptions.GetParsedValue(o: TEnvOptParseType): string; function TEnvironmentOptions.GetParsedValue(o: TEnvOptParseType): string;
@ -1710,6 +1704,30 @@ begin
ParsedValue:=UnparsedValue; ParsedValue:=UnparsedValue;
GlobalMacroList.SubstituteStr(ParsedValue); GlobalMacroList.SubstituteStr(ParsedValue);
ParseStamp:=CompilerParseStamp; ParseStamp:=CompilerParseStamp;
case o of
eopLazarusDirectory,eopFPCSourceDirectory,eopTestBuildDirectory:
// directory
ParsedValue:=TrimAndExpandDirectory(ParsedValue,GetParsedLazarusDirectory);
eopCompilerMessagesFilename:
// data file
ParsedValue:=TrimAndExpandFilename(ParsedValue,GetParsedLazarusDirectory);
eopDebuggerSearchPath,eopFPDocPaths:
// search path
ParsedValue:=TrimSearchPath(ParsedValue,GetParsedLazarusDirectory,true);
eopCompilerFilename,eopDebuggerFilename,eopMakeFilename:
// program
begin
ParsedValue:=TrimFilename(ParsedValue);
if (ParsedValue<>'') and (not FilenameIsAbsolute(ParsedValue)) then
begin
if ExtractFilePath(ParsedValue)='' then
ParsedValue:=FindDefaultExecutablePath(ParsedValue)
else
ParsedValue:=GetParsedLazarusDirectory+ParsedValue;
end;
end;
end;
finally finally
Parsing:=false; Parsing:=false;
end; end;
@ -1909,9 +1927,8 @@ end;
procedure TEnvironmentOptions.SetFPCSourceDirectory(const AValue: string); procedure TEnvironmentOptions.SetFPCSourceDirectory(const AValue: string);
begin begin
if FFPCSourceDirectory=AValue then exit; if FPCSourceDirectory=AValue then exit;
FFPCSourceDirectory:=AppendPathDelim(TrimFilename(AValue)); SetParseValue(eopFPCSourceDirectory,AValue);
FFPCSrcDirParsedStamp:=CTInvalidChangeStamp;
end; end;
procedure TEnvironmentOptions.SetCompilerFilename(const AValue: string); procedure TEnvironmentOptions.SetCompilerFilename(const AValue: string);
@ -1926,6 +1943,11 @@ begin
Result := FDebuggerEventLogColors[AIndex]; Result := FDebuggerEventLogColors[AIndex];
end; end;
function TEnvironmentOptions.GetFPCSourceDirectory: string;
begin
Result:=FParseValues[eopFPCSourceDirectory].UnparsedValue;
end;
function TEnvironmentOptions.GetLazarusDirectory: string; function TEnvironmentOptions.GetLazarusDirectory: string;
begin begin
Result:=FParseValues[eopLazarusDirectory].UnparsedValue; Result:=FParseValues[eopLazarusDirectory].UnparsedValue;

View File

@ -216,6 +216,7 @@ begin
Result:=SearchFileInPath(Executable,'', Result:=SearchFileInPath(Executable,'',
GetEnvironmentVariableUTF8('PATH'),':', GetEnvironmentVariableUTF8('PATH'),':',
[sffDontSearchInBasePath]); [sffDontSearchInBasePath]);
Result:=TrimFilename(Result);
end; end;
function GetDefaultLCLWidgetType: TLCLPlatform; function GetDefaultLCLWidgetType: TLCLPlatform;