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