tools/builder/Win32Builder.cs
author Scott Ehlert <ds@alliedmods.net>
Sun Jul 15 08:00:26 2007 +0000 (2007-07-15)
changeset 1116 40cc5e9f0f1b
parent 852 9a7a93363979
child 1548 e759eedf6c9b
permissions -rw-r--r--
Removed strange debugging code
     1 using System;
     2 using System.IO;
     3 using System.Diagnostics;
     4 
     5 namespace builder
     6 {
     7 	public class Win32Builder : ABuilder
     8 	{
     9 		public Win32Builder(Config _cfg)
    10 		{
    11 			cfg = _cfg;
    12 		}
    13 
    14 		public override string GetPawnCompilerName()
    15 		{
    16 			return "spcomp.exe";
    17 		}
    18 
    19 		public override string CompressPackage(Package pkg)
    20 		{
    21 			string lpath = null, ltarget = null;
    22 			
    23 			pkg.GetCompressBases(ref lpath, ref ltarget);
    24 
    25 			string local_dir = Config.PathFormat("{0}/{1}", 
    26 				cfg.OutputBase,
    27 				lpath);
    28 
    29 			string name = PackageBuildName(pkg) + ".zip";
    30 
    31 			ProcessStartInfo info = new ProcessStartInfo();
    32 			info.FileName = cfg.Compressor;
    33 			info.WorkingDirectory = local_dir;
    34 			info.Arguments = "-r \"" + name + "\" \"" + ltarget + "\"";
    35 			info.UseShellExecute = false;
    36 
    37 			Process p = Process.Start(info);
    38 			p.WaitForExit();
    39 
    40 			local_dir = Config.PathFormat("{0}/{1}", local_dir, name);
    41 
    42 			if (!File.Exists(local_dir))
    43 			{
    44 				return null;
    45 			}
    46 
    47 			return name;
    48 		}
    49 
    50 		public override bool BuildLibrary(Package pkg, Library lib, ref string _binName, ref string _binPath)
    51 		{
    52 			ProcessStartInfo info = new ProcessStartInfo();
    53 
    54 			string path = Config.PathFormat("{0}/{1}/msvc8", 
    55 				cfg.SourceBase,
    56 				lib.LocalPath);
    57 
    58 			/* PlatformExt ignored for us */
    59 			string binName = lib.Name + (lib.IsExecutable ? ".exe" : ".dll");
    60 
    61 			string binpath = Config.PathFormat("{0}/{1}/{2}",
    62 				path,
    63 				lib.ReleaseBuild,
    64 				binName);
    65 			
    66 			if (File.Exists(binpath))
    67 			{
    68 				File.Delete(binpath);
    69 			}
    70 
    71 			string projectFile = null;
    72 			if (lib.ProjectFile != null)
    73 			{
    74 				projectFile = lib.ProjectFile + ".vcproj";
    75 			} 
    76 			else 
    77 			{
    78 				projectFile = lib.Name + ".vcproj";
    79 			}
    80 
    81 			info.WorkingDirectory = path;
    82 			info.FileName = cfg.BuilderPath;
    83 			info.UseShellExecute = false;
    84 			info.RedirectStandardOutput = true;
    85 			info.RedirectStandardError = true;
    86 
    87 			if (cfg.BuildOptions != null)
    88 			{
    89 				info.Arguments = cfg.BuildOptions + " ";
    90 			}
    91 
    92 			info.Arguments += "/rebuild " + lib.ReleaseBuild + " " + projectFile;
    93 
    94 			Process p = Process.Start(info);
    95 			Console.WriteLine(p.StandardOutput.ReadToEnd());
    96 			p.WaitForExit();
    97 			p.Close();
    98 
    99 			if (!File.Exists(binpath))
   100 			{
   101 				return false;
   102 			}
   103 
   104 			_binName = binName;
   105 			_binPath = binpath;
   106 
   107 			return true;
   108 		}
   109 	}
   110 }