~halega/+junk/sharpdevelop

« back to all changes in this revision

Viewing changes to samples/Mono/Mono.Build.Tasks/MonoCSharpCompilerTask.cs

  • Committer: sk
  • Date: 2011-09-10 05:17:57 UTC
  • Revision ID: halega@halega.com-20110910051757-qfouz1llya9m6boy
4.1.0.7915 Release Candidate 1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// SharpDevelop samples
 
2
// Copyright (c) 2006, AlphaSierraPapa
 
3
// All rights reserved.
 
4
//
 
5
// Redistribution and use in source and binary forms, with or without modification, are
 
6
// permitted provided that the following conditions are met:
 
7
//
 
8
// - Redistributions of source code must retain the above copyright notice, this list
 
9
//   of conditions and the following disclaimer.
 
10
//
 
11
// - Redistributions in binary form must reproduce the above copyright notice, this list
 
12
//   of conditions and the following disclaimer in the documentation and/or other materials
 
13
//   provided with the distribution.
 
14
//
 
15
// - Neither the name of the SharpDevelop team nor the names of its contributors may be used to
 
16
//   endorse or promote products derived from this software without specific prior written
 
17
//   permission.
 
18
//
 
19
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS &AS IS& AND ANY EXPRESS
 
20
// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
 
21
// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 
22
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 
23
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 
24
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
 
25
// IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 
26
// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
27
 
 
28
using System;
 
29
using System.CodeDom.Compiler;
 
30
 
 
31
namespace Mono.Build.Tasks
 
32
{
 
33
        /// <summary>
 
34
        /// Base class for the Mcs and Gmcs tasks.
 
35
        /// </summary>
 
36
        public abstract class MonoCSharpCompilerTask : MonoCompilerTask
 
37
        {
 
38
                bool checkForOverflowUnderflow;
 
39
                bool delaySign;
 
40
                string documentationFile;
 
41
                string keyContainer;
 
42
                string keyFile;
 
43
                string langVersion;
 
44
                string moduleAssemblyName;
 
45
                bool noConfig;
 
46
                string win32Icon;
 
47
                string win32Resource;
 
48
                
 
49
                MonoCSharpCompilerResultsParser parser = new MonoCSharpCompilerResultsParser();
 
50
                
 
51
                public bool CheckForOverflowUnderflow {
 
52
                        get { return checkForOverflowUnderflow; }
 
53
                        set { checkForOverflowUnderflow = value; }
 
54
                }
 
55
                
 
56
                public bool DelaySign {
 
57
                        get { return delaySign; }
 
58
                        set { delaySign = value; }
 
59
                }
 
60
                
 
61
                public string DocumentationFile {
 
62
                        get { return documentationFile; }
 
63
                        set { documentationFile = value; }
 
64
                }
 
65
                
 
66
                public string KeyContainer {
 
67
                        get { return keyContainer; }
 
68
                        set { keyContainer = value; }
 
69
                }
 
70
                
 
71
                public string KeyFile {
 
72
                        get { return keyFile; }
 
73
                        set { keyFile = value; }
 
74
                }
 
75
 
 
76
                public string LangVersion {
 
77
                        get { return langVersion; }
 
78
                        set { langVersion = value; }
 
79
                }
 
80
                
 
81
                public string ModuleAssemblyName {
 
82
                        get { return moduleAssemblyName; }
 
83
                        set { moduleAssemblyName = value; }
 
84
                }
 
85
 
 
86
                public bool NoConfig {
 
87
                        get { return noConfig; }
 
88
                        set { noConfig = value; }
 
89
                }
 
90
                
 
91
                public string Win32Icon {
 
92
                        get { return win32Icon; }
 
93
                        set { win32Icon = value; }
 
94
                }
 
95
                
 
96
                public string Win32Resource {
 
97
                        get { return win32Resource; }
 
98
                        set { win32Resource = value; }
 
99
                }
 
100
                
 
101
                protected override string GenerateResponseFileCommands()
 
102
                {
 
103
                        CompilerCommandLineArguments args = new CompilerCommandLineArguments();
 
104
                        args.AppendSwitchIfTrue("-noconfig", noConfig); 
 
105
                        if (IsWarningLevelSet) {
 
106
                                args.AppendSwitch("-warn:", WarningLevel.ToString());
 
107
                        }
 
108
                        args.AppendFileNameIfNotNull("-out:", OutputAssembly);
 
109
                        args.AppendTarget(TargetType);
 
110
                        args.AppendSwitchIfTrue("-debug", EmitDebugInformation);
 
111
                        args.AppendSwitchIfTrue("-optimize", Optimize);                 
 
112
                        args.AppendSwitchIfTrue("-nologo", NoLogo);
 
113
                        args.AppendSwitchIfTrue("-unsafe", AllowUnsafeBlocks);
 
114
                        args.AppendSwitchIfTrue("-nostdlib", NoStandardLib);
 
115
                        args.AppendSwitchIfTrue("-checked", checkForOverflowUnderflow);
 
116
                        args.AppendSwitchIfTrue("-delaysign", delaySign);
 
117
                        args.AppendSwitchIfNotNull("-langversion:", langVersion);
 
118
                        args.AppendSwitchIfNotNull("-keycontainer:", keyContainer);
 
119
                        args.AppendSwitchIfNotNull("-keyfile:", keyFile);
 
120
                        args.AppendSwitchIfNotNull("-define:", DefineConstants);
 
121
                        args.AppendSwitchIfTrue("-warnaserror", TreatWarningsAsErrors);
 
122
                        args.AppendSwitchIfNotNull("-nowarn:", DisabledWarnings);
 
123
                        args.AppendSwitchIfNotNull("-main:", MainEntryPoint);
 
124
                        args.AppendFileNameIfNotNull("-doc:", documentationFile);
 
125
                        args.AppendSwitchIfNotNull("-lib:", AdditionalLibPaths, ",");
 
126
                        args.AppendReferencesIfNotNull(References);
 
127
                        args.AppendItemsIfNotNull("-resource:", Resources);
 
128
                        args.AppendFileNameIfNotNull("-win32res:", win32Resource);
 
129
                        args.AppendFileNameIfNotNull("-win32icon:", win32Icon);
 
130
                        args.AppendFileNamesIfNotNull(Sources, " ");
 
131
 
 
132
                        return args.ToString();
 
133
                }
 
134
                
 
135
                protected override CompilerError ParseLine(string line)
 
136
                {
 
137
                        return parser.ParseLine(line);
 
138
                }
 
139
        }
 
140
}