-
Notifications
You must be signed in to change notification settings - Fork 94
/
Copy pathfpcproxy.lpr
45 lines (37 loc) · 889 Bytes
/
fpcproxy.lpr
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
program fpcproxy;
{$mode objfpc}{$H+}
uses
SysUtils;//,process;
procedure error(const s : string);
begin
writeln('Error: ',s);
halt(1);
end;
var
i: integer;
aPath:string;
ppccommandline : array of ansistring;
errorvalue : Longint;
fpcbin: string;
begin
aPath:=ExtractFilePath(ParamStr(0));
{$IFDEF WINDOWS}
fpcbin:=aPath+'fpc.exe';
{$ELSE}
fpcbin:=aPath+'fpc';
{$ENDIF}
setlength(ppccommandline,paramcount+2);
ppccommandline[0]:='-n';
ppccommandline[1]:='@'+aPath+'fpc.cfg';
for i:=1 to ParamCount() do ppccommandline[i+1]:=ParamStr(i);
try
errorvalue:=ExecuteProcess(fpcbin,ppccommandline);
except
on e : exception do
error(fpcbin+' can''t be executed, error message: '+e.message);
end;
if (errorvalue<>0) and
(paramcount<>0) then
error(fpcbin+' returned an error exitcode');
halt(errorvalue);
end.