Advertisement
Guest User

Untitled

a guest
Dec 27th, 2014
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.80 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using Cosmos.Build.MSBuild;
  7. using Cosmos.Debug.Common;
  8. using Microsoft.Build.Framework;
  9. using Microsoft.Build.Utilities;
  10.  
  11. namespace IL2CPU
  12. {
  13.   internal class Program
  14.   {
  15.  
  16.     public const string CosmosRoot = "";//@"e:\OpenSource\Cosmos";
  17.     private const string KernelFile = CosmosRoot + "";// @"\Users\Sentinel209\SentinelKernel\bin\Debug\SentinelKernel.dll";
  18.     private const string OutputFile = CosmosRoot + "";//@"\Users\Sentinel209\SentinelKernel\bin\Debug\SentinelKernelBoot.asm";
  19.     private static  Dictionary<string, string> CmdOptions = new Dictionary<string, string>();
  20.     private static List<ITaskItem>  References = new List<ITaskItem>();
  21.  
  22.     private static void Main(string[] args)
  23.     {
  24.  
  25.    
  26.  
  27.       foreach (var s in args)
  28.       {
  29.         string[] s1 = s.Split(':');
  30.         string argID = s1[0].ToLower();
  31.         string argValue = s1[1];
  32.         if (argID != "References".ToLower())
  33.         {
  34.           CmdOptions.Add(argID, argValue);
  35.         }
  36.         else
  37.         {
  38.           References.Add(new TaskItemImpl(argValue));
  39.         }
  40.  
  41.       }
  42.      
  43.       try
  44.       {
  45.         var xTask = new IL2CPUTask();
  46.         xTask.DebugEnabled = Convert.ToBoolean(CmdOptions["DebugEnabled"].ToLower());
  47.         xTask.StackCorruptionDetectionEnabled = Convert.ToBoolean(CmdOptions["StackCorruptionDetectionEnabled".ToLower()]);
  48.         xTask.DebugMode = CmdOptions["DebugMode".ToLower()];
  49.         xTask.TraceAssemblies = CmdOptions["TraceAssemblies".ToLower()];
  50.         xTask.DebugCom = Convert.ToByte(CmdOptions["DebugCom".ToLower()]);
  51.         xTask.UseNAsm = Convert.ToBoolean(CmdOptions["UseNAsm".ToLower()]);
  52.         xTask.OutputFilename = CmdOptions["OutputFilename".ToLower()]; ;
  53.         xTask.EnableLogging = Convert.ToBoolean(CmdOptions["EnableLogging"].ToLower()); ;
  54.         xTask.EmitDebugSymbols = Convert.ToBoolean(CmdOptions["EmitDebugSymbols"].ToLower()); ;
  55.         xTask.IgnoreDebugStubAttribute = Convert.ToBoolean(CmdOptions["IgnoreDebugStubAttribute"].ToLower());
  56.         xTask.References = References.ToArray();
  57.         xTask.OnLogError = (m) => Console.WriteLine("Error: {0}", m);
  58.         xTask.OnLogWarning = (m) => Console.WriteLine("Warning: {0}", m);
  59.         xTask.OnLogMessage = (m) =>
  60.         {
  61.           Console.WriteLine("Message: {0}", m);
  62.         };
  63.         xTask.OnLogException = (m) => Console.WriteLine("Exception: {0}", m.ToString());
  64.  
  65.         if (xTask.Execute())
  66.         {
  67.           Console.WriteLine("Executed OK");
  68.         }
  69.         else
  70.         {
  71.           Console.WriteLine("Errorred");
  72.         }
  73.  
  74.  
  75.       }
  76.       catch (Exception E)
  77.       {
  78.         Console.Out.Flush();
  79.         Console.WriteLine(E.ToString());
  80.  
  81.         return;
  82.       }
  83.  
  84.       Console.Out.Flush();
  85.  
  86.  
  87.     }
  88.  
  89.     private static ITaskItem[] GetReferences()
  90.     {
  91.       return new ITaskItem[]
  92.       {
  93.         new TaskItemImpl(KernelFile),
  94.         new TaskItemImpl(CosmosRoot + @"\source\Cosmos.Core.Plugs\bin\x86\Debug\Cosmos.Core.Plugs.dll"),
  95.         new TaskItemImpl(CosmosRoot + @"\source\Cosmos.Debug.Kernel.Plugs\bin\x86\Debug\Cosmos.Debug.Kernel.Plugs.dll"),
  96.         new TaskItemImpl(CosmosRoot + @"\source\Cosmos.HAL\bin\x86\Debug\Cosmos.HAL.dll"),
  97.         new TaskItemImpl(CosmosRoot + @"\source\Cosmos.System.Plugs\bin\x86\Debug\Cosmos.System.Plugs.dll"),
  98.         new TaskItemImpl(CosmosRoot + @"\Users\Sentinel209\SentinelSystemLib\bin\Debug\SentinelSystemLib.dll"),
  99.       };
  100.     }
  101.  
  102.     private class TaskItemImpl : ITaskItem
  103.     {
  104.       private string path;
  105.  
  106.       public TaskItemImpl(string path)
  107.       {
  108.         this.path = path;
  109.       }
  110.  
  111.       public System.Collections.IDictionary CloneCustomMetadata()
  112.       {
  113.         throw new NotImplementedException();
  114.       }
  115.  
  116.       public void CopyMetadataTo(ITaskItem destinationItem)
  117.       {
  118.         throw new NotImplementedException();
  119.       }
  120.  
  121.       public string GetMetadata(string metadataName)
  122.       {
  123.         if (metadataName == "FullPath")
  124.         {
  125.           return path;
  126.         }
  127.         throw new NotImplementedException();
  128.       }
  129.  
  130.       public string ItemSpec
  131.       {
  132.         get { throw new NotImplementedException(); }
  133.         set { throw new NotImplementedException(); }
  134.       }
  135.  
  136.       public int MetadataCount
  137.       {
  138.         get { return MetadataNames.Count; }
  139.       }
  140.  
  141.       public System.Collections.ICollection MetadataNames
  142.       {
  143.         get { return new String[] {"FullPath"}; }
  144.       }
  145.  
  146.       public void RemoveMetadata(string metadataName)
  147.       {
  148.         throw new NotImplementedException();
  149.       }
  150.  
  151.       public void SetMetadata(string metadataName, string metadataValue)
  152.       {
  153.         throw new NotImplementedException();
  154.       }
  155.     }
  156.   }
  157. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement