2010-05-25 Jb Evain <jbevain@novell.com>
[mcs.git] / tools / xbuild / ErrorUtilities.cs
blob78c078bce41c5d905d4510a8cc56ea340a588053
1 //
2 // ErrorUtilities.cs: Functions that print out errors, warnings, help etc.
3 //
4 // Author:
5 // Marek Sieradzki (marek.sieradzki@gmail.com)
6 //
7 // (C) 2006 Marek Sieradzki
8 //
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 #if NET_2_0
30 using System;
32 namespace Mono.XBuild.CommandLine {
33 public static class ErrorUtilities {
35 static string[] version = {
36 String.Format ("XBuild Engine Version {0}", Consts.MonoVersion),
37 String.Format ("Mono, Version {0}", Consts.MonoVersion),
38 "Copyright (C) Marek Sieradzki 2005-2008, Novell 2008-2009.",
42 static public void ReportError (int errorNum, string msg)
44 Console.WriteLine (String.Format ("MSBUILD: error MSBUILD{0:0000}: {1}", errorNum, msg));
45 Environment.Exit (1);
48 static public void ReportWarning (int errorNum, string msg)
50 Console.WriteLine (String.Format ("MSBUILD: warning MSBUILD{0:0000}: {1}", errorNum, msg));
53 static public void ReportInvalidArgument (string option, string value)
55 ReportError (1012, String.Format ("'{0}' is not a valid setting for option '{1}'", value, option));
58 static public void ReportMissingArgument (string option)
60 ReportError (1003, String.Format ("Compiler option '{0}' must be followed by an argument", option));
63 static public void ReportNotImplemented (string option)
65 ReportError (0, String.Format ("Compiler option '{0}' is not implemented", option));
68 static public void ReportMissingFileSpec (string option)
70 ReportError (1008, String.Format ("Missing file specification for '{0}' command-line option", option));
73 static public void ReportMissingText (string option)
75 ReportError (1010, String.Format ("Missing ':<text>' for '{0}' option", option));
78 static public void ShowUsage ()
80 Display (version);
81 Console.WriteLine ("xbuild [options] [project-file]");
82 Console.WriteLine (
83 " /version Show the xbuild version\n" +
84 " /noconsolelogger Disable the default console logger\n" +
85 " /target:T1[,TN] List of targets to build\n" +
86 " /property:Name=Value\n" +
87 " Set or override project properties\n" +
88 " /logger:<logger> Custom logger to log events\n" +
89 " /verbosity:<level> Logger verbosity level : quiet, minimal, normal, detailed, diagnostic\n" +
90 " /validate Validate the project file against the schema\n" +
91 " /validate:<schema> Validate the project file against the specified schema\n" +
92 " /consoleloggerparameters:<params>\n" +
93 " Parameters for the console logger\n" +
94 " /nologo Don't show the initial banner\n" +
95 " /help Show this help\n"
97 Environment.Exit (0);
100 static public void ShowVersion (bool exit)
102 Display (version);
103 if (exit)
104 Environment.Exit (0);
107 static private void Display (string[] array)
109 foreach (string s in array)
110 Console.WriteLine (s);
115 #endif