[runtime] Use mkbundle in BCL tests
[mono.git] / mcs / tools / xbuild / ErrorUtilities.cs
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:
16 //
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
19 //
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.
27
28
29 using System;
30
31 namespace Mono.XBuild.CommandLine {
32         public static class ErrorUtilities {
33
34                 static string[] version = {
35                         String.Format ("XBuild Engine Version {0}", XBuildConsts.Version),
36                         String.Format ("Mono, Version {0}", Consts.MonoVersion),
37                         "Copyright (C) 2005-2013 Various Mono authors",
38                 };
39
40                 
41                 static public void ReportError (int errorNum, string msg)
42                 {
43                         Console.WriteLine (String.Format ("MSBUILD: error MSBUILD{0:0000}: {1}", errorNum, msg));
44                         Environment.Exit (1);
45                 }
46
47                 static public void ReportWarning (int errorNum, string msg)
48                 {
49                         Console.WriteLine (String.Format ("MSBUILD: warning MSBUILD{0:0000}: {1}", errorNum, msg));
50                 }
51
52                 static public void ReportInvalidArgument (string option, string value)
53                 {
54                         ReportError (1012, String.Format ("'{0}' is not a valid setting for option '{1}'", value, option));
55                 }
56
57                 static public void ReportMissingArgument (string option)
58                 {
59                         ReportError (1003, String.Format ("Compiler option '{0}' must be followed by an argument", option));
60                 }
61
62                 static public void ReportNotImplemented (string option)
63                 {
64                         ReportError (0, String.Format ("Compiler option '{0}' is not implemented", option));
65                 }
66  
67                 static public void ReportMissingFileSpec (string option)
68                 {
69                         ReportError (1008, String.Format ("Missing file specification for '{0}' command-line option", option));
70                 }
71
72                 static public void ReportMissingText (string option)
73                 {
74                         ReportError (1010, String.Format ("Missing ':<text>' for '{0}' option", option));
75                 }
76
77                 static public void ShowUsage ()
78                 {
79                         Display (version);
80                         Console.WriteLine ("xbuild [options] [project-file]");
81                         Console.WriteLine (
82                                 "    /version           Show the xbuild version\n" +
83                                 "    /noconsolelogger   Disable the default console logger\n" +
84                                 "    /target:T1[,TN]    List of targets to build\n" +
85                                 "    /property:Name=Value\n" +
86                                 "                       Set or override project properties\n" +
87                                 "    /logger:<logger>   Custom logger to log events\n" +
88                                 "    /verbosity:<level> Logger verbosity level : quiet, minimal, normal, detailed, diagnostic\n" +
89                                 "    /validate          Validate the project file against the schema\n" +
90                                 "    /validate:<schema> Validate the project file against the specified schema\n" +
91                                 "    /consoleloggerparameters:<params>\n" +
92                                 "    /clp:<params>\n" +
93                                 "                       Parameters for the console logger\n" +
94                                 "    /fileloggerparameters[n]:<params>\n" +
95                                 "    /flp[n]:<params>\n" +
96                                 "                       Parameters for the file logger, eg. LogFile=foo.log\n" +
97                                 "    /nologo            Don't show the initial banner\n" +
98                                 "    /help              Show this help\n"
99                                 );
100                         Environment.Exit (0);
101                 }
102
103                 static public void ShowVersion (bool exit)
104                 {
105                         Display (version);
106                         if (exit)
107                                 Environment.Exit (0);
108                 }
109
110                 static private void Display (string[] array)
111                 {
112                         foreach (string s in array)
113                                 Console.WriteLine (s);
114                 }
115         }
116 }
117