mirror of
https://github.com/danbulant/Cosmos
synced 2026-06-12 11:11:45 +00:00
Code cleanup
This commit is contained in:
parent
71647fa672
commit
8a5d0395f7
6 changed files with 50 additions and 225 deletions
|
|
@ -5,7 +5,6 @@ using System.Text;
|
|||
using System.Threading.Tasks;
|
||||
using Cosmos.Build.MSBuild;
|
||||
using Cosmos.Debug.Common;
|
||||
using Microsoft.Build.Framework;
|
||||
|
||||
namespace Cosmos.Compiler.TestsBase
|
||||
{
|
||||
|
|
@ -75,82 +74,14 @@ namespace Cosmos.Compiler.TestsBase
|
|||
}
|
||||
}
|
||||
|
||||
private ITaskItem[] GetReferences()
|
||||
private string[] GetReferences()
|
||||
{
|
||||
var xResult = new List<ITaskItem>(References.Count);
|
||||
var xResult = new List<string>(References.Count);
|
||||
foreach (var xRefFile in References)
|
||||
{
|
||||
xResult.Add(new TaskItemImpl(xRefFile));
|
||||
xResult.Add(xRefFile);
|
||||
}
|
||||
return xResult.ToArray();
|
||||
}
|
||||
|
||||
private class TaskItemImpl : ITaskItem
|
||||
{
|
||||
private string path;
|
||||
|
||||
public TaskItemImpl(string path)
|
||||
{
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
public System.Collections.IDictionary CloneCustomMetadata()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void CopyMetadataTo(ITaskItem destinationItem)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public string GetMetadata(string metadataName)
|
||||
{
|
||||
if (metadataName == "FullPath")
|
||||
{
|
||||
return path;
|
||||
}
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public string ItemSpec
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
set
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
public int MetadataCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return MetadataNames.Count;
|
||||
}
|
||||
}
|
||||
|
||||
public System.Collections.ICollection MetadataNames
|
||||
{
|
||||
get
|
||||
{
|
||||
return new String[] { "FullPath" };
|
||||
}
|
||||
}
|
||||
|
||||
public void RemoveMetadata(string metadataName)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SetMetadata(string metadataName, string metadataValue)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -103,84 +103,17 @@ namespace DebugCompiler
|
|||
Console.WriteLine("SQL: {0}", e.Message);
|
||||
}
|
||||
|
||||
private static ITaskItem[] GetReferences()
|
||||
private static string[] GetReferences()
|
||||
{
|
||||
return new ITaskItem[]
|
||||
return new string[]
|
||||
{
|
||||
new TaskItemImpl(KernelFile),
|
||||
new TaskItemImpl(CosmosRoot + @"\source\Cosmos.Core.Plugs\bin\x86\Debug\Cosmos.Core.Plugs.dll"),
|
||||
new TaskItemImpl(CosmosRoot + @"\source\Cosmos.Debug.Kernel.Plugs\bin\x86\Debug\Cosmos.Debug.Kernel.Plugs.dll"),
|
||||
new TaskItemImpl(CosmosRoot + @"\source\Cosmos.HAL\bin\x86\Debug\Cosmos.HAL.dll"),
|
||||
new TaskItemImpl(CosmosRoot + @"\source\Cosmos.System.Plugs\bin\x86\Debug\Cosmos.System.Plugs.dll"),
|
||||
new TaskItemImpl(CosmosRoot + @"\Users\Sentinel209\SentinelSystemLib\bin\Debug\SentinelSystemLib.dll"),
|
||||
KernelFile,
|
||||
CosmosRoot + @"\source\Cosmos.Core.Plugs\bin\x86\Debug\Cosmos.Core.Plugs.dll",
|
||||
CosmosRoot + @"\source\Cosmos.Debug.Kernel.Plugs\bin\x86\Debug\Cosmos.Debug.Kernel.Plugs.dll",
|
||||
CosmosRoot + @"\source\Cosmos.HAL\bin\x86\Debug\Cosmos.HAL.dll",
|
||||
CosmosRoot + @"\source\Cosmos.System.Plugs\bin\x86\Debug\Cosmos.System.Plugs.dll",
|
||||
CosmosRoot + @"\Users\Sentinel209\SentinelSystemLib\bin\Debug\SentinelSystemLib.dll",
|
||||
};
|
||||
}
|
||||
|
||||
private class TaskItemImpl : ITaskItem
|
||||
{
|
||||
private string path;
|
||||
|
||||
public TaskItemImpl(string path)
|
||||
{
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
public System.Collections.IDictionary CloneCustomMetadata()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void CopyMetadataTo(ITaskItem destinationItem)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public string GetMetadata(string metadataName)
|
||||
{
|
||||
if (metadataName == "FullPath")
|
||||
{
|
||||
return path;
|
||||
}
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public string ItemSpec
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
set
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
public int MetadataCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return MetadataNames.Count;
|
||||
}
|
||||
}
|
||||
|
||||
public System.Collections.ICollection MetadataNames
|
||||
{
|
||||
get
|
||||
{
|
||||
return new String[] { "FullPath" };
|
||||
}
|
||||
}
|
||||
|
||||
public void RemoveMetadata(string metadataName)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SetMetadata(string metadataName, string metadataValue)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ namespace Cosmos.Build.MSBuild
|
|||
}
|
||||
foreach (var xOutput in mOutput)
|
||||
{
|
||||
Log.LogError(xOutput);
|
||||
Log.LogMessage(xOutput);
|
||||
}
|
||||
return xProcess.ExitCode == 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ using System.Diagnostics;
|
|||
namespace Cosmos.Build.MSBuild {
|
||||
public class IL2CPU : BaseToolTask
|
||||
{
|
||||
// protected IL2CPUTask mTask = new IL2CPUTask();
|
||||
// protected IL2CPUTask mTask = new IL2CPUTask();
|
||||
|
||||
[Required]
|
||||
public string CosmosBuildDir
|
||||
|
|
@ -33,7 +33,7 @@ namespace Cosmos.Build.MSBuild {
|
|||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
|
||||
[Required]
|
||||
public string DebugMode {
|
||||
get;
|
||||
|
|
@ -47,7 +47,7 @@ namespace Cosmos.Build.MSBuild {
|
|||
|
||||
public bool StackCorruptionDetectionEnabled
|
||||
{
|
||||
get;
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
|
|
@ -118,25 +118,6 @@ namespace Cosmos.Build.MSBuild {
|
|||
var xSW = Stopwatch.StartNew();
|
||||
|
||||
try {
|
||||
/* mTask.OnLogMessage = LogMessage;
|
||||
mTask.OnLogError = LogError;
|
||||
mTask.OnLogWarning = LogWarning;
|
||||
mTask.OnLogException = LogException;
|
||||
|
||||
mTask.DebugEnabled = DebugEnabled;
|
||||
mTask.StackCorruptionDetectionEnabled = StackCorruptionDetectionEnabled;
|
||||
mTask.DebugMode = DebugMode;
|
||||
mTask.TraceAssemblies = TraceAssemblies;
|
||||
mTask.DebugCom = DebugCom;
|
||||
mTask.UseNAsm = UseNAsm;
|
||||
mTask.References = References;
|
||||
mTask.OutputFilename = OutputFilename;
|
||||
mTask.EnableLogging = EnableLogging;
|
||||
mTask.EmitDebugSymbols = EmitDebugSymbols;
|
||||
mTask.IgnoreDebugStubAttribute = IgnoreDebugStubAttribute;
|
||||
|
||||
*/
|
||||
|
||||
Dictionary<string,string> args = new Dictionary<string, string>();
|
||||
args.Add("DebugEnabled", Convert.ToString(DebugEnabled));
|
||||
args.Add("StackCorruptionDetectionEnabled", Convert.ToString(StackCorruptionDetectionEnabled));
|
||||
|
|
@ -148,17 +129,12 @@ namespace Cosmos.Build.MSBuild {
|
|||
List<string> refs = new List<string>();
|
||||
foreach (var reference in References)
|
||||
{
|
||||
|
||||
if (reference.MetadataNames.OfType<string>().Contains("FullPath"))
|
||||
{
|
||||
string xFile = reference.GetMetadata("FullPath");
|
||||
refs.Add(Convert.ToString(xFile));
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (reference.MetadataNames.OfType<string>().Contains("FullPath"))
|
||||
{
|
||||
string xFile = reference.GetMetadata("FullPath");
|
||||
refs.Add(Convert.ToString(xFile));
|
||||
}
|
||||
}
|
||||
// refs.RemoveAt(refs.Count - 1);
|
||||
|
||||
args.Add("OutputFilename", Convert.ToString(OutputFilename));
|
||||
args.Add("EnableLogging", Convert.ToString(EnableLogging));
|
||||
|
|
@ -174,12 +150,10 @@ namespace Cosmos.Build.MSBuild {
|
|||
{
|
||||
Arguments += "\"References:" + Ref + "\" ";
|
||||
}
|
||||
return base.ExecuteTool(WorkingDir,
|
||||
return base.ExecuteTool(WorkingDir,
|
||||
Path.Combine(CosmosBuildDir, @"IL2CPU\IL2CPU.exe"),
|
||||
Arguments,
|
||||
"IL2CPU");
|
||||
|
||||
// return mTask.Execute();
|
||||
} finally {
|
||||
xSW.Stop();
|
||||
Log.LogMessage(MessageImportance.High,
|
||||
|
|
@ -191,4 +165,4 @@ namespace Cosmos.Build.MSBuild {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,21 +1,11 @@
|
|||
using Cosmos.Build.Common;
|
||||
using Cosmos.Assembler;
|
||||
using Cosmos.Assembler.x86;
|
||||
using Cosmos.IL2CPU.X86;
|
||||
using Cosmos.IL2CPU;
|
||||
using Cosmos.System;
|
||||
using Microsoft.Win32;
|
||||
using Microsoft.Build.Utilities;
|
||||
using Microsoft.Build.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Data;
|
||||
using System.Configuration;
|
||||
using System.Data.SQLite;
|
||||
using System.Reflection;
|
||||
using System.Reflection.Emit;
|
||||
using System.Text;
|
||||
using Cosmos.Debug.Common;
|
||||
|
||||
|
|
@ -36,7 +26,7 @@ namespace Cosmos.Build.MSBuild
|
|||
public string TraceAssemblies { get; set; }
|
||||
public byte DebugCom { get; set; }
|
||||
public bool UseNAsm { get; set; }
|
||||
public ITaskItem[] References { get; set; }
|
||||
public string[] References { get; set; }
|
||||
public string OutputFilename { get; set; }
|
||||
public bool EnableLogging { get; set; }
|
||||
public bool EmitDebugSymbols { get; set; }
|
||||
|
|
@ -137,13 +127,13 @@ namespace Cosmos.Build.MSBuild
|
|||
mSearchDirs.Add(CosmosPaths.Kernel);
|
||||
AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
|
||||
|
||||
// This seems to be to try to load plugs on demand from their own dirs, but
|
||||
// it often just causes load conflicts, and weird errors like "implementation not found"
|
||||
// This seems to be to try to load plugs on demand from their own dirs, but
|
||||
// it often just causes load conflicts, and weird errors like "implementation not found"
|
||||
// for a method, even when both the output user kit dir and local bin dir have up to date
|
||||
// and same assemblies.
|
||||
// So its removed for now and we should find a better way to dynamically load plugs in
|
||||
// and same assemblies.
|
||||
// So its removed for now and we should find a better way to dynamically load plugs in
|
||||
// future.
|
||||
// Furthermore, it only scanned plugs/asms reffed from the boot proj, not the kernel proj
|
||||
// Furthermore, it only scanned plugs/asms reffed from the boot proj, not the kernel proj
|
||||
// so it was bugged there too.
|
||||
//if (References != null) {
|
||||
// foreach (var xRef in References) {
|
||||
|
|
@ -321,31 +311,28 @@ namespace Cosmos.Build.MSBuild
|
|||
Type xKernelType = null;
|
||||
foreach (var xRef in References)
|
||||
{
|
||||
if (xRef.MetadataNames.OfType<string>().Contains("FullPath"))
|
||||
if (File.Exists(xRef))
|
||||
{
|
||||
var xAssembly = Assembly.LoadFile(xRef);
|
||||
foreach (var xType in xAssembly.GetExportedTypes())
|
||||
{
|
||||
var xFile = xRef.GetMetadata("FullPath");
|
||||
if (File.Exists(xFile))
|
||||
if (!xType.IsGenericTypeDefinition
|
||||
&& !xType.IsAbstract)
|
||||
{
|
||||
if (xType.IsSubclassOf(typeof(Kernel)))
|
||||
{
|
||||
var xAssembly = Assembly.LoadFile(xFile);
|
||||
foreach (var xType in xAssembly.GetExportedTypes())
|
||||
{
|
||||
if (!xType.IsGenericTypeDefinition && !xType.IsAbstract)
|
||||
{
|
||||
if (xType.IsSubclassOf(typeof(Kernel)))
|
||||
{
|
||||
// found kernel?
|
||||
if (xKernelType != null)
|
||||
{
|
||||
// already a kernel found, which is not supported.
|
||||
LogError(string.Format("Two kernels found! '{0}' and '{1}'", xType.AssemblyQualifiedName, xKernelType.AssemblyQualifiedName));
|
||||
return null;
|
||||
}
|
||||
xKernelType = xType;
|
||||
}
|
||||
}
|
||||
}
|
||||
// found kernel?
|
||||
if (xKernelType != null)
|
||||
{
|
||||
// already a kernel found, which is not supported.
|
||||
LogError(string.Format("Two kernels found! '{0}' and '{1}'", xType.AssemblyQualifiedName, xKernelType.AssemblyQualifiedName));
|
||||
return null;
|
||||
}
|
||||
xKernelType = xType;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (xKernelType == null)
|
||||
{
|
||||
|
|
@ -361,4 +348,4 @@ namespace Cosmos.Build.MSBuild
|
|||
return xCtor;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ namespace IL2CPU
|
|||
private const string KernelFile = CosmosRoot + "";// @"\Users\Sentinel209\SentinelKernel\bin\Debug\SentinelKernel.dll";
|
||||
private const string OutputFile = CosmosRoot + "";//@"\Users\Sentinel209\SentinelKernel\bin\Debug\SentinelKernelBoot.asm";
|
||||
private static Dictionary<string, string> CmdOptions = new Dictionary<string, string>();
|
||||
private static List<ITaskItem> References = new List<ITaskItem>();
|
||||
private static List<string> References = new List<string>();
|
||||
|
||||
private static int Main(string[] args)
|
||||
{
|
||||
|
|
@ -37,7 +37,7 @@ namespace IL2CPU
|
|||
else
|
||||
{
|
||||
|
||||
References.Add(new TaskItemImpl(s.Replace(s1[0] + ":","")));
|
||||
References.Add(s.Replace(s1[0] + ":",""));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -72,7 +72,7 @@ namespace IL2CPU
|
|||
xTask.OnLogWarning = (m) => Console.WriteLine("Warning: {0}", m);
|
||||
xTask.OnLogMessage = (m) =>
|
||||
{
|
||||
Console.WriteLine("Message: {0}", m);
|
||||
//Console.WriteLine("Message: {0}", m);
|
||||
};
|
||||
xTask.OnLogException = (m) => Console.WriteLine("Exception: {0}", m.ToString());
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue