From eeb043e59e821d70e8af7bd8cd045418dd5f9952 Mon Sep 17 00:00:00 2001 From: mattias Date: Mon, 19 Jul 2010 12:19:30 +0000 Subject: [PATCH] codetools: TCodeToolsOptions.InitWithEnvironmentVariables: search for default git-svn-id: trunk@26736 - --- components/codetools/codetoolsconfig.pas | 6 ++--- components/codetools/definetemplates.pas | 6 ++--- .../codetools/examples/finddeclaration.lpr | 22 +++++-------------- 3 files changed, 10 insertions(+), 24 deletions(-) diff --git a/components/codetools/codetoolsconfig.pas b/components/codetools/codetoolsconfig.pas index 7e59b9e9cf..7e77868846 100644 --- a/components/codetools/codetoolsconfig.pas +++ b/components/codetools/codetoolsconfig.pas @@ -297,10 +297,10 @@ end; procedure TCodeToolsOptions.InitWithEnvironmentVariables; begin - if FPCPath='' then - FPCPath:=FindDefaultCompilerFilename; if GetEnvironmentVariableUTF8('PP')<>'' then - FPCPath:=GetEnvironmentVariableUTF8('PP'); + FPCPath:=GetEnvironmentVariableUTF8('PP') + else if (FPCPath='') or not FileExistsCached(FPCPath) then + FPCPath:=FindDefaultCompilerFilename; if GetEnvironmentVariableUTF8('FPCDIR')<>'' then FPCSrcDir:=GetEnvironmentVariableUTF8('FPCDIR'); if GetEnvironmentVariableUTF8('LAZARUSDIR')<>'' then diff --git a/components/codetools/definetemplates.pas b/components/codetools/definetemplates.pas index ddda17e569..f7c3d8cbee 100644 --- a/components/codetools/definetemplates.pas +++ b/components/codetools/definetemplates.pas @@ -1242,7 +1242,7 @@ function ParseFPCVerbose(List: TStrings; out ConfigFiles: TSTrings; i, len, CurPos: integer; Filename: String; begin - DebugLn(['ProcessOutputLine ',Line]); + //DebugLn(['ProcessOutputLine ',Line]); len := length(Line); if len <= 6 then Exit; // shortest match @@ -8175,7 +8175,7 @@ var begin ParseUnitSetID(UnitSetID,CompilerFilename, TargetOS, TargetCPU, Options, FPCSrcDir, ChangeStamp); - debugln(['TFPCDefinesCache.FindUnitToSrcCache UnitSetID="',dbgstr(UnitSetID),'" CompilerFilename="',CompilerFilename,'" TargetOS="',TargetOS,'" TargetCPU="',TargetCPU,'" Options="',Options,'" FPCSrcDir="',FPCSrcDir,'" ChangeStamp=',ChangeStamp,' exists=',FindUnitToSrcCache(CompilerFilename, TargetOS, TargetCPU,Options, FPCSrcDir,false)<>nil]); + //debugln(['TFPCDefinesCache.FindUnitToSrcCache UnitSetID="',dbgstr(UnitSetID),'" CompilerFilename="',CompilerFilename,'" TargetOS="',TargetOS,'" TargetCPU="',TargetCPU,'" Options="',Options,'" FPCSrcDir="',FPCSrcDir,'" ChangeStamp=',ChangeStamp,' exists=',FindUnitToSrcCache(CompilerFilename, TargetOS, TargetCPU,Options, FPCSrcDir,false)<>nil]); Result:=FindUnitToSrcCache(CompilerFilename, TargetOS, TargetCPU, Options, FPCSrcDir, false); if Result<>nil then begin @@ -8427,7 +8427,6 @@ begin if (fuscfUnitTreeNeedsUpdate in fFlags) or (fUnitStampOfFiles<>Src.ChangeStamp) or (fUnitStampOfRules<>SrcRules.ChangeStamp) then begin - debugln(['TFPCUnitSetCache.GetUnitToSourceTree START ChangeStamp=',ChangeStamp]); Exclude(fFlags,fuscfUnitTreeNeedsUpdate); NewSrcDuplicates:=nil; NewUnitToSourceTree:=nil; @@ -8451,7 +8450,6 @@ begin NewUnitToSourceTree.Free; NewSrcDuplicates.Free; end; - debugln(['TFPCUnitSetCache.GetUnitToSourceTree END ChangeStamp=',ChangeStamp]); end; Result:=fUnitToSourceTree; end; diff --git a/components/codetools/examples/finddeclaration.lpr b/components/codetools/examples/finddeclaration.lpr index 1981da54ad..6e408f786c 100644 --- a/components/codetools/examples/finddeclaration.lpr +++ b/components/codetools/examples/finddeclaration.lpr @@ -58,24 +58,12 @@ begin if FileExists(ConfigFilename) then begin // To not parse the FPC sources every time, the options are saved to a file. Options.LoadFromFile(ConfigFilename); - end else begin - Options.InitWithEnvironmentVariables; - if Options.FPCPath='' then - Options.FPCPath:='/usr/bin/ppc386'; - if Options.FPCSrcDir='' then - Options.FPCSrcDir:=ExpandFileName('~/freepascal/fpc'); - if Options.LazarusSrcDir='' then - Options.LazarusSrcDir:=ExpandFileName('~/pascal/lazarus'); - { Linux } - {Options.FPCPath:='/usr/bin/ppc386'; - Options.FPCSrcDir:=ExpandFileName('~/freepascal/fpc'); - Options.LazarusSrcDir:=ExpandFileName('~/pascal/lazarus');} - - { Windows - Options.FPCPath:='C:\lazarus\fpc\2.0.4\bin\i386-win32\ppc386.exe'; - Options.FPCSrcDir:='C:\lazarus\fpc\2.0.4\source'; - Options.LazarusSrcDir:='C:\lazarus\';} end; + Options.InitWithEnvironmentVariables; + if Options.FPCSrcDir='' then + Options.FPCSrcDir:=ExpandFileName('~/freepascal/fpc'); + if Options.LazarusSrcDir='' then + Options.LazarusSrcDir:=ExpandFileName('~/pascal/lazarus'); // optional: ProjectDir and TestPascalFile exists only to easily test some // things.