Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@568 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
21 changed files with 1335 additions and 4 deletions
@ -0,0 +1,8 @@ |
|||||||
|
Microsoft Visual Studio Solution File, Format Version 9.00 |
||||||
|
# SharpDevelop 2.0.0.546 |
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Build.Tasks", "Project\ICSharpCode.Build.Tasks.csproj", "{4139CCF6-FB49-4A9D-B2CF-331E9EA3198D}" |
||||||
|
EndProject |
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Build.Tasks.Tests", "Test\ICSharpCode.Build.Tasks.Tests.csproj", "{B7C2A664-B454-4920-AC6E-318F5274B2EF}" |
||||||
|
EndProject |
||||||
|
Global |
||||||
|
EndGlobal |
@ -0,0 +1,127 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using Microsoft.Build.Framework; |
||||||
|
using Microsoft.Build.Tasks; |
||||||
|
using Microsoft.Build.Utilities; |
||||||
|
using System; |
||||||
|
using System.Text; |
||||||
|
using System.IO; |
||||||
|
|
||||||
|
namespace ICSharpCode.Build.Tasks |
||||||
|
{ |
||||||
|
public class CompilerCommandLineArguments : CommandLineBuilderExtension |
||||||
|
{ |
||||||
|
public CompilerCommandLineArguments(MonoCompilerTask compilerTask) |
||||||
|
{ |
||||||
|
GenerateCommandLineArguments(compilerTask); |
||||||
|
} |
||||||
|
|
||||||
|
public static bool IsNetModule(string fileName) |
||||||
|
{ |
||||||
|
return Path.GetExtension(fileName).ToLowerInvariant() == ".netmodule"; |
||||||
|
} |
||||||
|
|
||||||
|
void GenerateCommandLineArguments(MonoCompilerTask compilerTask) |
||||||
|
{ |
||||||
|
AppendSwitchIfTrue("-noconfig", compilerTask.NoConfig); |
||||||
|
AppendSwitch("-warn:", compilerTask.WarningLevel.ToString()); |
||||||
|
AppendFileNameIfNotNull("-out:", compilerTask.OutputAssembly); |
||||||
|
AppendTarget(compilerTask.TargetType); |
||||||
|
AppendSwitchWithoutParameterIfNotNull("-debug", compilerTask.DebugType); |
||||||
|
AppendSwitchIfTrue("-optimize", compilerTask.Optimize); |
||||||
|
AppendSwitchIfTrue("-nologo", compilerTask.NoLogo); |
||||||
|
AppendSwitchIfTrue("-unsafe", compilerTask.AllowUnsafeBlocks); |
||||||
|
AppendSwitchIfTrue("-nostdlib", compilerTask.NoStandardLib); |
||||||
|
AppendSwitchIfTrue("-checked", compilerTask.CheckForOverflowUnderflow); |
||||||
|
AppendSwitchIfTrue("-delaysign", compilerTask.DelaySign); |
||||||
|
AppendSwitchIfNotNull("-langversion:", compilerTask.LangVersion); |
||||||
|
AppendSwitchIfNotNull("-keycontainer:", compilerTask.KeyContainer); |
||||||
|
AppendSwitchIfNotNull("-keyfile:", compilerTask.KeyFile); |
||||||
|
AppendSwitchIfNotNull("-define:", compilerTask.DefineConstants); |
||||||
|
AppendSwitchIfTrue("-warnaserror", compilerTask.TreatWarningsAsErrors); |
||||||
|
AppendSwitchIfNotNull("-nowarn:", compilerTask.DisabledWarnings); |
||||||
|
AppendSwitchIfNotNull("-main:", compilerTask.MainEntryPoint); |
||||||
|
AppendFileNameIfNotNull("-doc:", compilerTask.DocumentationFile); |
||||||
|
AppendSwitchIfNotNull("-lib:", compilerTask.AdditionalLibPaths, ","); |
||||||
|
AppendReferencesIfNotNull(compilerTask.References); |
||||||
|
AppendResourcesIfNotNull(compilerTask.Resources); |
||||||
|
AppendFileNameIfNotNull("-win32res:", compilerTask.Win32Resource); |
||||||
|
AppendFileNameIfNotNull("-win32icon:", compilerTask.Win32Icon); |
||||||
|
AppendFileNamesIfNotNull(compilerTask.Sources, " "); |
||||||
|
} |
||||||
|
|
||||||
|
void AppendReferencesIfNotNull(ITaskItem[] references) |
||||||
|
{ |
||||||
|
if (references == null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
foreach (ITaskItem reference in references) { |
||||||
|
string fileName = reference.ItemSpec; |
||||||
|
if (CompilerCommandLineArguments.IsNetModule(fileName)) { |
||||||
|
AppendFileNameIfNotNull("-addmodule:", reference); |
||||||
|
} else { |
||||||
|
AppendFileNameIfNotNull("-r:", reference); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void AppendResourcesIfNotNull(ITaskItem[] resources) |
||||||
|
{ |
||||||
|
if (resources == null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
foreach (ITaskItem resource in resources) { |
||||||
|
AppendFileNameIfNotNull("-resource:", resource); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void AppendSwitchWithoutParameterIfNotNull(string switchName, string parameter) |
||||||
|
{ |
||||||
|
if (parameter != null && parameter.Trim().Length > 0) { |
||||||
|
AppendSwitch(switchName); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void AppendSwitchIfTrue(string switchName, bool parameter) |
||||||
|
{ |
||||||
|
if (parameter) { |
||||||
|
AppendSwitch(switchName); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void AppendSwitch(string switchName, string parameter) |
||||||
|
{ |
||||||
|
AppendSwitchIfNotNull(switchName, parameter); |
||||||
|
} |
||||||
|
|
||||||
|
void AppendFileNameIfNotNull(string switchName, ITaskItem fileItem) |
||||||
|
{ |
||||||
|
if (fileItem != null) { |
||||||
|
AppendFileNameIfNotNull(switchName, fileItem.ItemSpec); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void AppendFileNameIfNotNull(string switchName, string fileName) |
||||||
|
{ |
||||||
|
if (fileName != null) { |
||||||
|
AppendSpaceIfNotEmpty(); |
||||||
|
AppendTextUnquoted(switchName); |
||||||
|
AppendFileNameWithQuoting(fileName); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void AppendTarget(string targetType) |
||||||
|
{ |
||||||
|
if (targetType != null) { |
||||||
|
AppendSwitch("-target:", targetType.ToLowerInvariant()); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,76 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.CodeDom.Compiler; |
||||||
|
using System.IO; |
||||||
|
using System.Text; |
||||||
|
using System.Text.RegularExpressions; |
||||||
|
|
||||||
|
namespace ICSharpCode.Build.Tasks |
||||||
|
{ |
||||||
|
public class CompilerResultsParser : ICompilerResultsParser |
||||||
|
{ |
||||||
|
public const string NormalErrorPattern = @"(?<file>.*)\((?<line>\d+),(?<column>\d+)\):\s+(?<error>\w+)\s+(?<number>[\d\w]+):\s+(?<message>.*)"; |
||||||
|
public const string GeneralErrorPattern = @"(?<error>.+?)\s+(?<number>[\d\w]+?):\s+(?<message>.*)"; |
||||||
|
|
||||||
|
Regex normalError = new Regex(NormalErrorPattern, RegexOptions.Compiled); |
||||||
|
Regex generalError = new Regex(GeneralErrorPattern, RegexOptions.Compiled); |
||||||
|
|
||||||
|
public CompilerResultsParser() |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
public CompilerResults Parse(TempFileCollection tempFiles, string fileName) |
||||||
|
{ |
||||||
|
CompilerResults results = new CompilerResults(tempFiles); |
||||||
|
|
||||||
|
StringBuilder compilerOutput = new StringBuilder(); |
||||||
|
StreamReader resultsReader = File.OpenText(fileName); |
||||||
|
|
||||||
|
while (true) { |
||||||
|
string curLine = resultsReader.ReadLine(); |
||||||
|
compilerOutput.Append(curLine); |
||||||
|
compilerOutput.Append('\n'); |
||||||
|
if (curLine == null) { |
||||||
|
break; |
||||||
|
} |
||||||
|
curLine = curLine.Trim(); |
||||||
|
if (curLine.Length == 0) { |
||||||
|
continue; |
||||||
|
} |
||||||
|
|
||||||
|
CompilerError error = new CompilerError(); |
||||||
|
|
||||||
|
// try to match standard mono errors
|
||||||
|
Match match = normalError.Match(curLine); |
||||||
|
if (match.Success) { |
||||||
|
error.Column = Int32.Parse(match.Result("${column}")); |
||||||
|
error.Line = Int32.Parse(match.Result("${line}")); |
||||||
|
error.FileName = Path.GetFullPath(match.Result("${file}")); |
||||||
|
error.IsWarning = match.Result("${error}") == "warning"; |
||||||
|
error.ErrorNumber = match.Result("${number}"); |
||||||
|
error.ErrorText = match.Result("${message}"); |
||||||
|
|
||||||
|
results.Errors.Add(error); |
||||||
|
} else { |
||||||
|
match = generalError.Match(curLine); |
||||||
|
if (match.Success) { |
||||||
|
error.IsWarning = match.Result("${error}") == "warning"; |
||||||
|
error.ErrorNumber = match.Result("${number}"); |
||||||
|
error.ErrorText = match.Result("${message}"); |
||||||
|
|
||||||
|
results.Errors.Add(error); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
resultsReader.Close(); |
||||||
|
|
||||||
|
return results; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,29 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using Microsoft.Build.Framework; |
||||||
|
using System; |
||||||
|
|
||||||
|
namespace ICSharpCode.Build.Tasks |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// MSBuild task for Mono's GMCS.
|
||||||
|
/// </summary>
|
||||||
|
public class Gmcs : MonoCompilerTask |
||||||
|
{ |
||||||
|
protected override string ToolName { |
||||||
|
get { |
||||||
|
return "Gmcs.exe"; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
protected override string GenerateFullPathToTool() |
||||||
|
{ |
||||||
|
return String.Concat(Environment.GetEnvironmentVariable("ComSpec"), " /c gmcs"); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,17 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.CodeDom.Compiler; |
||||||
|
|
||||||
|
namespace ICSharpCode.Build.Tasks |
||||||
|
{ |
||||||
|
public interface ICompilerResultsParser |
||||||
|
{ |
||||||
|
CompilerResults Parse(TempFileCollection tempFiles, string fileName); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,29 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using Microsoft.Build.Framework; |
||||||
|
using System; |
||||||
|
|
||||||
|
namespace ICSharpCode.Build.Tasks |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// MSBuild task for Mono's MCS.
|
||||||
|
/// </summary>
|
||||||
|
public class Mcs : MonoCompilerTask |
||||||
|
{ |
||||||
|
protected override string ToolName { |
||||||
|
get { |
||||||
|
return "Mcs.exe"; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
protected override string GenerateFullPathToTool() |
||||||
|
{ |
||||||
|
return String.Concat(Environment.GetEnvironmentVariable("ComSpec"), " /c mcs"); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,53 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.CodeDom.Compiler; |
||||||
|
using System.IO; |
||||||
|
|
||||||
|
namespace ICSharpCode.Build.Tasks |
||||||
|
{ |
||||||
|
public class MonoCompiler |
||||||
|
{ |
||||||
|
CompilerResults results; |
||||||
|
|
||||||
|
public MonoCompiler() |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
public int Run(string compiler, string args, ICompilerResultsParser parser) |
||||||
|
{ |
||||||
|
string responseFileName = Path.GetTempFileName(); |
||||||
|
|
||||||
|
using (StreamWriter writer = new StreamWriter(responseFileName)) { |
||||||
|
writer.Write(args); |
||||||
|
} |
||||||
|
|
||||||
|
//string outstr = String.Concat(compilerFileName, compilerparameters.NoConfig ? " /noconfig" : String.Empty, " \"@", responseFileName, "\"");
|
||||||
|
string outputFileName = String.Empty; |
||||||
|
string errorFileName = String.Empty; |
||||||
|
TempFileCollection tempFiles = new TempFileCollection(); |
||||||
|
string command = String.Concat(compiler, " \"@", responseFileName, "\""); |
||||||
|
|
||||||
|
int returnValue = Executor.ExecWaitWithCapture(command, tempFiles, ref outputFileName, ref errorFileName); |
||||||
|
|
||||||
|
results = parser.Parse(tempFiles, errorFileName); |
||||||
|
|
||||||
|
File.Delete(responseFileName); |
||||||
|
File.Delete(outputFileName); |
||||||
|
File.Delete(errorFileName); |
||||||
|
|
||||||
|
return returnValue; |
||||||
|
} |
||||||
|
|
||||||
|
public CompilerResults Results { |
||||||
|
get { |
||||||
|
return results; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,370 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using Microsoft.Build.Framework; |
||||||
|
using Microsoft.Build.Utilities; |
||||||
|
using System; |
||||||
|
using System.CodeDom.Compiler; |
||||||
|
|
||||||
|
namespace ICSharpCode.Build.Tasks |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Base class task for the mono compilers mcs and gmcs.
|
||||||
|
/// </summary>
|
||||||
|
public abstract class MonoCompilerTask : MyToolTask |
||||||
|
{ |
||||||
|
string[] additionalLibPaths; |
||||||
|
string[] addModules; |
||||||
|
bool allowUnsafeBlocks; |
||||||
|
bool checkForOverflowUnderflow; |
||||||
|
int codePage; |
||||||
|
string debugType; |
||||||
|
string defineConstants; |
||||||
|
bool delaySign; |
||||||
|
string disabledWarnings; |
||||||
|
string documentationFile; |
||||||
|
string emitDebugInformation; |
||||||
|
string keyContainer; |
||||||
|
string keyFile; |
||||||
|
string langVersion; |
||||||
|
ITaskItem[] linkResources; |
||||||
|
string mainEntryPoint; |
||||||
|
string moduleAssemblyName; |
||||||
|
bool noConfig; |
||||||
|
bool noLogo; |
||||||
|
bool noStandardLib; |
||||||
|
bool optimize; |
||||||
|
ITaskItem outputAssembly; |
||||||
|
ITaskItem[] references; |
||||||
|
ITaskItem[] resources; |
||||||
|
ITaskItem[] responseFiles; |
||||||
|
ITaskItem[] sources; |
||||||
|
string targetType; |
||||||
|
bool treatWarningsAsErrors; |
||||||
|
int warningLevel; |
||||||
|
string win32Icon; |
||||||
|
string win32Resource; |
||||||
|
|
||||||
|
public string[] AdditionalLibPaths { |
||||||
|
get { |
||||||
|
return additionalLibPaths; |
||||||
|
} |
||||||
|
set { |
||||||
|
additionalLibPaths = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public string[] AddModules { |
||||||
|
get { |
||||||
|
return addModules; |
||||||
|
} |
||||||
|
set { |
||||||
|
addModules = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public bool AllowUnsafeBlocks { |
||||||
|
get { |
||||||
|
return allowUnsafeBlocks; |
||||||
|
} |
||||||
|
set { |
||||||
|
allowUnsafeBlocks = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public bool CheckForOverflowUnderflow { |
||||||
|
get { |
||||||
|
return checkForOverflowUnderflow; |
||||||
|
} |
||||||
|
set { |
||||||
|
checkForOverflowUnderflow = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public int CodePage { |
||||||
|
get { |
||||||
|
return codePage; |
||||||
|
} |
||||||
|
set { |
||||||
|
codePage = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public string DebugType { |
||||||
|
get { |
||||||
|
return debugType; |
||||||
|
} |
||||||
|
set { |
||||||
|
debugType = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public string DefineConstants { |
||||||
|
get { |
||||||
|
return defineConstants; |
||||||
|
} |
||||||
|
set { |
||||||
|
defineConstants = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public bool DelaySign { |
||||||
|
get { |
||||||
|
return delaySign; |
||||||
|
} |
||||||
|
|
||||||
|
set { |
||||||
|
delaySign = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public string DisabledWarnings { |
||||||
|
get { |
||||||
|
return disabledWarnings; |
||||||
|
} |
||||||
|
set { |
||||||
|
disabledWarnings = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public string DocumentationFile { |
||||||
|
get { |
||||||
|
return documentationFile; |
||||||
|
} |
||||||
|
set { |
||||||
|
documentationFile = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public string EmitDebugInformation { |
||||||
|
get { |
||||||
|
return emitDebugInformation; |
||||||
|
} |
||||||
|
set { |
||||||
|
emitDebugInformation = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public string KeyContainer { |
||||||
|
get { |
||||||
|
return keyContainer; |
||||||
|
} |
||||||
|
set { |
||||||
|
keyContainer = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public string KeyFile { |
||||||
|
get { |
||||||
|
return keyFile; |
||||||
|
} |
||||||
|
set { |
||||||
|
keyFile = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public string LangVersion { |
||||||
|
get { |
||||||
|
return langVersion; |
||||||
|
} |
||||||
|
set { |
||||||
|
langVersion = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public ITaskItem[] LinkResources { |
||||||
|
get { |
||||||
|
return linkResources; |
||||||
|
} |
||||||
|
set { |
||||||
|
linkResources = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public string MainEntryPoint { |
||||||
|
get { |
||||||
|
return mainEntryPoint; |
||||||
|
} |
||||||
|
set { |
||||||
|
mainEntryPoint = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public string ModuleAssemblyName { |
||||||
|
get { |
||||||
|
return moduleAssemblyName; |
||||||
|
} |
||||||
|
set { |
||||||
|
moduleAssemblyName = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public bool NoConfig { |
||||||
|
get { |
||||||
|
return noConfig; |
||||||
|
} |
||||||
|
set { |
||||||
|
noConfig = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public bool NoLogo { |
||||||
|
get { |
||||||
|
return noLogo; |
||||||
|
} |
||||||
|
set { |
||||||
|
noLogo = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public bool NoStandardLib { |
||||||
|
get { |
||||||
|
return noStandardLib; |
||||||
|
} |
||||||
|
set { |
||||||
|
noStandardLib = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public bool Optimize { |
||||||
|
get { |
||||||
|
return optimize; |
||||||
|
} |
||||||
|
set { |
||||||
|
optimize = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public ITaskItem OutputAssembly { |
||||||
|
get { |
||||||
|
return outputAssembly; |
||||||
|
} |
||||||
|
set { |
||||||
|
outputAssembly = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public ITaskItem[] References { |
||||||
|
get { |
||||||
|
return references; |
||||||
|
} |
||||||
|
set { |
||||||
|
references = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public ITaskItem[] Resources { |
||||||
|
get { |
||||||
|
return resources; |
||||||
|
} |
||||||
|
set { |
||||||
|
resources = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public ITaskItem[] ResponseFiles { |
||||||
|
get { |
||||||
|
return responseFiles; |
||||||
|
} |
||||||
|
set { |
||||||
|
responseFiles = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public ITaskItem[] Sources { |
||||||
|
get { |
||||||
|
return sources; |
||||||
|
} |
||||||
|
set { |
||||||
|
sources = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public string TargetType { |
||||||
|
get { |
||||||
|
return targetType; |
||||||
|
} |
||||||
|
set { |
||||||
|
targetType = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public bool TreatWarningsAsErrors { |
||||||
|
get { |
||||||
|
return treatWarningsAsErrors; |
||||||
|
} |
||||||
|
set { |
||||||
|
treatWarningsAsErrors = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public int WarningLevel { |
||||||
|
get { |
||||||
|
return warningLevel; |
||||||
|
} |
||||||
|
set { |
||||||
|
warningLevel = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public string Win32Icon { |
||||||
|
get { |
||||||
|
return win32Icon; |
||||||
|
} |
||||||
|
set { |
||||||
|
win32Icon = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public string Win32Resource { |
||||||
|
get { |
||||||
|
return win32Resource; |
||||||
|
} |
||||||
|
set { |
||||||
|
win32Resource = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public override bool Execute() |
||||||
|
{ |
||||||
|
string args = GenerateCommandLineArguments(); |
||||||
|
|
||||||
|
ToolPath = GenerateFullPathToTool(); |
||||||
|
MonoCompiler compiler = new MonoCompiler(); |
||||||
|
int returnValue = compiler.Run(ToolPath, args, GetCompilerResultsParser()); |
||||||
|
|
||||||
|
int errorCount = 0; |
||||||
|
foreach (CompilerError error in compiler.Results.Errors) { |
||||||
|
if (error.IsWarning) { |
||||||
|
Log.LogWarning("warning", error.ErrorNumber, null, error.FileName, error.Line, error.Column, error.Line, error.Column, error.ErrorText); |
||||||
|
} else { |
||||||
|
errorCount++; |
||||||
|
Log.LogError("error", error.ErrorNumber, null, error.FileName, error.Line, error.Column, error.Line, error.Column, error.ErrorText); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
if (returnValue != 0 && errorCount == 0) { |
||||||
|
Log.LogError(String.Concat("Failed to execute compiler: ", returnValue, ": ", ToolPath)); |
||||||
|
} |
||||||
|
|
||||||
|
return errorCount == 0; |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Command line arguments that will be passed to the compiler.
|
||||||
|
/// </summary>
|
||||||
|
protected virtual string GenerateCommandLineArguments() |
||||||
|
{ |
||||||
|
CompilerCommandLineArguments args = new CompilerCommandLineArguments(this); |
||||||
|
return args.ToString(); |
||||||
|
} |
||||||
|
|
||||||
|
protected virtual ICompilerResultsParser GetCompilerResultsParser() |
||||||
|
{ |
||||||
|
return new CompilerResultsParser(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,63 @@ |
|||||||
|
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build"> |
||||||
|
|
||||||
|
<UsingTask TaskName="ICSharpCode.Build.Tasks.Gmcs" |
||||||
|
AssemblyFile="$(SharpDevelopBinPath)\ICSharpCode.Build.Tasks.dll"/> |
||||||
|
|
||||||
|
<PropertyGroup> |
||||||
|
<MSBuildAllProjects>$(MSBuildAllProjects);$(SharpDevelopBinPath)\SharpDevelop.Build.Mono.targets</MSBuildAllProjects> |
||||||
|
<DefaultLanguageSourceExtension>.cs</DefaultLanguageSourceExtension> |
||||||
|
<Language>C#</Language> |
||||||
|
</PropertyGroup> |
||||||
|
|
||||||
|
<Target |
||||||
|
Name="CoreCompile" |
||||||
|
Inputs="$(MSBuildAllProjects); |
||||||
|
@(Compile); |
||||||
|
@(ManifestResourceWithNoCulture); |
||||||
|
$(ApplicationIcon); |
||||||
|
$(AssemblyOriginatorKeyFile); |
||||||
|
@(ManifestNonResxWithNoCultureOnDisk); |
||||||
|
@(ReferencePath); |
||||||
|
@(CompiledLicenseFile)" |
||||||
|
Outputs="@(DocFileItem); |
||||||
|
@(IntermediateAssembly); |
||||||
|
$(NonExistentFile)" |
||||||
|
DependsOnTargets="$(CoreCompileDependsOn)" |
||||||
|
> |
||||||
|
|
||||||
|
<Gmcs |
||||||
|
AdditionalLibPaths="$(AdditionalLibPaths)" |
||||||
|
AddModules="@(AddModules)" |
||||||
|
AllowUnsafeBlocks="$(AllowUnsafeBlocks)" |
||||||
|
CheckForOverflowUnderflow="$(CheckForOverflowUnderflow)" |
||||||
|
CodePage="$(CodePage)" |
||||||
|
DebugType="$(DebugType)" |
||||||
|
DefineConstants="$(DefineConstants)" |
||||||
|
DelaySign="$(DelaySign)" |
||||||
|
DisabledWarnings="$(NoWarn)" |
||||||
|
DocumentationFile="@(DocFileItem)" |
||||||
|
EmitDebugInformation="$(DebugSymbols)" |
||||||
|
KeyContainer="$(KeyContainerName)" |
||||||
|
KeyFile="$(KeyOriginatorFile)" |
||||||
|
LangVersion="$(LangVersion)" |
||||||
|
MainEntryPoint="$(StartupObject)" |
||||||
|
NoConfig="true" |
||||||
|
NoLogo="$(NoLogo)" |
||||||
|
NoStandardLib="$(NoStdLib)" |
||||||
|
Optimize="$(Optimize)" |
||||||
|
OutputAssembly="@(IntermediateAssembly)" |
||||||
|
References="@(ReferencePath)" |
||||||
|
Resources="@(ManifestResourceWithNoCulture);@(ManifestNonResxWithNoCultureOnDisk);@(CompiledLicenseFile)" |
||||||
|
ResponseFiles="$(CompilerResponseFile)" |
||||||
|
Sources="@(Compile)" |
||||||
|
TargetType="$(OutputType)" |
||||||
|
ToolPath="$(GmcsToolPath)" |
||||||
|
TreatWarningsAsErrors="$(TreatWarningsAsErrors)" |
||||||
|
WarningLevel="$(WarningLevel)" |
||||||
|
Win32Icon="$(ApplicationIcon)" |
||||||
|
Win32Resource="$(Win32Resource)" /> |
||||||
|
</Target> |
||||||
|
|
||||||
|
<Import Project="$(SharpDevelopBinPath)\SharpDevelop.Build.Common.targets" /> |
||||||
|
|
||||||
|
</Project> |
@ -0,0 +1,63 @@ |
|||||||
|
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build"> |
||||||
|
|
||||||
|
<UsingTask TaskName="ICSharpCode.Build.Tasks.Mcs" |
||||||
|
AssemblyFile="$(SharpDevelopBinPath)\ICSharpCode.Build.Tasks.dll"/> |
||||||
|
|
||||||
|
<PropertyGroup> |
||||||
|
<MSBuildAllProjects>$(MSBuildAllProjects);$(SharpDevelopBinPath)\SharpDevelop.Build.Mono.targets</MSBuildAllProjects> |
||||||
|
<DefaultLanguageSourceExtension>.cs</DefaultLanguageSourceExtension> |
||||||
|
<Language>C#</Language> |
||||||
|
</PropertyGroup> |
||||||
|
|
||||||
|
<Target |
||||||
|
Name="CoreCompile" |
||||||
|
Inputs="$(MSBuildAllProjects); |
||||||
|
@(Compile); |
||||||
|
@(ManifestResourceWithNoCulture); |
||||||
|
$(ApplicationIcon); |
||||||
|
$(AssemblyOriginatorKeyFile); |
||||||
|
@(ManifestNonResxWithNoCultureOnDisk); |
||||||
|
@(ReferencePath); |
||||||
|
@(CompiledLicenseFile)" |
||||||
|
Outputs="@(DocFileItem); |
||||||
|
@(IntermediateAssembly); |
||||||
|
$(NonExistentFile)" |
||||||
|
DependsOnTargets="$(CoreCompileDependsOn)" |
||||||
|
> |
||||||
|
|
||||||
|
<Mcs |
||||||
|
AdditionalLibPaths="$(AdditionalLibPaths)" |
||||||
|
AddModules="@(AddModules)" |
||||||
|
AllowUnsafeBlocks="$(AllowUnsafeBlocks)" |
||||||
|
CheckForOverflowUnderflow="$(CheckForOverflowUnderflow)" |
||||||
|
CodePage="$(CodePage)" |
||||||
|
DebugType="$(DebugType)" |
||||||
|
DefineConstants="$(DefineConstants)" |
||||||
|
DelaySign="$(DelaySign)" |
||||||
|
DisabledWarnings="$(NoWarn)" |
||||||
|
DocumentationFile="@(DocFileItem)" |
||||||
|
EmitDebugInformation="$(DebugSymbols)" |
||||||
|
KeyContainer="$(KeyContainerName)" |
||||||
|
KeyFile="$(KeyOriginatorFile)" |
||||||
|
LangVersion="$(LangVersion)" |
||||||
|
MainEntryPoint="$(StartupObject)" |
||||||
|
NoConfig="true" |
||||||
|
NoLogo="$(NoLogo)" |
||||||
|
NoStandardLib="$(NoStdLib)" |
||||||
|
Optimize="$(Optimize)" |
||||||
|
OutputAssembly="@(IntermediateAssembly)" |
||||||
|
References="@(ReferencePath)" |
||||||
|
Resources="@(ManifestResourceWithNoCulture);@(ManifestNonResxWithNoCultureOnDisk);@(CompiledLicenseFile)" |
||||||
|
ResponseFiles="$(CompilerResponseFile)" |
||||||
|
Sources="@(Compile)" |
||||||
|
TargetType="$(OutputType)" |
||||||
|
ToolPath="$(McsToolPath)" |
||||||
|
TreatWarningsAsErrors="$(TreatWarningsAsErrors)" |
||||||
|
WarningLevel="$(WarningLevel)" |
||||||
|
Win32Icon="$(ApplicationIcon)" |
||||||
|
Win32Resource="$(Win32Resource)" /> |
||||||
|
</Target> |
||||||
|
|
||||||
|
<Import Project="$(SharpDevelopBinPath)\SharpDevelop.Build.Common.targets" /> |
||||||
|
|
||||||
|
</Project> |
@ -0,0 +1,27 @@ |
|||||||
|
using System.Reflection; |
||||||
|
using System.Runtime.CompilerServices; |
||||||
|
|
||||||
|
// Information about this assembly is defined by the following
|
||||||
|
// attributes.
|
||||||
|
//
|
||||||
|
// change them to the information which is associated with the assembly
|
||||||
|
// you compile.
|
||||||
|
|
||||||
|
[assembly: AssemblyTitle("")] |
||||||
|
[assembly: AssemblyDescription("")] |
||||||
|
[assembly: AssemblyConfiguration("")] |
||||||
|
[assembly: AssemblyCompany("")] |
||||||
|
[assembly: AssemblyProduct("")] |
||||||
|
[assembly: AssemblyCopyright("")] |
||||||
|
[assembly: AssemblyTrademark("")] |
||||||
|
[assembly: AssemblyCulture("")] |
||||||
|
|
||||||
|
// The assembly version has following format :
|
||||||
|
//
|
||||||
|
// Major.Minor.Build.Revision
|
||||||
|
//
|
||||||
|
// You can specify all values by your own or you can build default build and revision
|
||||||
|
// numbers with the '*' character (the default):
|
||||||
|
|
||||||
|
[assembly: AssemblyVersion("1.0.*")] |
||||||
|
|
@ -0,0 +1,273 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using ICSharpCode.Build.Tasks; |
||||||
|
using MbUnit.Framework; |
||||||
|
using Microsoft.Build.Utilities; |
||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
|
||||||
|
namespace ICSharpCode.Build.Tasks.Tests |
||||||
|
{ |
||||||
|
[TestFixture] |
||||||
|
public class CompilerCommandLineTestFixture |
||||||
|
{ |
||||||
|
[Test] |
||||||
|
public void NoArguments() |
||||||
|
{ |
||||||
|
Mcs mcs = new Mcs(); |
||||||
|
|
||||||
|
CompilerCommandLineArguments args = new CompilerCommandLineArguments(mcs); |
||||||
|
Assert.AreEqual("-warn:0", args.ToString()); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void OutputAssembly() |
||||||
|
{ |
||||||
|
Mcs mcs = new Mcs(); |
||||||
|
string outputAssembly = @"obj\debug\test.exe"; |
||||||
|
mcs.OutputAssembly = new TaskItem(outputAssembly); |
||||||
|
|
||||||
|
CompilerCommandLineArguments args = new CompilerCommandLineArguments(mcs); |
||||||
|
Assert.AreEqual(@"-warn:0 -out:obj\debug\test.exe", args.ToString()); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void OutputAssemblyWithSpace() |
||||||
|
{ |
||||||
|
Mcs mcs = new Mcs(); |
||||||
|
string outputAssembly = @"obj\debug\test this.exe"; |
||||||
|
mcs.OutputAssembly = new TaskItem(outputAssembly); |
||||||
|
|
||||||
|
CompilerCommandLineArguments args = new CompilerCommandLineArguments(mcs); |
||||||
|
Assert.AreEqual("-warn:0 -out:\"obj\\debug\\test this.exe\"", args.ToString()); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void WinExeTarget() |
||||||
|
{ |
||||||
|
Mcs mcs = new Mcs(); |
||||||
|
mcs.TargetType = "Exe"; |
||||||
|
|
||||||
|
CompilerCommandLineArguments args = new CompilerCommandLineArguments(mcs); |
||||||
|
Assert.AreEqual("-warn:0 -target:exe", args.ToString()); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void ModuleTarget() |
||||||
|
{ |
||||||
|
Mcs mcs = new Mcs(); |
||||||
|
mcs.TargetType = "Module"; |
||||||
|
|
||||||
|
CompilerCommandLineArguments args = new CompilerCommandLineArguments(mcs); |
||||||
|
Assert.AreEqual("-warn:0 -target:module", args.ToString()); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void FullDebugging() |
||||||
|
{ |
||||||
|
Mcs mcs = new Mcs(); |
||||||
|
mcs.DebugType = "Full"; |
||||||
|
|
||||||
|
CompilerCommandLineArguments args = new CompilerCommandLineArguments(mcs); |
||||||
|
Assert.AreEqual("-warn:0 -debug", args.ToString()); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void Optimize() |
||||||
|
{ |
||||||
|
Mcs mcs = new Mcs(); |
||||||
|
mcs.Optimize = true; |
||||||
|
|
||||||
|
CompilerCommandLineArguments args = new CompilerCommandLineArguments(mcs); |
||||||
|
Assert.AreEqual("-warn:0 -optimize", args.ToString()); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void NoLogo() |
||||||
|
{ |
||||||
|
Mcs mcs = new Mcs(); |
||||||
|
mcs.NoLogo = true; |
||||||
|
|
||||||
|
CompilerCommandLineArguments args = new CompilerCommandLineArguments(mcs); |
||||||
|
Assert.AreEqual("-warn:0 -nologo", args.ToString()); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void Unsafe() |
||||||
|
{ |
||||||
|
Mcs mcs = new Mcs(); |
||||||
|
mcs.AllowUnsafeBlocks = true; |
||||||
|
|
||||||
|
CompilerCommandLineArguments args = new CompilerCommandLineArguments(mcs); |
||||||
|
Assert.AreEqual("-warn:0 -unsafe", args.ToString()); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void NoStandardLib() |
||||||
|
{ |
||||||
|
Mcs mcs = new Mcs(); |
||||||
|
mcs.NoStandardLib = true; |
||||||
|
|
||||||
|
CompilerCommandLineArguments args = new CompilerCommandLineArguments(mcs); |
||||||
|
Assert.AreEqual("-warn:0 -nostdlib", args.ToString()); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void DelaySign() |
||||||
|
{ |
||||||
|
Mcs mcs = new Mcs(); |
||||||
|
mcs.DelaySign = true; |
||||||
|
|
||||||
|
CompilerCommandLineArguments args = new CompilerCommandLineArguments(mcs); |
||||||
|
Assert.AreEqual("-warn:0 -delaysign", args.ToString()); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void DefineConstants() |
||||||
|
{ |
||||||
|
Mcs mcs = new Mcs(); |
||||||
|
mcs.DefineConstants = "DEBUG;TRACE"; |
||||||
|
|
||||||
|
CompilerCommandLineArguments args = new CompilerCommandLineArguments(mcs); |
||||||
|
Assert.AreEqual("-warn:0 -define:\"DEBUG;TRACE\"", args.ToString()); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void WarnAsError() |
||||||
|
{ |
||||||
|
Mcs mcs = new Mcs(); |
||||||
|
mcs.TreatWarningsAsErrors = true; |
||||||
|
|
||||||
|
CompilerCommandLineArguments args = new CompilerCommandLineArguments(mcs); |
||||||
|
Assert.AreEqual("-warn:0 -warnaserror", args.ToString()); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void NoWarn() |
||||||
|
{ |
||||||
|
Mcs mcs = new Mcs(); |
||||||
|
mcs.DisabledWarnings = "1234,5678"; |
||||||
|
|
||||||
|
CompilerCommandLineArguments args = new CompilerCommandLineArguments(mcs); |
||||||
|
Assert.AreEqual("-warn:0 -nowarn:\"1234,5678\"", args.ToString()); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void MainEntryPoint() |
||||||
|
{ |
||||||
|
Mcs mcs = new Mcs(); |
||||||
|
mcs.MainEntryPoint = "Console.MainClass.Main"; |
||||||
|
|
||||||
|
CompilerCommandLineArguments args = new CompilerCommandLineArguments(mcs); |
||||||
|
Assert.AreEqual("-warn:0 -main:Console.MainClass.Main", args.ToString()); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void DocumentationFile() |
||||||
|
{ |
||||||
|
Mcs mcs = new Mcs(); |
||||||
|
mcs.DocumentationFile = @"obj\debug test\test.exe.xml"; |
||||||
|
|
||||||
|
CompilerCommandLineArguments args = new CompilerCommandLineArguments(mcs); |
||||||
|
Assert.AreEqual("-warn:0 -doc:\"obj\\debug test\\test.exe.xml\"", args.ToString()); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void SingleSourceFile() |
||||||
|
{ |
||||||
|
Mcs mcs = new Mcs(); |
||||||
|
mcs.Sources = new TaskItem[] { new TaskItem("proj src\\Main.cs") }; |
||||||
|
|
||||||
|
CompilerCommandLineArguments args = new CompilerCommandLineArguments(mcs); |
||||||
|
Assert.AreEqual("-warn:0 \"proj src\\Main.cs\"", args.ToString()); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void MultipleSourceFiles() |
||||||
|
{ |
||||||
|
Mcs mcs = new Mcs(); |
||||||
|
mcs.Sources = new TaskItem[] { new TaskItem("proj src\\Main.cs"), |
||||||
|
new TaskItem("AssemblyInfo.cs") }; |
||||||
|
|
||||||
|
CompilerCommandLineArguments args = new CompilerCommandLineArguments(mcs); |
||||||
|
Assert.AreEqual("-warn:0 \"proj src\\Main.cs\" AssemblyInfo.cs", args.ToString()); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void SingleReference() |
||||||
|
{ |
||||||
|
Mcs mcs = new Mcs(); |
||||||
|
mcs.References = new TaskItem[] { new TaskItem("proj refs\\Test.dll") }; |
||||||
|
|
||||||
|
CompilerCommandLineArguments args = new CompilerCommandLineArguments(mcs); |
||||||
|
Assert.AreEqual("-warn:0 -r:\"proj refs\\Test.dll\"", args.ToString()); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void NetModuleReference() |
||||||
|
{ |
||||||
|
Mcs mcs = new Mcs(); |
||||||
|
mcs.References = new TaskItem[] { new TaskItem("proj refs\\Test.dll"), |
||||||
|
new TaskItem("proj refs\\Run.netmodule") }; |
||||||
|
|
||||||
|
CompilerCommandLineArguments args = new CompilerCommandLineArguments(mcs); |
||||||
|
Assert.AreEqual("-warn:0 -r:\"proj refs\\Test.dll\" -addmodule:\"proj refs\\Run.netmodule\"", args.ToString()); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void AdditionalLibPaths() |
||||||
|
{ |
||||||
|
Mcs mcs = new Mcs(); |
||||||
|
mcs.AdditionalLibPaths = new string[] { "proj\\My libs", "proj\\My libs2" }; |
||||||
|
|
||||||
|
CompilerCommandLineArguments args = new CompilerCommandLineArguments(mcs); |
||||||
|
Assert.AreEqual("-warn:0 -lib:\"proj\\My libs\",\"proj\\My libs2\"", args.ToString()); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void EmbeddedResources() |
||||||
|
{ |
||||||
|
Mcs mcs = new Mcs(); |
||||||
|
mcs.Resources = new TaskItem[] { new TaskItem("proj res\\Test.xml"), |
||||||
|
new TaskItem("proj res\\Run.xml") }; |
||||||
|
|
||||||
|
CompilerCommandLineArguments args = new CompilerCommandLineArguments(mcs); |
||||||
|
Assert.AreEqual("-warn:0 -resource:\"proj res\\Test.xml\" -resource:\"proj res\\Run.xml\"", args.ToString()); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void Win32Resource() |
||||||
|
{ |
||||||
|
Mcs mcs = new Mcs(); |
||||||
|
mcs.Win32Resource = "Project Resources\\Test.res"; |
||||||
|
|
||||||
|
CompilerCommandLineArguments args = new CompilerCommandLineArguments(mcs); |
||||||
|
Assert.AreEqual("-warn:0 -win32res:\"Project Resources\\Test.res\"", args.ToString()); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void Win32Icon() |
||||||
|
{ |
||||||
|
Mcs mcs = new Mcs(); |
||||||
|
mcs.Win32Icon = "Project Icons\\app.ico"; |
||||||
|
|
||||||
|
CompilerCommandLineArguments args = new CompilerCommandLineArguments(mcs); |
||||||
|
Assert.AreEqual("-warn:0 -win32icon:\"Project Icons\\app.ico\"", args.ToString()); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void Checked() |
||||||
|
{ |
||||||
|
Mcs mcs = new Mcs(); |
||||||
|
mcs.CheckForOverflowUnderflow = true; |
||||||
|
|
||||||
|
CompilerCommandLineArguments args = new CompilerCommandLineArguments(mcs); |
||||||
|
Assert.AreEqual("-warn:0 -checked", args.ToString()); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,47 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using ICSharpCode.Build.Tasks; |
||||||
|
using MbUnit.Framework; |
||||||
|
using System; |
||||||
|
using System.Text.RegularExpressions; |
||||||
|
|
||||||
|
namespace ICSharpCode.Build.Tasks.Tests |
||||||
|
{ |
||||||
|
[TestFixture] |
||||||
|
public class GeneralMonoErrorParseTestFixture |
||||||
|
{ |
||||||
|
Match match; |
||||||
|
|
||||||
|
[TestFixtureSetUp] |
||||||
|
public void FixtureSetUp() |
||||||
|
{ |
||||||
|
string error = "error CS1904: `CS0169' is not a valid warning number"; |
||||||
|
|
||||||
|
Regex regex = new Regex(CompilerResultsParser.GeneralErrorPattern, RegexOptions.Compiled); |
||||||
|
match = regex.Match(error); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void Error() |
||||||
|
{ |
||||||
|
Assert.AreEqual("error", match.Result("${error}")); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void ErrorNumber() |
||||||
|
{ |
||||||
|
Assert.AreEqual("CS1904", match.Result("${number}")); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void ErrorText() |
||||||
|
{ |
||||||
|
Assert.AreEqual("`CS0169' is not a valid warning number", match.Result("${message}")); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,56 @@ |
|||||||
|
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||||
|
<PropertyGroup> |
||||||
|
<OutputType>Library</OutputType> |
||||||
|
<RootNamespace>ICSharpCode.Build.Tasks.Tests</RootNamespace> |
||||||
|
<AssemblyName>ICSharpCode.Build.Tasks.Tests</AssemblyName> |
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
||||||
|
<ProjectGuid>{B7C2A664-B454-4920-AC6E-318F5274B2EF}</ProjectGuid> |
||||||
|
<AllowUnsafeBlocks>False</AllowUnsafeBlocks> |
||||||
|
<NoStdLib>False</NoStdLib> |
||||||
|
<RegisterForComInterop>False</RegisterForComInterop> |
||||||
|
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies> |
||||||
|
<BaseAddress>4194304</BaseAddress> |
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget> |
||||||
|
<FileAlignment>4096</FileAlignment> |
||||||
|
<WarningLevel>4</WarningLevel> |
||||||
|
<TreatWarningsAsErrors>false</TreatWarningsAsErrors> |
||||||
|
</PropertyGroup> |
||||||
|
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> |
||||||
|
<OutputPath>..\..\..\..\bin\</OutputPath> |
||||||
|
<Optimize>False</Optimize> |
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants> |
||||||
|
<DebugSymbols>true</DebugSymbols> |
||||||
|
<DebugType>Full</DebugType> |
||||||
|
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> |
||||||
|
</PropertyGroup> |
||||||
|
<PropertyGroup Condition=" '$(Configuration)' == 'Release' "> |
||||||
|
<OutputPath>bin\Release\</OutputPath> |
||||||
|
<Optimize>True</Optimize> |
||||||
|
<DefineConstants>TRACE</DefineConstants> |
||||||
|
<DebugSymbols>False</DebugSymbols> |
||||||
|
<DebugType>None</DebugType> |
||||||
|
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> |
||||||
|
</PropertyGroup> |
||||||
|
<ItemGroup> |
||||||
|
<Reference Include="System" /> |
||||||
|
<Reference Include="System.Xml" /> |
||||||
|
<Reference Include="MbUnit.Framework, Version=2.24.0.0, Culture=neutral, PublicKeyToken=5e72ecd30bc408d5" /> |
||||||
|
<Reference Include="Microsoft.Build.Utilities, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> |
||||||
|
<Reference Include="Microsoft.Build.Framework, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> |
||||||
|
<Reference Include="Microsoft.Build.Tasks, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> |
||||||
|
</ItemGroup> |
||||||
|
<ItemGroup> |
||||||
|
<Compile Include="CompilerCommandLineTestFixture.cs" /> |
||||||
|
<Compile Include="AssemblyInfo.cs" /> |
||||||
|
<Compile Include="NormalMonoErrorParseTestFixture.cs" /> |
||||||
|
<Compile Include="GeneralErrorParseTestFixture.cs" /> |
||||||
|
</ItemGroup> |
||||||
|
<ItemGroup> |
||||||
|
<ProjectReference Include="..\Project\ICSharpCode.Build.Tasks.csproj"> |
||||||
|
<Project>{4139CCF6-FB49-4A9D-B2CF-331E9EA3198D}</Project> |
||||||
|
<Name>ICSharpCode.Build.Tasks</Name> |
||||||
|
</ProjectReference> |
||||||
|
</ItemGroup> |
||||||
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> |
||||||
|
</Project> |
@ -0,0 +1,65 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using ICSharpCode.Build.Tasks; |
||||||
|
using MbUnit.Framework; |
||||||
|
using System; |
||||||
|
using System.Text.RegularExpressions; |
||||||
|
|
||||||
|
namespace ICSharpCode.Build.Tasks.Tests |
||||||
|
{ |
||||||
|
[TestFixture] |
||||||
|
public class NormalMonoErrorParseTestFixture |
||||||
|
{ |
||||||
|
Match match; |
||||||
|
|
||||||
|
[TestFixtureSetUp] |
||||||
|
public void FixtureSetUp() |
||||||
|
{ |
||||||
|
string error = "MyClass.cs(19,7): warning CS0169: The private field `Foo.MyClass.foo' is never used"; |
||||||
|
|
||||||
|
Regex regex = new Regex(CompilerResultsParser.NormalErrorPattern, RegexOptions.Compiled); |
||||||
|
match = regex.Match(error); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void Column() |
||||||
|
{ |
||||||
|
Assert.AreEqual("7", match.Result("${column}")); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void Line() |
||||||
|
{ |
||||||
|
Assert.AreEqual("19", match.Result("${line}")); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void FileName() |
||||||
|
{ |
||||||
|
Assert.AreEqual("MyClass.cs", match.Result("${file}")); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void Warning() |
||||||
|
{ |
||||||
|
Assert.AreEqual("warning", match.Result("${error}")); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void ErrorNumber() |
||||||
|
{ |
||||||
|
Assert.AreEqual("CS0169", match.Result("${number}")); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void ErrorText() |
||||||
|
{ |
||||||
|
Assert.AreEqual("The private field `Foo.MyClass.foo' is never used", match.Result("${message}")); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
Binary file not shown.
Binary file not shown.
Loading…
Reference in new issue