Fixed bug where error messages weren't displayed; changed icon; added optional compiler.ini to set default output directory (Section "Main", Key "Output")
--HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401308
This commit is contained in:
parent
ac03126022
commit
c2e2c5bfda
@ -1,7 +1,7 @@
|
|||||||
(* AMX Mod X
|
(* SourceMod
|
||||||
* compile.exe
|
* compile.exe
|
||||||
*
|
*
|
||||||
* by the AMX Mod X Development Team
|
* by the SourceMod Development Team (adapted from AMX Mod X's compiler tool)
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify it
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
@ -33,17 +33,19 @@ program compile;
|
|||||||
|
|
||||||
{$APPTYPE CONSOLE}
|
{$APPTYPE CONSOLE}
|
||||||
{$R version.res}
|
{$R version.res}
|
||||||
|
{$R icon.res}
|
||||||
|
|
||||||
uses
|
uses
|
||||||
SysUtils, Classes,
|
SysUtils, Classes, IniFiles,
|
||||||
uFunc in 'uFunc.pas';
|
uFunc in 'uFunc.pas';
|
||||||
|
|
||||||
var
|
var sr: TSearchRec;
|
||||||
sr: TSearchRec;
|
i: Word;
|
||||||
i: Word;
|
cfg: TIniFile;
|
||||||
|
outdir: String;
|
||||||
begin
|
begin
|
||||||
WriteLn('//SourceMod compile.exe');
|
WriteLn('//SourceMod Batch Compiler');
|
||||||
WriteLn('// by the AMX Mod X Dev Team');
|
WriteLn('// by the SourceMod Dev Team');
|
||||||
WriteLn;
|
WriteLn;
|
||||||
|
|
||||||
if not FileExists(ExtractFilePath(ParamStr(0))+COMPILER_EXE) then
|
if not FileExists(ExtractFilePath(ParamStr(0))+COMPILER_EXE) then
|
||||||
@ -52,7 +54,15 @@ begin
|
|||||||
AppExit;
|
AppExit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if not DirectoryExists(ExtractFilePath(ParamStr(0))+'compiled') then
|
cfg := TIniFile.Create(ExtractFilePath(ParamStr(0)) + 'compiler.ini');
|
||||||
|
outdir := cfg.ReadString('Main', 'Output', '');
|
||||||
|
if (outdir <> '') and (DirectoryExists(outdir)) then
|
||||||
|
outdir := IncludeTrailingPathDelimiter(outdir)
|
||||||
|
else
|
||||||
|
outdir := '';
|
||||||
|
cfg.Free;
|
||||||
|
|
||||||
|
if (outdir = '') and (not DirectoryExists(ExtractFilePath(ParamStr(0))+'compiled')) then
|
||||||
CreateDir(ExtractFilePath(ParamStr(0))+'compiled');
|
CreateDir(ExtractFilePath(ParamStr(0))+'compiled');
|
||||||
|
|
||||||
if ( ParamCount > 0 ) then
|
if ( ParamCount > 0 ) then
|
||||||
@ -60,7 +70,7 @@ begin
|
|||||||
for i := 1 to ParamCount do
|
for i := 1 to ParamCount do
|
||||||
begin
|
begin
|
||||||
if FileExists(ParamStr(i)) then
|
if FileExists(ParamStr(i)) then
|
||||||
CompilePlugin(ParamStr(i))
|
CompilePlugin(ParamStr(i), outdir)
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
WriteLn;
|
WriteLn;
|
||||||
@ -73,7 +83,7 @@ begin
|
|||||||
if ( FindFirst('*.sp',faAnyFile,sr) = 0 ) then
|
if ( FindFirst('*.sp',faAnyFile,sr) = 0 ) then
|
||||||
begin
|
begin
|
||||||
repeat
|
repeat
|
||||||
CompilePlugin(sr.Name);
|
CompilePlugin(sr.Name, outdir);
|
||||||
until ( FindNext(sr) <> 0 );
|
until ( FindNext(sr) <> 0 );
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
Binary file not shown.
1
sourcepawn/batchtool/icon.rc
Normal file
1
sourcepawn/batchtool/icon.rc
Normal file
@ -0,0 +1 @@
|
|||||||
|
SM ICON "pawn.ico"
|
BIN
sourcepawn/batchtool/icon.res
Normal file
BIN
sourcepawn/batchtool/icon.res
Normal file
Binary file not shown.
BIN
sourcepawn/batchtool/pawn.ico
Normal file
BIN
sourcepawn/batchtool/pawn.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.3 KiB |
@ -40,7 +40,7 @@ resourcestring
|
|||||||
COMPILER_EXE = 'spcomp.exe';
|
COMPILER_EXE = 'spcomp.exe';
|
||||||
|
|
||||||
procedure AppExit;
|
procedure AppExit;
|
||||||
procedure CompilePlugin(const Name: String);
|
procedure CompilePlugin(const Name, OutputDir: String);
|
||||||
function GetAgeFromDat(const FileName: String): Integer;
|
function GetAgeFromDat(const FileName: String): Integer;
|
||||||
procedure SetAgeToDat(const FileName: String; const Age: Integer);
|
procedure SetAgeToDat(const FileName: String; const Age: Integer);
|
||||||
function GetConsoleOutput(const Command: String; var Output: TStringList): Boolean;
|
function GetConsoleOutput(const Command: String; var Output: TStringList): Boolean;
|
||||||
@ -55,7 +55,7 @@ begin
|
|||||||
Halt;
|
Halt;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure CompilePlugin(const Name: String);
|
procedure CompilePlugin(const Name, OutputDir: String);
|
||||||
var
|
var
|
||||||
Output: TStringList;
|
Output: TStringList;
|
||||||
i: Word;
|
i: Word;
|
||||||
@ -64,14 +64,18 @@ var
|
|||||||
begin
|
begin
|
||||||
FileName := ExtractFileName(Name);
|
FileName := ExtractFileName(Name);
|
||||||
FilePath := ExtractFilePath(Name);
|
FilePath := ExtractFilePath(Name);
|
||||||
Compiled := FilePath+'compiled\'+ChangeFileExt(Filename,'.smx');
|
if (OutputDir = '') then
|
||||||
|
Compiled := FilePath+'compiled\'+ChangeFileExt(Filename,'.smx')
|
||||||
|
else
|
||||||
|
Compiled := OutputDir+ChangeFileExt(Filename,'.smx');
|
||||||
|
|
||||||
if (FilePath='') then
|
if (FilePath='') then
|
||||||
FilePath := ExtractFilePath(ParamStr(0));
|
FilePath := ExtractFilePath(ParamStr(0));
|
||||||
|
|
||||||
WriteLn;
|
WriteLn;
|
||||||
WriteLn('//// '+ExtractFileName(FileName));
|
WriteLn('//// '+ExtractFileName(FileName));
|
||||||
|
|
||||||
if FileExists(Compiled) and ( GetAgeFromDat(FileName)=FileAge(Name) ) then
|
if FileExists(Compiled) and ( GetAgeFromDat(Name)=FileAge(Name) ) then
|
||||||
begin
|
begin
|
||||||
WriteLn('// Already compiled.');
|
WriteLn('// Already compiled.');
|
||||||
WriteLn('// ----------------------------------------');
|
WriteLn('// ----------------------------------------');
|
||||||
@ -82,7 +86,7 @@ begin
|
|||||||
|
|
||||||
try
|
try
|
||||||
cStart := GetTickCount;
|
cStart := GetTickCount;
|
||||||
if not GetConsoleOutput(ExtractFilePath(ParamStr(0))+COMPILER_EXE+' "'+FilePath+FileName+'" "-o'+Compiled+'"',Output) then
|
if not GetConsoleOutput(ExtractFilePath(ParamStr(0))+COMPILER_EXE+' "'+FileName+'" "-o'+Compiled+'"',Output) then
|
||||||
begin
|
begin
|
||||||
WriteLn('// Internal error.');
|
WriteLn('// Internal error.');
|
||||||
AppExit;
|
AppExit;
|
||||||
@ -103,7 +107,7 @@ begin
|
|||||||
AppExit;
|
AppExit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
SetAgeToDat(FileName,FileAge(Name));
|
SetAgeToDat(Name,FileAge(Name));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function GetAgeFromDat(const FileName: String): Integer;
|
function GetAgeFromDat(const FileName: String): Integer;
|
||||||
@ -123,6 +127,7 @@ begin
|
|||||||
Ini.WriteInteger(FileName,'Age',Age);
|
Ini.WriteInteger(FileName,'Age',Age);
|
||||||
Ini.UpdateFile;
|
Ini.UpdateFile;
|
||||||
Ini.Free;
|
Ini.Free;
|
||||||
|
SetFileAttributes(PChar(ExtractFilePath(ParamStr(0))+'compile.dat'), faHidden);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function GetConsoleOutput(const Command: String; var Output: TStringList): Boolean;
|
function GetConsoleOutput(const Command: String; var Output: TStringList): Boolean;
|
||||||
@ -138,10 +143,11 @@ var
|
|||||||
Buffer: array [0..255] of Char;
|
Buffer: array [0..255] of Char;
|
||||||
NumberOfBytesRead: DWORD;
|
NumberOfBytesRead: DWORD;
|
||||||
Stream: TMemoryStream;
|
Stream: TMemoryStream;
|
||||||
|
Errors: String;
|
||||||
begin
|
begin
|
||||||
FillChar(ProcessInfo, SizeOf(TProcessInformation), 0);
|
FillChar(ProcessInfo, SizeOf(TProcessInformation), 0);
|
||||||
|
|
||||||
FillChar(SecurityAttr, SizeOf(TSecurityAttributes), 0);
|
FillChar(SecurityAttr, SizeOf(TSecurityAttributes), 0);
|
||||||
|
|
||||||
SecurityAttr.nLength := SizeOf(SecurityAttr);
|
SecurityAttr.nLength := SizeOf(SecurityAttr);
|
||||||
SecurityAttr.bInheritHandle := True;
|
SecurityAttr.bInheritHandle := True;
|
||||||
SecurityAttr.lpSecurityDescriptor := nil;
|
SecurityAttr.lpSecurityDescriptor := nil;
|
||||||
@ -157,9 +163,7 @@ begin
|
|||||||
StartupInfo.wShowWindow := SW_HIDE;
|
StartupInfo.wShowWindow := SW_HIDE;
|
||||||
StartupInfo.dwFlags := STARTF_USESHOWWINDOW or STARTF_USESTDHANDLES;
|
StartupInfo.dwFlags := STARTF_USESHOWWINDOW or STARTF_USESTDHANDLES;
|
||||||
|
|
||||||
if CreateProcess(nil, PChar(command), nil, nil, true,
|
if CreateProcess(nil, PChar(command), nil, nil, true, CREATE_DEFAULT_ERROR_MODE or CREATE_NEW_CONSOLE or NORMAL_PRIORITY_CLASS, nil, nil, StartupInfo, ProcessInfo) then begin
|
||||||
CREATE_DEFAULT_ERROR_MODE or CREATE_NEW_CONSOLE or NORMAL_PRIORITY_CLASS, nil, nil,
|
|
||||||
StartupInfo, ProcessInfo) then begin
|
|
||||||
Result := True;
|
Result := True;
|
||||||
CloseHandle(PipeOutputWrite);
|
CloseHandle(PipeOutputWrite);
|
||||||
CloseHandle(PipeErrorsWrite);
|
CloseHandle(PipeErrorsWrite);
|
||||||
@ -171,20 +175,24 @@ begin
|
|||||||
if not Succeed then Break;
|
if not Succeed then Break;
|
||||||
Stream.Write(Buffer, NumberOfBytesRead);
|
Stream.Write(Buffer, NumberOfBytesRead);
|
||||||
end;
|
end;
|
||||||
Stream.Position := 0;
|
|
||||||
Output.LoadFromStream(Stream);
|
|
||||||
finally
|
finally
|
||||||
Stream.Free;
|
// nothing
|
||||||
end;
|
end;
|
||||||
|
Stream.Position := 0;
|
||||||
|
Output.LoadFromStream(Stream);
|
||||||
|
Stream.Free;
|
||||||
CloseHandle(PipeOutputRead);
|
CloseHandle(PipeOutputRead);
|
||||||
|
|
||||||
|
Errors := '';
|
||||||
try
|
try
|
||||||
while True do
|
while True do
|
||||||
begin
|
begin
|
||||||
Succeed := ReadFile(PipeErrorsRead, Buffer, 255, NumberOfBytesRead, nil);
|
Succeed := ReadFile(PipeErrorsRead, Buffer, 255, NumberOfBytesRead, nil);
|
||||||
if not Succeed then Break;
|
if not Succeed then Break;
|
||||||
|
Errors := Errors + Copy(Buffer, 1, NumberOfBytesRead);
|
||||||
end;
|
end;
|
||||||
finally
|
finally
|
||||||
|
// nothing
|
||||||
end;
|
end;
|
||||||
CloseHandle(PipeErrorsRead);
|
CloseHandle(PipeErrorsRead);
|
||||||
|
|
||||||
@ -199,6 +207,18 @@ begin
|
|||||||
CloseHandle(PipeErrorsRead);
|
CloseHandle(PipeErrorsRead);
|
||||||
CloseHandle(PipeErrorsWrite);
|
CloseHandle(PipeErrorsWrite);
|
||||||
end;
|
end;
|
||||||
end;
|
// error management
|
||||||
|
if (Errors <> '') then begin
|
||||||
|
if (Output.Count > 1) then begin
|
||||||
|
if (Trim(Output[Output.Count -2]) = '') then
|
||||||
|
Output.Strings[Output.Count -2] := TrimRight(Errors)
|
||||||
|
else
|
||||||
|
Output.Insert(Output.Count -1, TrimRight(Errors));
|
||||||
|
end
|
||||||
|
else
|
||||||
|
Output.Add(Errors);
|
||||||
|
Output.Text := Output.Text; // pseudo-rearrangement
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
@ -12,17 +12,17 @@ BEGIN
|
|||||||
BEGIN
|
BEGIN
|
||||||
BLOCK "040904b0"
|
BLOCK "040904b0"
|
||||||
BEGIN
|
BEGIN
|
||||||
VALUE "Comments", "AMXXPC compile.exe\0"
|
VALUE "Comments", "SPCOMP compile.exe\0"
|
||||||
//VALUE "CompanyName", "AMXX Development Team\0"
|
//VALUE "CompanyName", "AMXX Development Team\0"
|
||||||
VALUE "FileDescription", "AMXXPC compile.exe\0"
|
VALUE "FileDescription", "SPCOMP compile.exe\0"
|
||||||
VALUE "FileVersion", "1.5\0"
|
VALUE "FileVersion", "1.0\0"
|
||||||
VALUE "InternalName", "AMXXPC compile.exe\0"
|
VALUE "InternalName", "SPCOMP compile.exe\0"
|
||||||
VALUE "LegalCopyright", "(c) 2004-2005, AMXX Development Team\0"
|
VALUE "LegalCopyright", "(c) 2007, SourceMod Development Team\0"
|
||||||
//VALUE "LegalTrademarks", "\0"
|
//VALUE "LegalTrademarks", "\0"
|
||||||
VALUE "OriginalFilename", "compile.exe\0"
|
VALUE "OriginalFilename", "compile.exe\0"
|
||||||
//VALUE "PrivateBuild", "\0"
|
//VALUE "PrivateBuild", "\0"
|
||||||
VALUE "ProductName", "AMXXPC compile.exe\0"
|
VALUE "ProductName", "SPCOMP compile.exe\0"
|
||||||
VALUE "ProductVersion", "1.5\0"
|
VALUE "ProductVersion", "1.0\0"
|
||||||
//VALUE "SpecialBuild", "\0"
|
//VALUE "SpecialBuild", "\0"
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user