2007-01-27 04:10:31 +01:00
|
|
|
using System;
|
|
|
|
using System.IO;
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
|
|
|
namespace builder
|
|
|
|
{
|
|
|
|
public class Win32Builder : ABuilder
|
|
|
|
{
|
|
|
|
public Win32Builder(Config _cfg)
|
|
|
|
{
|
|
|
|
cfg = _cfg;
|
|
|
|
}
|
|
|
|
|
2007-05-24 00:08:05 +02:00
|
|
|
public override string GetPawnCompilerName()
|
|
|
|
{
|
|
|
|
return "spcomp.exe";
|
|
|
|
}
|
|
|
|
|
2007-10-14 20:55:49 +02:00
|
|
|
public override bool BuildLibrary(Package pkg, Library lib, ref string _binName, ref string _binPath)
|
2007-01-28 05:19:46 +01:00
|
|
|
{
|
|
|
|
ProcessStartInfo info = new ProcessStartInfo();
|
|
|
|
|
2007-10-14 20:55:49 +02:00
|
|
|
string path = Config.PathFormat("{0}/{1}/msvc8",
|
|
|
|
cfg.source_path,
|
|
|
|
lib.source_path);
|
|
|
|
|
|
|
|
/* PlatformExt ignored for us */
|
|
|
|
string binName = lib.binary_name + (lib.is_executable ? ".exe" : ".dll");
|
2007-01-28 05:19:46 +01:00
|
|
|
|
2007-10-14 20:55:49 +02:00
|
|
|
string config_name = "Unknown";
|
2007-01-28 05:19:46 +01:00
|
|
|
|
2007-10-14 20:55:49 +02:00
|
|
|
if (lib.release_mode == ReleaseMode.ReleaseMode_Release)
|
2007-01-28 05:19:46 +01:00
|
|
|
{
|
2007-10-14 20:55:49 +02:00
|
|
|
config_name = "Release";
|
|
|
|
}
|
|
|
|
else if (lib.release_mode == ReleaseMode.ReleaseMode_Debug)
|
|
|
|
{
|
|
|
|
config_name = "Debug";
|
2007-01-28 05:19:46 +01:00
|
|
|
}
|
|
|
|
|
2007-10-14 20:55:49 +02:00
|
|
|
if (lib.build_mode == BuildMode.BuildMode_Episode1)
|
|
|
|
{
|
|
|
|
config_name = config_name + " - Episode 1";
|
|
|
|
}
|
|
|
|
else if (lib.build_mode == BuildMode.BuildMode_Episode2)
|
|
|
|
{
|
|
|
|
config_name = config_name + " - Orange Box";
|
|
|
|
}
|
|
|
|
else if (lib.build_mode == BuildMode.BuildMode_OldMetamod)
|
|
|
|
{
|
|
|
|
config_name = config_name + " - Old Metamod";
|
|
|
|
}
|
2007-01-27 04:10:31 +01:00
|
|
|
|
|
|
|
string binpath = Config.PathFormat("{0}/{1}/{2}",
|
|
|
|
path,
|
2007-10-14 20:55:49 +02:00
|
|
|
config_name,
|
2007-01-27 04:10:31 +01:00
|
|
|
binName);
|
|
|
|
|
|
|
|
if (File.Exists(binpath))
|
|
|
|
{
|
|
|
|
File.Delete(binpath);
|
|
|
|
}
|
|
|
|
|
2007-10-14 20:55:49 +02:00
|
|
|
string project_file = null;
|
|
|
|
if (lib.vcproj_name != null)
|
2007-01-27 04:10:31 +01:00
|
|
|
{
|
2007-10-14 20:55:49 +02:00
|
|
|
project_file = lib.vcproj_name + ".vcproj";
|
2007-01-27 04:10:31 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-10-14 20:55:49 +02:00
|
|
|
project_file = lib.binary_name + ".vcproj";
|
2007-01-27 04:10:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
info.WorkingDirectory = path;
|
2007-10-14 20:55:49 +02:00
|
|
|
info.FileName = cfg.builder_path;
|
2007-01-27 04:10:31 +01:00
|
|
|
info.UseShellExecute = false;
|
2007-04-12 21:08:01 +02:00
|
|
|
info.RedirectStandardOutput = true;
|
|
|
|
info.RedirectStandardError = true;
|
2007-01-27 04:10:31 +01:00
|
|
|
|
2007-10-14 20:55:49 +02:00
|
|
|
if (cfg.build_options != null)
|
2007-02-12 06:43:14 +01:00
|
|
|
{
|
2007-10-14 20:55:49 +02:00
|
|
|
info.Arguments = cfg.build_options + " ";
|
2007-02-12 06:43:14 +01:00
|
|
|
}
|
|
|
|
|
2007-10-14 20:55:49 +02:00
|
|
|
info.Arguments += "/rebuild \"" + config_name + "\" " + project_file;
|
2007-02-12 06:56:27 +01:00
|
|
|
|
2007-01-27 04:10:31 +01:00
|
|
|
Process p = Process.Start(info);
|
2007-04-12 21:08:01 +02:00
|
|
|
Console.WriteLine(p.StandardOutput.ReadToEnd());
|
2007-01-27 04:10:31 +01:00
|
|
|
p.WaitForExit();
|
|
|
|
p.Close();
|
|
|
|
|
|
|
|
if (!File.Exists(binpath))
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
_binName = binName;
|
|
|
|
_binPath = binpath;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|