added plugin compiling

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40858
This commit is contained in:
David Anderson 2007-05-23 22:08:05 +00:00
parent 942c3acd8e
commit 150cb6ec1f
5 changed files with 112 additions and 1 deletions

View File

@ -16,6 +16,62 @@ namespace builder
public abstract bool BuildLibrary(Package pkg, Library lib, ref string _binName, ref string _binPath);
public abstract string GetPawnCompilerName();
public bool CompilePlugin(Package pkg, Plugin pl)
{
string local_dir = Config.PathFormat("{0}/{1}/scripting", cfg.OutputBase, pkg.GetBaseFolder());
string filepath = null;
if (pl.Folder != null)
{
filepath = Config.PathFormat("{0}/{1}", pl.Folder, pl.Source);
}
else
{
filepath = pl.Source;
}
ProcessStartInfo info = new ProcessStartInfo();
info.WorkingDirectory = local_dir;
info.FileName = Config.PathFormat("{0}/{1}", local_dir, GetPawnCompilerName());
info.Arguments = filepath + ".sp";
info.UseShellExecute = false;
info.RedirectStandardOutput = true;
info.RedirectStandardError = true;
Process p = Process.Start(info);
string output = p.StandardOutput.ReadToEnd() + "\n";
output += p.StandardError.ReadToEnd();
p.WaitForExit();
p.Close();
Console.WriteLine(output);
string binary = Config.PathFormat("{0}/{1}/scripting/{2}.smx", cfg.OutputBase, pkg.GetBaseFolder(), pl.Source);
if (!File.Exists(binary))
{
return false;
}
string new_loc = Config.PathFormat("{0}/{1}/plugins/{2}.smx", cfg.OutputBase, pkg.GetBaseFolder(), pl.Source);
try
{
if (File.Exists(new_loc))
{
File.Delete(new_loc);
}
File.Move(binary, new_loc);
}
catch (System.Exception e)
{
Console.WriteLine(e.Message);
return false;
}
return true;
}
public string GetRevsionOfPath(string path)
{
ProcessStartInfo info = new ProcessStartInfo();
@ -172,6 +228,19 @@ namespace builder
}
}
/* Do plugins */
Plugin [] plugins = pkg.GetPlugins();
if (plugins != null)
{
for (int i=0; i<plugins.Length; i++)
{
if (!CompilePlugin(pkg, plugins[i]))
{
throw new System.Exception("Failed to compile plugin: " + plugins[i].Source);
}
}
}
string pkg_file = null;
if (cfg.Compressor != null)
{

View File

@ -11,6 +11,11 @@ namespace builder
cfg = _cfg;
}
public override string GetPawnCompilerName()
{
return "spcomp";
}
public override string CompressPackage(Package pkg)
{
string lpath = null, ltarget = null;

View File

@ -7,7 +7,6 @@ namespace builder
public Library()
{
PlatformExt = false;
ProjectFile = null;
IsExecutable = false;
ReleaseBuild = "Release";
}
@ -21,6 +20,21 @@ namespace builder
//string DebugBuild; /* Debug build name */
};
public class Plugin
{
public Plugin(string file)
{
Source = file;
}
public Plugin (string file, string folder)
{
Source = file;
Folder = folder;
}
public string Folder; /* Source folder relative to scripting (null for default) */
public string Source; /* Source file name */
};
public abstract class Package
{
/**
@ -57,5 +71,10 @@ namespace builder
* Called to get package name
*/
public abstract string GetPackageName();
/**
* Called to get a plugin list
*/
public abstract Plugin [] GetPlugins();
}
}

View File

@ -115,6 +115,19 @@ namespace builder
return libs;
}
/**
* Called to build plugins
*/
public override Plugin [] GetPlugins()
{
Plugin [] plugins = new Plugin[2];
plugins[0] = new Plugin("admin-auth");
plugins[1] = new Plugin("admin-flatfile", "admin-flatfile");
return plugins;
}
}
}

View File

@ -11,6 +11,11 @@ namespace builder
cfg = _cfg;
}
public override string GetPawnCompilerName()
{
return "spcomp.exe";
}
public override string CompressPackage(Package pkg)
{
string lpath = null, ltarget = null;