merge r67228-r67235, r67237, r67251 and r67256-67259 to trunk (they are
[mono.git] / mcs / class / Microsoft.Build.Tasks / Microsoft.Build.Tasks / Csc.cs
1 //
2 // Csc.cs: Task that runs C# compiler
3 //
4 // Author:
5 //   Marek Sieradzki (marek.sieradzki@gmail.com)
6 //
7 // (C) 2005 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 #if NET_2_0
29
30 using System;
31 using System.IO;
32 using Microsoft.Build.Framework;
33 using Microsoft.Build.Tasks.Hosting;
34 using Microsoft.Build.Utilities;
35
36 namespace Microsoft.Build.Tasks {
37         public class Csc : ManagedCompiler {
38         
39                 public Csc ()
40                 {
41                 }
42
43                 [MonoTODO]
44                 protected internal override void AddResponseFileCommands (CommandLineBuilderExtension commandLine)
45                 {
46                         base.AddResponseFileCommands (commandLine);
47                         
48                         if (AllowUnsafeBlocks == true)
49                                 commandLine.AppendSwitch ("/unsafe");
50                         //baseAddress
51                         //checkForOverflowUnderflow
52                         commandLine.AppendSwitchIfNotNull ("/nowarn:", DisabledWarnings);
53                         commandLine.AppendSwitchIfNotNull ("/doc:", DocumentationFile);
54                         //errorReport
55                         commandLine.AppendSwitchIfNotNull ("/langversion:", LangVersion);
56                         //moduleAssemblyName
57                         if (NoStandardLib)
58                                 commandLine.AppendSwitch ("/nostdlib");
59                         //platform
60                         commandLine.AppendSwitchIfNotNull ("/warn:", WarningLevel.ToString ());
61                         //warningsAsErrors
62                         //warningNotAsErrors
63                 }
64
65                 [MonoTODO]
66                 protected override bool CallHostObjectToExecute ()
67                 {
68                         throw new NotImplementedException ();
69                 }
70
71                 protected override string GenerateFullPathToTool ()
72                 {
73                         return Path.Combine (ToolPath, ToolName);
74                 }
75
76                 [MonoTODO]
77                 protected override HostObjectInitializationStatus InitializeHostObject ()
78                 {
79                         return HostObjectInitializationStatus.NoActionReturnSuccess;
80                 }
81
82                 public bool AllowUnsafeBlocks {
83                         get { return GetBoolParameterWithDefault ("AllowUnsafeBlocks", false); }
84                         set { Bag ["AllowUnsafeBlocks"] = value; }
85                 }
86
87                 public string BaseAddress {
88                         get { return (string) Bag ["BaseAddress"]; }
89                         set { Bag ["BaseAddress"] = value; }
90                 }
91
92                 public bool CheckForOverflowUnderflow {
93                         get { return GetBoolParameterWithDefault ("CheckForOverflowUnderflow", false); }
94                         set { Bag ["CheckForOverflowUnderflow"] = value; }
95                 }
96
97                 public string DisabledWarnings {
98                         get { return (string) Bag ["DisabledWarnings"]; }
99                         set { Bag ["DisabledWarnings"] = value; }
100                 }
101
102                 public string DocumentationFile {
103                         get { return (string) Bag ["DocumentationFile"]; }
104                         set { Bag ["DocumentationFile"] = value; }
105                 }
106
107                 public string ErrorReport {
108                         get { return (string) Bag ["ErrorReport"]; }
109                         set { Bag ["ErrorReport"] = value; }
110                 }
111
112                 public bool GenerateFullPaths {
113                         get { return GetBoolParameterWithDefault ("GenerateFullPaths", false); }
114                         set { Bag ["GenerateFullPaths"] = value; }
115                 }
116
117                 public string LangVersion {
118                         get { return (string) Bag ["LangVersion"]; }
119                         set { Bag ["LangVersion"] = value; }
120                 }
121
122                 public string ModuleAssemblyName {
123                         get { return (string) Bag ["ModuleAssemblyName"]; }
124                         set { Bag ["ModuleAssemblyName"] = value; }
125                 }
126
127                 public bool NoStandardLib {
128                         get { return GetBoolParameterWithDefault ("NoStandardLib", false); }
129                         set { Bag ["NoStandardLib"] = value; }
130                 }
131                 
132                 public string PdbFile {
133                         get { return (string) Bag ["PdbFile"]; }
134                         set { Bag ["PdbFile"] = value; }
135                 }
136
137                 public string Platform {
138                         get { return (string) Bag ["Platform"]; }
139                         set { Bag ["Platform"] = value; }
140                 }
141
142                 protected override string ToolName {
143                         get { return "gmcs"; }
144                 }
145
146                 public bool UseHostCompilerIfAvailable {
147                         get { return GetBoolParameterWithDefault ("UseHostCompilerIfAvailable", false); }
148                         set { Bag ["UseHostCompilerIfAvailable"] = value; }
149                 }
150
151                 public int WarningLevel {
152                         get { return GetIntParameterWithDefault ("WarningLevel", 2); }
153                         set { Bag ["WarningLevel"] = value; }
154                 }
155
156                 public string WarningsAsErrors {
157                         get { return (string) Bag ["WarningsAsErrors"]; }
158                         set { Bag ["WarningsAsErrors"] = value; }
159                 }
160
161                 public string WarningsNotAsErrors {
162                         get { return (string) Bag ["WarningsNotAsErrors"]; }
163                         set { Bag ["WarningsNotAsErrors"] = value; }
164                 }
165         }
166 }
167
168 #endif