tools/builder/Win32Builder.cs
author David Anderson <dvander@alliedmods.net>
Mon Feb 12 05:56:27 2007 +0000 (2007-02-12)
changeset 471 9728c9e59f8c
parent 468 e88b65aad7e1
child 686 b3f80b9ced9e
permissions -rw-r--r--
(none)
     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 CompressPackage(Package pkg)
    15 		{
    16 			string lpath = null, ltarget = null;
    17 			
    18 			pkg.GetCompressBases(ref lpath, ref ltarget);
    19 
    20 			string local_dir = Config.PathFormat("{0}/{1}", 
    21 				cfg.OutputBase,
    22 				lpath);
    23 
    24 			string name = PackageBuildName(pkg) + ".zip";
    25 
    26 			ProcessStartInfo info = new ProcessStartInfo();
    27 			info.FileName = cfg.Compressor;
    28 			info.WorkingDirectory = local_dir;
    29 			info.Arguments = "-r \"" + name + "\" \"" + ltarget + "\"";
    30 			info.UseShellExecute = false;
    31 
    32 			Process p = Process.Start(info);
    33 			p.WaitForExit();
    34 
    35 			local_dir = Config.PathFormat("{0}/{1}", local_dir, name);
    36 
    37 			if (!File.Exists(local_dir))
    38 			{
    39 				return null;
    40 			}
    41 
    42 			return name;
    43 		}
    44 
    45 		public override bool BuildLibrary(Package pkg, Library lib, ref string _binName, ref string _binPath)
    46 		{
    47 			ProcessStartInfo info = new ProcessStartInfo();
    48 
    49 			string path = Config.PathFormat("{0}/{1}/msvc8", 
    50 				cfg.SourceBase,
    51 				lib.LocalPath);
    52 
    53 			/* PlatformExt ignored for us */
    54 			string binName = lib.Name + (lib.IsExecutable ? ".exe" : ".dll");
    55 
    56 			string binpath = Config.PathFormat("{0}/{1}/{2}",
    57 				path,
    58 				lib.ReleaseBuild,
    59 				binName);
    60 			
    61 			if (File.Exists(binpath))
    62 			{
    63 				File.Delete(binpath);
    64 			}
    65 
    66 			string projectFile = null;
    67 			if (lib.ProjectFile != null)
    68 			{
    69 				projectFile = lib.ProjectFile + ".vcproj";
    70 			} 
    71 			else 
    72 			{
    73 				projectFile = lib.Name + ".vcproj";
    74 			}
    75 
    76 			info.WorkingDirectory = path;
    77 			info.FileName = cfg.BuilderPath;
    78 			info.UseShellExecute = false;
    79 
    80 			if (cfg.BuildOptions != null)
    81 			{
    82 				info.Arguments = cfg.BuildOptions + " ";
    83 			}
    84 
    85 			info.Arguments += "/rebuild " + lib.ReleaseBuild + " " + projectFile;
    86 
    87 			Process p = Process.Start(info);
    88 			p.WaitForExit();
    89 			p.Close();
    90 
    91 			if (!File.Exists(binpath))
    92 			{
    93 				return false;
    94 			}
    95 
    96 			_binName = binName;
    97 			_binPath = binpath;
    98 
    99 			return true;
   100 		}
   101 	}
   102 }