From ace6bfd4e9349dfa3c0066cb582643702817f000 Mon Sep 17 00:00:00 2001 From: florian Date: Sat, 15 Oct 2011 17:43:12 +0000 Subject: [PATCH] * check environment variable LOCALAPPDATA on windows as a possible cache location for instantfpc git-svn-id: trunk@19497 - --- utils/instantfpc/instantfptools.pas | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/utils/instantfpc/instantfptools.pas b/utils/instantfpc/instantfptools.pas index b8702aa688..6ea76e5a5c 100644 --- a/utils/instantfpc/instantfptools.pas +++ b/utils/instantfpc/instantfptools.pas @@ -38,7 +38,7 @@ function IsCacheValid(Src: TStringList; procedure Compile(const SrcFilename, CacheFilename, OutputFilename: string); procedure WriteCompilerOutput(SrcFilename, CacheFilename, CompilerOutput: string); function GetCompiler: string; -procedure SetCompiler(AValue : string); +procedure SetCompiler(AValue : string); function GetCompilerParameters(const SrcFilename, OutputFilename: string): string; procedure Run(const Filename: string); @@ -47,7 +47,7 @@ implementation Var CmdCacheDir : String; CmdCompiler : String; - + procedure AddParam(p: string; var Line: string); begin if p='' then exit; @@ -96,18 +96,22 @@ end; function GetCacheDir: string; begin Result:=CmdCacheDir; - if (Result='') then + if (Result='') then begin Result:=GetEnvironmentVariable('INSTANTFPCCACHE'); - if Result='' then + if Result='' then begin Result:=GetEnvironmentVariable('HOME'); +{$ifdef WINDOWS} + if Result='' then + Result:=GetEnvironmentVariable('LOCALAPPDATA'); +{$endif WINDOWS} if Result<>'' then Result:=IncludeTrailingPathDelimiter(Result)+'.cache'+PathDelim+'instantfpc'; end; - end; + end; if Result='' then begin - writeln('missing environment variable: HOME or INSTANTFPCCACHE'); + writeln('missing environment variable: HOME or INSTANTFPCCACHE or LOCALAPPDATA'); Halt(1); end; Result:=IncludeTrailingPathDelimiter(ExpandFileName(Result)); @@ -140,7 +144,7 @@ begin {$ENDIF} end; -procedure SetCompiler(AValue : string); +procedure SetCompiler(AValue : string); begin CmdCompiler:=AValue; @@ -195,7 +199,7 @@ begin if (Result<>'') then begin Result:=ExpandFileName(Result); - if not FileExists(Result) then + if not FileExists(Result) then begin writeln('Error: '+Result+' not found, check the --compiler parameter.'); Halt(1); @@ -285,7 +289,7 @@ begin p:=ParamStr(i); if (Copy(p,1,1)='-') and (copy(p,1,2)<>'--') then AddParam(P,Result); - inc(I); + inc(I); end; AddParam('-o'+OutputFilename {$IFDEF HASEXEEXT} + '.exe' {$ENDIF},Result); AddParam(SrcFilename,Result);