mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-18 03:39:04 -04:00
Compiling now includes source filenames at end in success message (thanks Venk)
This commit is contained in:
parent
ca8f6eba59
commit
f82ea2cb51
@ -32,7 +32,7 @@ namespace MCGalaxy.Commands.Scripting {
|
|||||||
if (!Formatter.ValidFilename(p, args[0])) return;
|
if (!Formatter.ValidFilename(p, args[0])) return;
|
||||||
|
|
||||||
string language = args.Length > 1 ? args[1] : "";
|
string language = args.Length > 1 ? args[1] : "";
|
||||||
ICompiler engine = ICompiler.Lookup(language, p);
|
ICompiler engine = ScriptingOperations.GetCompiler(p, language);
|
||||||
if (engine == null) return;
|
if (engine == null) return;
|
||||||
|
|
||||||
string path = engine.CommandPath(args[0]);
|
string path = engine.CommandPath(args[0]);
|
||||||
|
@ -32,7 +32,7 @@ namespace MCGalaxy.Commands.Scripting {
|
|||||||
if (!Formatter.ValidFilename(p, args[0])) return;
|
if (!Formatter.ValidFilename(p, args[0])) return;
|
||||||
|
|
||||||
string language = args.Length > 1 ? args[1] : "";
|
string language = args.Length > 1 ? args[1] : "";
|
||||||
ICompiler compiler = ICompiler.Lookup(language, p);
|
ICompiler compiler = ScriptingOperations.GetCompiler(p, language);
|
||||||
if (compiler == null) return;
|
if (compiler == null) return;
|
||||||
|
|
||||||
// either "source" or "source1,source2,source3"
|
// either "source" or "source1,source2,source3"
|
||||||
|
@ -61,7 +61,7 @@ namespace MCGalaxy.Commands.Scripting {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void CompilePlugin(Player p, string name, string language) {
|
static void CompilePlugin(Player p, string name, string language) {
|
||||||
ICompiler compiler = ICompiler.Lookup(language, p);
|
ICompiler compiler = ScriptingOperations.GetCompiler(p, language);
|
||||||
if (compiler == null) return;
|
if (compiler == null) return;
|
||||||
|
|
||||||
// either "source" or "source1,source2,source3"
|
// either "source" or "source1,source2,source3"
|
||||||
@ -110,7 +110,7 @@ namespace MCGalaxy.Commands.Scripting {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void CreatePlugin(Player p, string name, string language) {
|
static void CreatePlugin(Player p, string name, string language) {
|
||||||
ICompiler engine = ICompiler.Lookup(language, p);
|
ICompiler engine = ScriptingOperations.GetCompiler(p, language);
|
||||||
if (engine == null) return;
|
if (engine == null) return;
|
||||||
|
|
||||||
string path = engine.PluginPath(name);
|
string path = engine.PluginPath(name);
|
||||||
|
@ -200,20 +200,7 @@ namespace MCGalaxy.Scripting
|
|||||||
public static ICompiler VB = new VBCompiler();
|
public static ICompiler VB = new VBCompiler();
|
||||||
|
|
||||||
public static List<ICompiler> Compilers = new List<ICompiler>() { CS, VB };
|
public static List<ICompiler> Compilers = new List<ICompiler>() { CS, VB };
|
||||||
|
|
||||||
|
|
||||||
public static ICompiler Lookup(string name, Player p) {
|
|
||||||
if (name.Length == 0) return Compilers[0];
|
|
||||||
|
|
||||||
foreach (ICompiler comp in Compilers) {
|
|
||||||
if (comp.ShortName.CaselessEq(name)) return comp;
|
|
||||||
}
|
|
||||||
|
|
||||||
p.Message("&WUnknown language \"{0}\"", name);
|
|
||||||
p.Message("&HAvailable languages: &f{0}",
|
|
||||||
Compilers.Join(c => c.ShortName + " (" + c.FullName + ")"));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
static string FormatSource(string source, params string[] args) {
|
static string FormatSource(string source, params string[] args) {
|
||||||
// Always use \r\n line endings so it looks correct in Notepad
|
// Always use \r\n line endings so it looks correct in Notepad
|
||||||
|
@ -28,6 +28,21 @@ namespace MCGalaxy.Scripting
|
|||||||
{
|
{
|
||||||
public static class ScriptingOperations
|
public static class ScriptingOperations
|
||||||
{
|
{
|
||||||
|
public static ICompiler GetCompiler(Player p, string name) {
|
||||||
|
if (name.Length == 0) return ICompiler.Compilers[0];
|
||||||
|
|
||||||
|
foreach (ICompiler comp in ICompiler.Compilers)
|
||||||
|
{
|
||||||
|
if (comp.ShortName.CaselessEq(name)) return comp;
|
||||||
|
}
|
||||||
|
|
||||||
|
p.Message("&WUnknown language \"{0}\"", name);
|
||||||
|
p.Message("&HAvailable languages: &f{0}",
|
||||||
|
ICompiler.Compilers.Join(c => c.ShortName + " (" + c.FullName + ")"));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const int MAX_LOG = 2;
|
const int MAX_LOG = 2;
|
||||||
|
|
||||||
/// <summary> Attempts to compile the given source code files into a .dll </summary>
|
/// <summary> Attempts to compile the given source code files into a .dll </summary>
|
||||||
@ -48,7 +63,8 @@ namespace MCGalaxy.Scripting
|
|||||||
|
|
||||||
CompilerResults results = compiler.Compile(srcs, dst);
|
CompilerResults results = compiler.Compile(srcs, dst);
|
||||||
if (!results.Errors.HasErrors) {
|
if (!results.Errors.HasErrors) {
|
||||||
p.Message("{0} compiled successfully.", type);
|
p.Message("{0} compiled successfully from {1}",
|
||||||
|
type, srcs.Join(file => Path.GetFileName(file)));
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user