X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fclass%2FMicrosoft.Build.Tasks%2FMicrosoft.Build.Tasks%2FManagedCompiler.cs;h=461f2f6c648c641961b33bde4cb3fdc0ea8a6d4a;hb=9b2e52a86a4191314a3dc690e046d74cf766927e;hp=f2c11375b71ddff95653b4199b7988161f7a6eb9;hpb=881f83658281916d8f0784df7c726ecb7cc289db;p=mono.git diff --git a/mcs/class/Microsoft.Build.Tasks/Microsoft.Build.Tasks/ManagedCompiler.cs b/mcs/class/Microsoft.Build.Tasks/Microsoft.Build.Tasks/ManagedCompiler.cs index f2c11375b71..461f2f6c648 100644 --- a/mcs/class/Microsoft.Build.Tasks/Microsoft.Build.Tasks/ManagedCompiler.cs +++ b/mcs/class/Microsoft.Build.Tasks/Microsoft.Build.Tasks/ManagedCompiler.cs @@ -29,9 +29,11 @@ using System; using System.Collections; +using System.Collections.Generic; using System.IO; using System.Text; using Microsoft.Build.Framework; +using Microsoft.Build.Utilities; namespace Microsoft.Build.Tasks { public abstract class ManagedCompiler : ToolTaskExtension { @@ -44,70 +46,82 @@ namespace Microsoft.Build.Tasks { protected internal override void AddCommandLineCommands ( CommandLineBuilderExtension commandLine) { + if (NoConfig) + commandLine.AppendSwitch ("/noconfig"); } [MonoTODO] protected internal override void AddResponseFileCommands ( CommandLineBuilderExtension commandLine) { - commandLine.AppendSwitchIfNotNull ("/lib:", AdditionalLibPaths, ","); - commandLine.AppendSwitchIfNotNull ("/addmodule:", AddModules, ","); - //commandLine.AppendSwitchIfNotNull ("/codepage:", CodePage.ToString ()); - //debugType - commandLine.AppendSwitchIfNotNull ("/define:", DefineConstants); - //delaySign - if (EmitDebugInformation) - commandLine.AppendSwitch ("/debug"); + if (AddModules != null && AddModules.Length > 0) + commandLine.AppendSwitchIfNotNull ("/addmodule:", AddModules, ","); + if (Bag ["CodePage"] != null) + commandLine.AppendSwitchIfNotNull ("/codepage:", CodePage.ToString ()); + + commandLine.AppendSwitchIfNotNull ("/debug:", DebugType); + + if (Bag ["DelaySign"] != null) + if (DelaySign) + commandLine.AppendSwitch ("/delaysign+"); + else + commandLine.AppendSwitch ("/delaysign-"); + if (Bag ["EmitDebugInformation"] != null) + if (EmitDebugInformation) + commandLine.AppendSwitch ("/debug+"); + else + commandLine.AppendSwitch ("/debug-"); //fileAlignment commandLine.AppendSwitchIfNotNull ("/keycontainer:", KeyContainer); commandLine.AppendSwitchIfNotNull ("/keyfile:", KeyFile); // FIXME: add ids from metadata - if (LinkResources != null) { - foreach (ITaskItem item in LinkResources) { + if (LinkResources != null) + foreach (ITaskItem item in LinkResources) commandLine.AppendSwitchIfNotNull ("/linkresource:", item.ItemSpec); - } - } - commandLine.AppendSwitchIfNotNull ("/main:", MainEntryPoint); - if (NoConfig) - commandLine.AppendSwitch ("/noconfig"); - if (Optimize) - commandLine.AppendSwitch ("/optimize"); + + if (NoLogo) + commandLine.AppendSwitch ("/nologo"); + + if (Bag ["Optimize"] != null) + if (Optimize) + commandLine.AppendSwitch ("/optimize+"); + else + commandLine.AppendSwitch ("/optimize-"); + if (OutputAssembly != null) commandLine.AppendSwitchIfNotNull ("/out:", OutputAssembly.ItemSpec); - if (References != null) { - foreach (ITaskItem item in References) { - commandLine.AppendSwitchIfNotNull ("/reference:", item.ItemSpec); - } - } - if (Resources != null) { + + if (Resources != null) foreach (ITaskItem item in Resources) { + string logical_name = item.GetMetadata ("LogicalName"); + if (logical_name.Length > 0) + commandLine.AppendSwitchIfNotNull ("/resource:", + String.Format ("{0},{1}", item.ItemSpec, logical_name)); + else commandLine.AppendSwitchIfNotNull ("/resource:", item.ItemSpec); } - } - if (ResponseFiles != null) { - foreach (ITaskItem item in ResponseFiles) { - commandLine.AppendFileNameIfNotNull (String.Format ("@{0}",item.ItemSpec)); - } - } - if (Sources != null) { - foreach (ITaskItem item in Sources) { + + if (Sources != null) + foreach (ITaskItem item in Sources) commandLine.AppendFileNameIfNotNull (item.ItemSpec); - } - } + if (TargetType != null) commandLine.AppendSwitchIfNotNull ("/target:", TargetType); - if (TreatWarningsAsErrors) - commandLine.AppendSwitch ("/warnaserror"); + if (Bag ["TreatWarningsAsErrors"] != null) + if (TreatWarningsAsErrors) + commandLine.AppendSwitch ("/warnaserror+"); + else + commandLine.AppendSwitch ("/warnaserror-"); commandLine.AppendSwitchIfNotNull ("/win32icon:", Win32Icon); - commandLine.AppendSwitchIfNotNull ("/win32res:", Win32Resource); } [MonoTODO] protected bool CheckAllReferencesExistOnDisk () { - foreach (ITaskItem item in (ITaskItem[])Bag ["References"]) - if (File.Exists (item.GetMetadata ("FullPath")) == false) - return false; + if (Bag ["References"] != null) + foreach (ITaskItem item in (ITaskItem[]) Bag ["References"]) + if (!File.Exists (item.GetMetadata ("FullPath"))) + return false; return true; } @@ -120,17 +134,20 @@ namespace Microsoft.Build.Tasks { [MonoTODO] protected override bool HandleTaskExecutionErrors () { - return true; + if (!Log.HasLoggedErrors && ExitCode != 0) + Log.LogError ("Compiler crashed with code: {0}.", ExitCode); + + return ExitCode == 0 && !Log.HasLoggedErrors; } [MonoTODO] - protected bool ListHasNoDuplicateItems (ITaskItem[] itemList, + protected bool ListHasNoDuplicateItems (ITaskItem [] itemList, string parameterName) { - Hashtable items = new Hashtable (); + Dictionary items = new Dictionary (); foreach (ITaskItem item in itemList) { - if (items.Contains (item.ItemSpec)) + if (!items.ContainsKey (item.ItemSpec)) items.Add (item.ItemSpec, null); else return false; @@ -248,17 +265,24 @@ namespace Microsoft.Build.Tasks { public ITaskItem[] Sources { get { return (ITaskItem[]) Bag ["Sources"]; } - set { Bag ["Sources"] = value; } + set { + Bag ["Sources"] = value; + if (Bag ["OutputAssembly"] == null && value != null && value.Length >= 1) + Bag ["OutputAssembly"] = new TaskItem (String.Format ("{0}.exe", value [0].ItemSpec)); + } } protected override Encoding StandardOutputEncoding { get { return Console.Error.Encoding; } } - // FIXME: hack to get build of hello world working public string TargetType { get { - return (Bag.Contains ("TargetType")) ? (((string) Bag ["TargetType"]).ToLower ()) : null; + if (Bag.Contains ("TargetType")) { + string s = (string) Bag ["TargetType"]; + return s.ToLowerInvariant (); + } else + return null; } set { Bag ["TargetType"] = value; } }