instantfpc: added parameter --compiler=<path of compiler>

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1597 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
mgaertner
2011-04-23 19:55:39 +00:00
parent b01fc22a91
commit 9e6817f182
2 changed files with 24 additions and 2 deletions

View File

@ -73,7 +73,11 @@ begin
writeln('instantfpc --get-cache'); writeln('instantfpc --get-cache');
writeln(' Prints cache directory to stdout.'); writeln(' Prints cache directory to stdout.');
writeln; writeln;
writeln('Normal usage is to add as first line "#!/usr/bin/instantfpc" to a source'); writeln('instantfpc --compiler=<path to 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); Halt(0);
end else if p='--get-cache' then begin end else if p='--get-cache' then begin
CacheDir:=GetCacheDir; CacheDir:=GetCacheDir;

View File

@ -103,13 +103,31 @@ begin
end; end;
function GetCompiler: string; function GetCompiler: string;
const
CompilerParam = '--compiler=';
var var
Path: String; Path: String;
p: Integer; p: Integer;
StartPos: LongInt; StartPos: LongInt;
Dir: String; Dir: String;
CompFile: String; CompFile: String;
i: Integer;
Param: String;
begin 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} {$IFDEF Windows}
CompFile:='fpc.exe'; CompFile:='fpc.exe';
{$ELSE} {$ELSE}
@ -129,7 +147,7 @@ begin
inc(p); inc(p);
end; end;
end; end;
writeln(CompFile+' not found in PATH'); writeln('Error: '+CompFile+' not found in PATH');
Halt(1); Halt(1);
end; end;