|
ds@1952
|
1 |
(* SourceMod |
|
ds@1952
|
2 |
* compile.exe |
|
ds@1952
|
3 |
* |
|
ds@1952
|
4 |
* by the SourceMod Development Team (adapted from AMX Mod X's compiler tool) |
|
ds@1952
|
5 |
* |
|
ds@1952
|
6 |
* |
|
ds@1952
|
7 |
* This program is free software; you can redistribute it and/or modify it |
|
ds@1952
|
8 |
* under the terms of the GNU General Public License as published by the |
|
ds@1952
|
9 |
* Free Software Foundation; either version 2 of the License, or (at |
|
ds@1952
|
10 |
* your option) any later version. |
|
ds@1952
|
11 |
* |
|
ds@1952
|
12 |
* This program is distributed in the hope that it will be useful, but |
|
ds@1952
|
13 |
* WITHOUT ANY WARRANTY; without even the implied warranty of |
|
ds@1952
|
14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
ds@1952
|
15 |
* General Public License for more details. |
|
ds@1952
|
16 |
* |
|
ds@1952
|
17 |
* You should have received a copy of the GNU General Public License |
|
ds@1952
|
18 |
* along with this program; if not, write to the Free Software Foundation, |
|
ds@1952
|
19 |
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
ds@1952
|
20 |
* |
|
ds@1952
|
21 |
* In addition, as a special exception, the author gives permission to |
|
ds@1952
|
22 |
* link the code of this program with the Half-Life Game Engine ("HL |
|
ds@1952
|
23 |
* Engine") and Modified Game Libraries ("MODs") developed by Valve, |
|
ds@1952
|
24 |
* L.L.C ("Valve"). You must obey the GNU General Public License in all |
|
ds@1952
|
25 |
* respects for all of the code used other than the HL Engine and MODs |
|
ds@1952
|
26 |
* from Valve. If you modify this file, you may extend this exception |
|
ds@1952
|
27 |
* to your version of the file, but you are not obligated to do so. If |
|
ds@1952
|
28 |
* you do not wish to do so, delete this exception statement from your |
|
ds@1952
|
29 |
* version. |
|
ds@1952
|
30 |
*) |
|
ds@1952
|
31 |
|
|
ds@1952
|
32 |
program compile; |
|
ds@1952
|
33 |
|
|
ds@1952
|
34 |
{$APPTYPE CONSOLE} |
|
ds@1952
|
35 |
{$R version.res} |
|
ds@1952
|
36 |
{$R icon.res} |
|
ds@1952
|
37 |
|
|
ds@1952
|
38 |
uses |
|
ds@1952
|
39 |
SysUtils, Classes, IniFiles, |
|
ds@1952
|
40 |
uFunc in 'uFunc.pas'; |
|
ds@1952
|
41 |
|
|
ds@1952
|
42 |
var sr: TSearchRec; |
|
ds@1952
|
43 |
i: Word; |
|
ds@1952
|
44 |
cfg: TIniFile; |
|
ds@1952
|
45 |
outdir: String; |
|
ds@1952
|
46 |
begin |
|
ds@1952
|
47 |
WriteLn('//SourceMod Batch Compiler'); |
|
ds@1952
|
48 |
WriteLn('// by the SourceMod Dev Team'); |
|
ds@1952
|
49 |
WriteLn; |
|
ds@1952
|
50 |
|
|
ds@1952
|
51 |
if not FileExists(ExtractFilePath(ParamStr(0))+COMPILER_EXE) then |
|
ds@1952
|
52 |
begin |
|
ds@1952
|
53 |
WriteLn('// Could not find '+COMPILER_EXE); |
|
ds@1952
|
54 |
AppExit; |
|
ds@1952
|
55 |
end; |
|
ds@1952
|
56 |
|
|
ds@1952
|
57 |
cfg := TIniFile.Create(ExtractFilePath(ParamStr(0)) + 'compiler.ini'); |
|
ds@1952
|
58 |
outdir := cfg.ReadString('Main', 'Output', ''); |
|
ds@1952
|
59 |
if (outdir <> '') then begin |
|
ds@1952
|
60 |
if (DirectoryExists(outdir)) then |
|
ds@1952
|
61 |
outdir := IncludeTrailingPathDelimiter(outdir) |
|
ds@1952
|
62 |
else if (DirectoryExists(ExtractFilePath(ParamStr(0)) + outdir)) then |
|
ds@1952
|
63 |
outdir := ExtractFilePath(ParamStr(0)) + IncludeTrailingPathDelimiter(outdir); |
|
ds@1952
|
64 |
end |
|
ds@1952
|
65 |
else |
|
ds@1952
|
66 |
outdir := ''; |
|
ds@1952
|
67 |
cfg.Free; |
|
ds@1952
|
68 |
|
|
ds@1952
|
69 |
if (outdir = '') and (not DirectoryExists(ExtractFilePath(ParamStr(0))+'compiled')) then |
|
ds@1952
|
70 |
CreateDir(ExtractFilePath(ParamStr(0))+'compiled'); |
|
ds@1952
|
71 |
|
|
ds@1952
|
72 |
if ( ParamCount > 0 ) then |
|
ds@1952
|
73 |
begin |
|
ds@1952
|
74 |
for i := 1 to ParamCount do |
|
ds@1952
|
75 |
begin |
|
ds@1952
|
76 |
if FileExists(ParamStr(i)) then |
|
ds@1952
|
77 |
CompilePlugin(ParamStr(i), outdir) |
|
ds@1952
|
78 |
else |
|
ds@1952
|
79 |
begin |
|
ds@1952
|
80 |
WriteLn; |
|
ds@1952
|
81 |
WriteLn('// File not found.'); |
|
ds@1952
|
82 |
end; |
|
ds@1952
|
83 |
end; |
|
ds@1952
|
84 |
end |
|
ds@1952
|
85 |
else |
|
ds@1952
|
86 |
begin |
|
ds@1952
|
87 |
if ( FindFirst('*.sp',faAnyFile,sr) = 0 ) then |
|
ds@1952
|
88 |
begin |
|
ds@1952
|
89 |
repeat |
|
ds@1952
|
90 |
CompilePlugin(sr.Name, outdir); |
|
ds@1952
|
91 |
until ( FindNext(sr) <> 0 ); |
|
ds@1952
|
92 |
end |
|
ds@1952
|
93 |
else |
|
ds@1952
|
94 |
begin |
|
ds@1952
|
95 |
WriteLn('// No file found.'); |
|
ds@1952
|
96 |
end; |
|
ds@1952
|
97 |
FindClose(sr); |
|
ds@1952
|
98 |
end; |
|
ds@1952
|
99 |
|
|
ds@1952
|
100 |
AppExit; |
|
ds@1952
|
101 |
end. |