From 9e6817f182864208244c34cfe137a02d7c542c3c Mon Sep 17 00:00:00 2001 From: mgaertner Date: Sat, 23 Apr 2011 19:55:39 +0000 Subject: [PATCH] instantfpc: added parameter --compiler= git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1597 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- applications/instantfpc/instantfpc.lpr | 6 +++++- applications/instantfpc/instantfptools.pas | 20 +++++++++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/applications/instantfpc/instantfpc.lpr b/applications/instantfpc/instantfpc.lpr index d12ad35d4..57fdd661e 100644 --- a/applications/instantfpc/instantfpc.lpr +++ b/applications/instantfpc/instantfpc.lpr @@ -73,7 +73,11 @@ begin writeln('instantfpc --get-cache'); writeln(' Prints cache directory to stdout.'); writeln; - writeln('Normal usage is to add as first line "#!/usr/bin/instantfpc" to a source'); + writeln('instantfpc --compiler='); + writeln(' Normally fpc is searched in PATH and used as compiler.'); + writeln; + writeln('Normal usage is to add as first line ("shebang") "#!/usr/bin/instantfpc"'); + writeln('to a program source file. Then you can execute the source like a script.'); Halt(0); end else if p='--get-cache' then begin CacheDir:=GetCacheDir; diff --git a/applications/instantfpc/instantfptools.pas b/applications/instantfpc/instantfptools.pas index f58f6519c..0927c00ae 100644 --- a/applications/instantfpc/instantfptools.pas +++ b/applications/instantfpc/instantfptools.pas @@ -103,13 +103,31 @@ begin end; function GetCompiler: string; +const + CompilerParam = '--compiler='; var Path: String; p: Integer; StartPos: LongInt; Dir: String; CompFile: String; + i: Integer; + Param: String; begin + for i:=1 to Paramcount do begin + Param:=ParamStr(i); + if (Param='') or (Param[1]<>'-') then break; + if copy(Param,1,length(CompilerParam))=CompilerParam then begin + CompFile:=copy(Param,length(CompilerParam)+1,length(Param)); + Result:=ExpandFileName(CompFile); + if not FileExists(Result) then begin + writeln('Error: '+CompFile+' not found, check the ',CompilerParam,' parameter.'); + Halt(1); + end; + exit; + end; + end; + {$IFDEF Windows} CompFile:='fpc.exe'; {$ELSE} @@ -129,7 +147,7 @@ begin inc(p); end; end; - writeln(CompFile+' not found in PATH'); + writeln('Error: '+CompFile+' not found in PATH'); Halt(1); end;