f0195f01e057ba46cd58d4e8f0b888d3b61ed819
[mono.git] / mcs / class / Microsoft.Build.Tasks / Microsoft.Build.Tasks / AL.cs
1 //
2 // AL.cs: Task for assembly linker
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.Diagnostics;
32 using System.IO;
33 using Microsoft.Build.Framework;
34 using Microsoft.Build.Utilities;
35 using Mono.XBuild.Utilities;
36
37 namespace Microsoft.Build.Tasks {
38         public class AL : ToolTaskExtension {
39         
40                 Process alProcess;
41         
42                 public AL ()
43                 {
44                 }
45                 
46                 [MonoTODO]
47                 protected internal override void AddResponseFileCommands (
48                                                  CommandLineBuilderExtension commandLine)
49                 {
50                         commandLine.AppendSwitchIfNotNull ("/algid:", AlgorithmId);
51                         commandLine.AppendSwitchIfNotNull ("/baseaddress:", BaseAddress);
52                         commandLine.AppendSwitchIfNotNull ("/company:", CompanyName);
53                         commandLine.AppendSwitchIfNotNull ("/configuration:", Configuration);
54                         commandLine.AppendSwitchIfNotNull ("/culture:", Culture);
55                         commandLine.AppendSwitchIfNotNull ("/copyright:", Copyright);
56                         if (Bag ["DelaySign"] != null)
57                                 if (DelaySign)
58                                         commandLine.AppendSwitch ("/delaysign+");
59                                 else
60                                         commandLine.AppendSwitch ("/delaysign-");
61                         commandLine.AppendSwitchIfNotNull ("/description:", Description);
62                         if (EmbedResources != null)
63                                 foreach (ITaskItem item in EmbedResources)
64                                         commandLine.AppendSwitchIfNotNull ("/embed:", item.ItemSpec);
65                         commandLine.AppendSwitchIfNotNull ("/evidence:", EvidenceFile);
66                         commandLine.AppendSwitchIfNotNull ("/fileversion:", FileVersion);
67                         commandLine.AppendSwitchIfNotNull ("/flags:", Flags);
68                         if (GenerateFullPaths)
69                                 commandLine.AppendSwitch ("/fullpaths");
70                         commandLine.AppendSwitchIfNotNull ("/keyname:", KeyContainer);
71                         commandLine.AppendSwitchIfNotNull ("/keyfile:", KeyFile);
72                         if (LinkResources != null)
73                                 foreach (ITaskItem item in LinkResources)
74                                         commandLine.AppendSwitchIfNotNull ("/link:", item.ItemSpec);
75                         commandLine.AppendSwitchIfNotNull ("/main:", MainEntryPoint);
76                         if (OutputAssembly != null)
77                                 commandLine.AppendSwitchIfNotNull ("/out:", OutputAssembly.ItemSpec);
78                         //platform
79                         commandLine.AppendSwitchIfNotNull ("/product:", ProductName);
80                         commandLine.AppendSwitchIfNotNull ("/productversion:", ProductVersion);
81                         if (ResponseFiles != null)
82                                 foreach (string s in ResponseFiles)
83                                         commandLine.AppendFileNameIfNotNull (String.Format ("@{0}", s));
84                         if (SourceModules != null)
85                                 foreach (ITaskItem item in SourceModules)
86                                         commandLine.AppendFileNameIfNotNull (item.ItemSpec);
87                         commandLine.AppendSwitchIfNotNull ("/target:", TargetType);
88                         commandLine.AppendSwitchIfNotNull ("/template:", TemplateFile);
89                         commandLine.AppendSwitchIfNotNull ("/title:", Title);
90                         commandLine.AppendSwitchIfNotNull ("/trademark:", Trademark);
91                         commandLine.AppendSwitchIfNotNull ("/version:", Version);
92                         commandLine.AppendSwitchIfNotNull ("/win32icon:", Win32Icon);
93                         commandLine.AppendSwitchIfNotNull ("/win32res:", Win32Resource);
94                 }
95                 
96                 public override bool Execute ()
97                 {
98                         return base.Execute ();
99                 }
100
101                 protected override string GenerateFullPathToTool ()
102                 {
103                         return Path.Combine (ToolPath, ToolExe);
104                 }
105
106                 public string AlgorithmId {
107                         get { return (string) Bag ["AlgorithmId"]; }
108                         set { Bag ["AlgorithmId"] = value; }
109                 }
110
111                 public string BaseAddress {
112                         get { return (string) Bag ["BaseAddress"]; }
113                         set { Bag ["BaseAddress"] = value; }
114                 }
115
116                 public string CompanyName {
117                         get { return (string) Bag ["CompanyName"]; }
118                         set { Bag ["CompanyName"] = value; }
119                 }
120
121                 public string Configuration {
122                         get { return (string) Bag ["Configuration"]; }
123                         set { Bag ["Configuration"] = value; }
124                 }
125
126                 public string Copyright {
127                         get { return (string) Bag ["Copyright"]; }
128                         set { Bag ["Copyright"] = value; }
129                 }
130
131                 public string Culture {
132                         get { return (string) Bag ["Culture"]; }
133                         set { Bag ["Culture"] = value; }
134                 }
135
136                 public bool DelaySign {
137                         get { return GetBoolParameterWithDefault ("DelaySign", false); }
138                         set { Bag ["DelaySign"] = value; }
139                 }
140
141                 public string Description {
142                         get { return (string) Bag ["Description"]; }
143                         set { Bag ["Description"] = value; }
144                 }
145
146                 public ITaskItem[] EmbedResources {
147                         get { return (ITaskItem[]) Bag ["EmbedResources"]; }
148                         set { Bag ["EmbedResources"] = value; }
149                 }
150
151                 public string EvidenceFile {
152                         get { return (string) Bag ["EvidenceFile"]; }
153                         set { Bag ["EvidenceFile"] = value; }
154                 }
155
156                 public string FileVersion {
157                         get { return (string) Bag ["FileVersion"]; }
158                         set { Bag ["FileVersion"] = value; }
159                 }
160
161                 public string Flags {
162                         get { return (string) Bag ["Flags"]; }
163                         set { Bag ["Flags"] = value; }
164                 }
165
166                 public bool GenerateFullPaths {
167                         get { return GetBoolParameterWithDefault ("GenerateFullPaths", false); }
168                         set { Bag ["GenerateFullPaths"] = value; }
169                 }
170
171                 public string KeyContainer {
172                         get { return (string) Bag ["KeyContainer"]; }
173                         set { Bag ["KeyContainer"] = value; }
174                 }
175
176                 public string KeyFile {
177                         get { return (string) Bag ["KeyFile"]; }
178                         set { Bag ["KeyFile"] = value; }
179                 }
180
181                 public ITaskItem[] LinkResources {
182                         get { return (ITaskItem[]) Bag ["LinkResources"]; }
183                         set { Bag ["LinkResources"] = value; }
184                 }
185
186                 public string MainEntryPoint {
187                         get { return (string) Bag ["MainEntryPoint"]; }
188                         set { Bag ["MainEntryPoint"] = value; }
189                 }
190
191                 [Required]
192                 [Output]
193                 public ITaskItem OutputAssembly {
194                         get { return (ITaskItem) Bag ["OutputAssembly"]; }
195                         set { Bag ["OutputAssembly"] = value; }
196                 }
197
198                 public string Platform {
199                         get { return (string) Bag ["Platform"]; }
200                         set { Bag ["Platform"] = value; }
201                 }
202
203                 public string ProductName {
204                         get { return (string) Bag ["ProductName"]; }
205                         set { Bag ["ProductName"] = value; }
206                 }
207
208                 public string ProductVersion {
209                         get { return (string) Bag ["ProductVersion"]; }
210                         set { Bag ["ProductVersion"] = value; }
211                 }
212
213                 public string[] ResponseFiles {
214                         get { return (string[]) Bag ["ResponseFiles"]; }
215                         set { Bag ["ResponseFiles"] = value; }
216                 }
217
218                 public ITaskItem[] SourceModules {
219                         get { return (ITaskItem[]) Bag ["SourceModules"]; }
220                         set { Bag ["SourceModules"] = value; }
221                 }
222
223                 public string TargetType {
224                         get { return (string) Bag ["TargetType"]; }
225                         set { Bag ["TargetType"] = value; }
226                 }
227
228                 public string TemplateFile {
229                         get { return (string) Bag ["TemplateFile"]; }
230                         set { Bag ["TemplateFile"] = value; }
231                 }
232
233                 public string Title {
234                         get { return (string) Bag ["Title"]; }
235                         set { Bag ["Title"] = value; }
236                 }
237
238                 protected override string ToolName {
239                         get {
240                                 return MSBuildUtils.RunningOnWindows ? "al.bat" : "al";
241                         }
242                 }
243
244                 public string Trademark {
245                         get { return (string) Bag ["Trademark"]; }
246                         set { Bag ["Trademark"] = value; }
247                 }
248
249                 public string Version {
250                         get { return (string) Bag ["Version"]; }
251                         set { Bag ["Version"] = value; }
252                 }
253
254                 public string Win32Icon {
255                         get { return (string) Bag ["Win32Icon"]; }
256                         set { Bag ["Win32Icon"] = value; }
257                 }
258
259                 public string Win32Resource {
260                         get { return (string) Bag ["Win32Resource"]; }
261                         set { Bag ["Win32Resource"] = value; }
262                 }
263         }
264 }
265
266 #endif