tools/builder/ABuilder.cs
changeset 852 9a7a93363979
parent 806 20f67c32aeb8
child 984 c996eafa2d16
     1.1 --- a/tools/builder/ABuilder.cs	Wed May 23 20:24:28 2007 +0000
     1.2 +++ b/tools/builder/ABuilder.cs	Wed May 23 22:08:05 2007 +0000
     1.3 @@ -16,6 +16,62 @@
     1.4  
     1.5  		public abstract bool BuildLibrary(Package pkg, Library lib, ref string _binName, ref string _binPath);
     1.6  
     1.7 +		public abstract string GetPawnCompilerName();
     1.8 +
     1.9 +		public bool CompilePlugin(Package pkg, Plugin pl)
    1.10 +		{
    1.11 +			string local_dir = Config.PathFormat("{0}/{1}/scripting", cfg.OutputBase, pkg.GetBaseFolder());
    1.12 +
    1.13 +			string filepath = null;
    1.14 +			if (pl.Folder != null)
    1.15 +			{
    1.16 +				filepath = Config.PathFormat("{0}/{1}", pl.Folder, pl.Source);
    1.17 +			} 
    1.18 +			else 
    1.19 +			{
    1.20 +				filepath = pl.Source;
    1.21 +			}
    1.22 +
    1.23 +			ProcessStartInfo info = new ProcessStartInfo();
    1.24 +			info.WorkingDirectory = local_dir;
    1.25 +			info.FileName = Config.PathFormat("{0}/{1}", local_dir, GetPawnCompilerName());
    1.26 +			info.Arguments = filepath + ".sp";
    1.27 +			info.UseShellExecute = false;
    1.28 +			info.RedirectStandardOutput = true;
    1.29 +			info.RedirectStandardError = true;
    1.30 +
    1.31 +			Process p = Process.Start(info);
    1.32 +			string output = p.StandardOutput.ReadToEnd() + "\n";
    1.33 +			output += p.StandardError.ReadToEnd();
    1.34 +			p.WaitForExit();
    1.35 +			p.Close();
    1.36 +
    1.37 +			Console.WriteLine(output);
    1.38 +
    1.39 +			string binary = Config.PathFormat("{0}/{1}/scripting/{2}.smx", cfg.OutputBase, pkg.GetBaseFolder(), pl.Source);
    1.40 +			if (!File.Exists(binary))
    1.41 +			{
    1.42 +				return false;
    1.43 +			}
    1.44 +			string new_loc = Config.PathFormat("{0}/{1}/plugins/{2}.smx", cfg.OutputBase, pkg.GetBaseFolder(), pl.Source);
    1.45 +
    1.46 +			try
    1.47 +			{
    1.48 +				if (File.Exists(new_loc))
    1.49 +				{
    1.50 +					File.Delete(new_loc);
    1.51 +				}
    1.52 +				File.Move(binary, new_loc);
    1.53 +			}
    1.54 +			catch (System.Exception e)
    1.55 +			{
    1.56 +				Console.WriteLine(e.Message);
    1.57 +				return false;
    1.58 +			}
    1.59 +
    1.60 +			return true;
    1.61 +		}
    1.62 +
    1.63  		public string GetRevsionOfPath(string path)
    1.64  		{
    1.65  			ProcessStartInfo info = new ProcessStartInfo();
    1.66 @@ -172,6 +228,19 @@
    1.67  				}
    1.68  			}
    1.69  
    1.70 +			/* Do plugins */
    1.71 +			Plugin [] plugins = pkg.GetPlugins();
    1.72 +			if (plugins != null)
    1.73 +			{
    1.74 +				for (int i=0; i<plugins.Length; i++)
    1.75 +				{
    1.76 +					if (!CompilePlugin(pkg, plugins[i]))
    1.77 +					{
    1.78 +						throw new System.Exception("Failed to compile plugin: " + plugins[i].Source);
    1.79 +					}
    1.80 +				}
    1.81 +			}
    1.82 +
    1.83  			string pkg_file = null;
    1.84  			if (cfg.Compressor != null)
    1.85  			{