tools/builder/LinuxBuilder.cs
changeset 1952 b7aa2b626807
child 2289 44045ead61cd
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/tools/builder/LinuxBuilder.cs	Sun Mar 30 07:00:22 2008 +0000
     1.3 @@ -0,0 +1,118 @@
     1.4 +using System;
     1.5 +using System.IO;
     1.6 +using System.Diagnostics;
     1.7 +
     1.8 +namespace builder
     1.9 +{
    1.10 +	public class LinuxBuilder : ABuilder
    1.11 +	{
    1.12 +		public LinuxBuilder(Config _cfg)
    1.13 +		{
    1.14 +			cfg = _cfg;
    1.15 +		}
    1.16 +
    1.17 +		public override string GetPawnCompilerName()
    1.18 +		{
    1.19 +			return "spcomp";
    1.20 +		}
    1.21 +
    1.22 +		public override bool BuildLibrary(Package pkg, Library lib)
    1.23 +		{
    1.24 +			ProcessStartInfo info = new ProcessStartInfo();
    1.25 +
    1.26 +			string path = Config.PathFormat("{0}/{1}", 
    1.27 +				cfg.source_path,
    1.28 +				lib.source_path);
    1.29 +
    1.30 +			/* PlatformExt ignored for us */
    1.31 +			string binName = lib.binary_name;
    1.32 +			
    1.33 +			if (!lib.is_executable)
    1.34 +			{
    1.35 +				if (lib.has_platform_ext)
    1.36 +				{
    1.37 +					binName += "_i486.so";
    1.38 +				} 
    1.39 +				else 
    1.40 +				{
    1.41 +					binName += ".so";
    1.42 +				}
    1.43 +			}
    1.44 +
    1.45 +			string output_folder = (lib.release_mode == ReleaseMode.ReleaseMode_Release) ? "Release" : "Debug";
    1.46 +
    1.47 +			if (lib.build_mode == BuildMode.BuildMode_Episode2)
    1.48 +			{
    1.49 +				output_folder += ".orangebox";
    1.50 +			}
    1.51 +			else if (lib.build_mode == BuildMode.BuildMode_OldMetamod)
    1.52 +			{
    1.53 +				output_folder += ".original";
    1.54 +			}
    1.55 +
    1.56 +			string binpath = Config.PathFormat("{0}/{1}/{2}",
    1.57 +				path,
    1.58 +				output_folder,
    1.59 +				binName);
    1.60 +			
    1.61 +			if (File.Exists(binpath))
    1.62 +			{
    1.63 +				File.Delete(binpath);
    1.64 +			}
    1.65 +
    1.66 +			string makefile_args = "";
    1.67 +
    1.68 +			if (lib.build_mode == BuildMode.BuildMode_Episode1)
    1.69 +			{
    1.70 +				makefile_args = null;
    1.71 +			}
    1.72 +			else if (lib.build_mode == BuildMode.BuildMode_Episode2)
    1.73 +			{
    1.74 +				makefile_args = "ENGINE=\"orangebox\"";
    1.75 +			}
    1.76 +			else if (lib.build_mode == BuildMode.BuildMode_OldMetamod)
    1.77 +			{
    1.78 +				makefile_args = "ENGINE=\"original\"";
    1.79 +			}
    1.80 +
    1.81 +			/* Clean the project first */
    1.82 +			info.WorkingDirectory = path;
    1.83 +			info.FileName = cfg.builder_path;
    1.84 +			info.Arguments = makefile_args + " clean";
    1.85 +			info.UseShellExecute = false;
    1.86 +
    1.87 +			Process p = Process.Start(info);
    1.88 +			p.WaitForExit();
    1.89 +			p.Close();
    1.90 +
    1.91 +			/* Now build it */
    1.92 +			info.WorkingDirectory = path;
    1.93 +			info.FileName = cfg.builder_path;
    1.94 +			info.Arguments = makefile_args;
    1.95 +			info.UseShellExecute = false;
    1.96 +
    1.97 +			if (cfg.build_options != null)
    1.98 +			{
    1.99 +				info.Arguments += " " + cfg.build_options;
   1.100 +			}
   1.101 +
   1.102 +			p = Process.Start(info);
   1.103 +			p.WaitForExit();
   1.104 +			p.Close();
   1.105 +
   1.106 +			if (!File.Exists(binpath))
   1.107 +			{
   1.108 +				return false;
   1.109 +			}
   1.110 +			
   1.111 +			path = Config.PathFormat("{0}/{1}/{2}/{3}",
   1.112 +				cfg.pkg_path,
   1.113 +				pkg.GetBaseFolder(),
   1.114 +				lib.package_path,
   1.115 +				binName);
   1.116 +			File.Copy(binpath, path, true);
   1.117 +
   1.118 +			return true;
   1.119 +		}
   1.120 +	}
   1.121 +}