1 18 19 24 29 package org.apache.tools.ant.taskdefs.optional.dotnet; 30 31 35 import java.io.File ; 36 37 39 101 102 public class CSharp extends DotnetCompile { 103 104 108 String definitions; 109 110 111 114 private File docFile; 115 116 119 private int fileAlign = 0; 120 121 124 private boolean fullpaths = false; 125 126 129 private boolean incremental; 130 131 134 protected boolean unsafe; 135 136 140 private boolean noconfig = false; 141 143 144 147 148 public CSharp() { 149 clear(); 150 } 151 152 155 public void clear() { 156 super.clear(); 157 docFile = null; 158 fileAlign = 0; 159 fullpaths = true; 160 incremental = false; 161 unsafe = false; 162 noconfig = false; 163 definitions = null; 164 setExecutable(isWindows ? "csc" : "mcs"); 165 } 166 167 168 169 174 public void setDocFile(File f) { 175 docFile = f; 176 } 177 178 179 184 protected String getDocFileParameter() { 185 if (docFile != null) { 186 return "/doc:" + docFile.toString(); 187 } else { 188 return null; 189 } 190 } 191 192 198 public void setFileAlign(int fileAlign) { 199 this.fileAlign = fileAlign; 200 } 201 202 207 protected String getFileAlignParameter() { 208 if (fileAlign != 0 && !"mcs".equals(getExecutable())) { 209 return "/filealign:" + fileAlign; 210 } else { 211 return null; 212 } 213 } 214 215 216 221 public void setFullPaths(boolean enabled) { 222 fullpaths = enabled; 223 } 224 225 226 231 protected String getFullPathsParameter() { 232 return fullpaths ? "/fullpaths" : null; 233 } 234 235 236 241 public void setIncremental(boolean incremental) { 242 this.incremental = incremental; 243 } 244 245 246 251 public boolean getIncremental() { 252 return incremental; 253 } 254 255 256 261 protected String getIncrementalParameter() { 262 return "/incremental" + (incremental ? "+" : "-"); 263 } 264 265 270 public void setOutputFile(File params) { 271 setDestFile(params); 272 } 273 274 275 280 public void setUnsafe(boolean unsafe) { 281 this.unsafe = unsafe; 282 } 283 284 285 290 public boolean getUnsafe() { 291 return this.unsafe; 292 } 293 294 295 300 protected String getUnsafeParameter() { 301 return unsafe ? "/unsafe" : null; 302 } 303 304 305 311 public void setNoConfig(boolean enabled) { 312 noconfig = enabled; 313 } 314 315 316 321 protected String getNoConfigParameter() { 322 return noconfig ? "/noconfig" : null; 323 } 324 325 326 331 public void setDefinitions(String params) { 332 definitions = params; 333 } 334 335 341 protected String getDefinitionsParameter() { 342 String predecessors = super.getDefinitionsParameter(); 343 if (notEmpty(definitions)) { 344 if (predecessors == null) { 345 predecessors = "/define:"; 346 } 347 return predecessors + definitions; 348 } else { 349 return predecessors; 350 } 351 } 352 353 354 358 public void addCompilerSpecificOptions(NetCommand command) { 359 command.addArgument(getIncludeDefaultReferencesParameter()); 360 command.addArgument(getWarnLevelParameter()); 361 command.addArgument(getDocFileParameter()); 362 command.addArgument(getFullPathsParameter()); 363 command.addArgument(getFileAlignParameter()); 364 command.addArgument(getIncrementalParameter()); 365 command.addArgument(getNoConfigParameter()); 366 command.addArgument(getUnsafeParameter()); 367 } 368 369 371 375 public String getReferenceDelimiter() { 376 return ";"; 377 } 378 379 380 384 public String getFileExtension() { 385 return "cs"; 386 } 387 388 393 protected void createResourceParameter( 394 NetCommand command, DotnetResource resource) { 395 resource.getParameters(getProject(), command, true); 396 } 397 398 } 399 400 | Popular Tags |