Author: jbevain
Date: 2007-07-05 10:18:17 -0400 (Thu, 05 Jul 2007)
New Revision: 81391
Modified:
trunk/cecil/linker/ChangeLog
trunk/cecil/linker/Mono.Linker/Driver.cs
trunk/cecil/linker/Mono.Linker/Pipeline.cs
Log:
2007-07-05 Jb Evain <[EMAIL PROTECTED]>
* Mono.Linker/Driver.cs
Mono.Linker/Pipeline.cs:
Add a way to install steps in the pipeline
from the outside.
Modified: trunk/cecil/linker/ChangeLog
===================================================================
--- trunk/cecil/linker/ChangeLog 2007-07-05 13:12:13 UTC (rev 81390)
+++ trunk/cecil/linker/ChangeLog 2007-07-05 14:18:17 UTC (rev 81391)
@@ -1,3 +1,10 @@
+2007-07-05 Jb Evain <[EMAIL PROTECTED]>
+
+ * Mono.Linker/Driver.cs
+ Mono.Linker/Pipeline.cs:
+ Add a way to install steps in the pipeline
+ from the outside.
+
2007-07-03 Jb Evain <[EMAIL PROTECTED]>
* Mono.Linker/Driver.cs:
Modified: trunk/cecil/linker/Mono.Linker/Driver.cs
===================================================================
--- trunk/cecil/linker/Mono.Linker/Driver.cs 2007-07-05 13:12:13 UTC (rev
81390)
+++ trunk/cecil/linker/Mono.Linker/Driver.cs 2007-07-05 14:18:17 UTC (rev
81391)
@@ -115,6 +115,9 @@
case 'c':
context.CoreAction = ParseCoreAction
(GetParam ());
break;
+ case 's':
+ AddCustomStep (p, GetParam ());
+ break;
case 'x':
foreach (string file in GetFiles
(GetParam ()))
p.PrependStep (new
ResolveFromXmlStep (new XPathDocument (file)));
@@ -148,6 +151,43 @@
p.Process (context);
}
+ static void AddCustomStep (Pipeline pipeline, string arg)
+ {
+ int pos = arg.IndexOf (":");
+ if (pos == -1) {
+ pipeline.AppendStep (ResolveStep (arg));
+ return;
+ }
+
+ string [] parts = arg.Split (':');
+ if (parts.Length != 2)
+ Usage ();
+
+ if (parts [0].IndexOf (",") > -1)
+ pipeline.AddStepBefore (FindStep (pipeline,
parts [1]), ResolveStep (parts [0]));
+ else if (parts [1].IndexOf (",") > -1)
+ pipeline.AddStepAfter (FindStep (pipeline,
parts [0]), ResolveStep (parts [1]));
+ else
+ Usage ();
+ }
+
+ static Type FindStep (Pipeline pipeline, string name)
+ {
+ foreach (IStep step in pipeline.GetSteps ()) {
+ Type t = step.GetType ();
+ if (t.Name == name)
+ return t;
+ }
+
+ return null;
+ }
+
+ static IStep ResolveStep (string type)
+ {
+ Type step = Type.GetType (type, true);
+ return (IStep) Activator.CreateInstance (step);
+ }
+
static string [] GetFiles (string param)
{
if (param.Length < 1 || param [0] != '@')
Modified: trunk/cecil/linker/Mono.Linker/Pipeline.cs
===================================================================
--- trunk/cecil/linker/Mono.Linker/Pipeline.cs 2007-07-05 13:12:13 UTC (rev
81390)
+++ trunk/cecil/linker/Mono.Linker/Pipeline.cs 2007-07-05 14:18:17 UTC (rev
81391)
@@ -83,5 +83,10 @@
_steps.Remove (step);
}
}
+
+ public IStep [] GetSteps ()
+ {
+ return (IStep []) _steps.ToArray (typeof (IStep));
+ }
}
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches