2007-09-28 08:56:18 +00:00
|
|
|
|
|
|
|
#region ================== Copyright (c) 2007 Pascal vd Heiden
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2007 Pascal vd Heiden, www.codeimp.com
|
|
|
|
* This program is released under GNU General Public License
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Namespaces
|
|
|
|
|
|
|
|
using System;
|
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Globalization;
|
|
|
|
using System.Text;
|
|
|
|
using CodeImp.DoomBuilder.IO;
|
2007-10-01 20:53:10 +00:00
|
|
|
using CodeImp.DoomBuilder.Data;
|
2007-09-28 08:56:18 +00:00
|
|
|
using System.IO;
|
|
|
|
using System.Diagnostics;
|
2007-10-13 14:05:45 +00:00
|
|
|
using System.Windows.Forms;
|
2008-11-14 10:44:03 +00:00
|
|
|
using CodeImp.DoomBuilder.Compilers;
|
2007-09-28 08:56:18 +00:00
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
2007-10-21 18:06:10 +00:00
|
|
|
namespace CodeImp.DoomBuilder.Config
|
2007-09-28 08:56:18 +00:00
|
|
|
{
|
2008-01-02 21:49:43 +00:00
|
|
|
internal class NodebuilderInfo : IComparable<NodebuilderInfo>
|
2007-09-28 08:56:18 +00:00
|
|
|
{
|
|
|
|
#region ================== Constants
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Variables
|
|
|
|
|
|
|
|
private string name;
|
2007-10-10 09:05:53 +00:00
|
|
|
private string title;
|
2007-10-13 14:05:45 +00:00
|
|
|
private CompilerInfo compiler;
|
|
|
|
private string parameters;
|
|
|
|
private bool specialoutputfile;
|
2007-09-28 08:56:18 +00:00
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Properties
|
|
|
|
|
|
|
|
public string Name { get { return name; } }
|
2007-10-10 09:05:53 +00:00
|
|
|
public string Title { get { return title; } }
|
2007-10-13 14:05:45 +00:00
|
|
|
public CompilerInfo Compiler { get { return compiler; } }
|
|
|
|
public string Parameters { get { return parameters; } }
|
|
|
|
public bool HasSpecialOutputFile { get { return specialoutputfile; } }
|
2007-09-28 08:56:18 +00:00
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Constructor / Disposer
|
|
|
|
|
|
|
|
// Constructor
|
2007-10-10 09:05:53 +00:00
|
|
|
public NodebuilderInfo(string filename, string name, Configuration cfg)
|
2007-09-28 08:56:18 +00:00
|
|
|
{
|
2007-10-13 14:05:45 +00:00
|
|
|
string compilername;
|
|
|
|
|
2007-10-10 09:05:53 +00:00
|
|
|
General.WriteLogLine("Registered nodebuilder configuration '" + name + "' from '" + filename + "'");
|
2008-11-14 16:19:25 +00:00
|
|
|
|
2007-10-10 09:05:53 +00:00
|
|
|
// Initialize
|
|
|
|
this.name = name;
|
2007-10-13 14:05:45 +00:00
|
|
|
this.compiler = null;
|
|
|
|
this.title = cfg.ReadSetting("nodebuilders." + name + ".title", "<untitled configuration>");
|
|
|
|
compilername = cfg.ReadSetting("nodebuilders." + name + ".compiler", "");
|
|
|
|
this.parameters = cfg.ReadSetting("nodebuilders." + name + ".parameters", "");
|
|
|
|
|
|
|
|
// Check for special output filename
|
2008-11-14 10:44:03 +00:00
|
|
|
this.specialoutputfile = this.parameters.Contains("%FO");
|
2007-10-13 14:05:45 +00:00
|
|
|
|
|
|
|
// Find compiler
|
|
|
|
foreach(CompilerInfo c in General.Compilers)
|
|
|
|
{
|
|
|
|
// Compiler name matches?
|
|
|
|
if(c.Name == compilername)
|
|
|
|
{
|
|
|
|
// Apply compiler
|
|
|
|
this.compiler = c;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2008-11-14 10:44:03 +00:00
|
|
|
|
2007-10-13 14:05:45 +00:00
|
|
|
// No compiler found?
|
|
|
|
if(this.compiler == null) throw new Exception("No such compiler defined: '" + compilername + "'");
|
2007-09-28 08:56:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Methods
|
|
|
|
|
|
|
|
// This compares it to other ConfigurationInfo objects
|
|
|
|
public int CompareTo(NodebuilderInfo other)
|
|
|
|
{
|
|
|
|
// Compare
|
|
|
|
return name.CompareTo(other.name);
|
|
|
|
}
|
2008-11-14 10:44:03 +00:00
|
|
|
|
2007-09-28 08:56:18 +00:00
|
|
|
// String representation
|
|
|
|
public override string ToString()
|
|
|
|
{
|
2007-10-10 09:05:53 +00:00
|
|
|
return title;
|
2007-09-28 08:56:18 +00:00
|
|
|
}
|
|
|
|
|
2007-10-13 14:05:45 +00:00
|
|
|
// This runs the nodebuilder
|
2008-11-14 16:19:25 +00:00
|
|
|
public Compiler CreateCompiler()
|
2007-10-13 14:05:45 +00:00
|
|
|
{
|
2008-11-14 16:19:25 +00:00
|
|
|
return compiler.Create();
|
2007-10-13 14:05:45 +00:00
|
|
|
}
|
|
|
|
|
2007-09-28 08:56:18 +00:00
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
}
|