KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tools > ant > taskdefs > optional > dotnet > DotnetCompile


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */

18
19 /*
20  * build notes
21  * -The reference CD to listen to while editing this file is
22  * nap:Cream+Live+2001+CD+2
23  */

24
25 // place in the optional ant tasks package
26
// but in its own dotnet group
27

28 package org.apache.tools.ant.taskdefs.optional.dotnet;
29
30 // imports
31

32 import java.io.File JavaDoc;
33 import java.util.Vector JavaDoc;
34 import java.util.Enumeration JavaDoc;
35 import java.util.Hashtable JavaDoc;
36
37 import org.apache.tools.ant.BuildException;
38 import org.apache.tools.ant.Project;
39 import org.apache.tools.ant.types.Commandline;
40 import org.apache.tools.ant.types.Path;
41 import org.apache.tools.ant.types.FileSet;
42 import org.apache.tools.ant.types.EnumeratedAttribute;
43
44
45 /**
46  * Abstract superclass for dotnet compiler tasks.
47  *
48  * History
49  * <table>
50  * <tr>
51  * <td>
52  * 0.1
53  * </td>
54  * <td>
55  * First creation
56  * </td>
57  * <td>
58  * Most of the code here was copied verbatim from v0.3 of
59  * Steve Loughran's CSharp optional task. Abstracted functionality
60  * to allow subclassing of other dotnet compiler types.
61  * </td>
62  * </tr>
63  *
64  * </table>
65  *
66  *
67  * @version 0.1
68  */

69
70 public abstract class DotnetCompile
71          extends DotnetBaseMatchingTask {
72
73     /**
74      * list of reference classes. (pretty much a classpath equivalent)
75      */

76     private String JavaDoc references;
77
78     /**
79      * flag to enable automatic reference inclusion
80      */

81     private boolean includeDefaultReferences = true;
82
83     /**
84      * icon for incorporation into apps
85      */

86     private File JavaDoc win32icon;
87
88     /**
89      * icon for incorporation into apps
90      */

91     private File JavaDoc win32res;
92
93     /**
94      * flag to control action on execution trouble
95      */

96     private boolean failOnError;
97
98     /**
99      * using the path approach didn't work as it could not handle the implicit
100      * execution path. Perhaps that could be extracted from the runtime and
101      * then the path approach would be viable
102      */

103     private Path referenceFiles;
104
105     /**
106      * optimise flag
107      */

108     private boolean optimize;
109
110     // CheckStyle:VisibilityModifier OFF - bc
111
/**
112      * a list of definitions to support;
113      */

114     protected Vector JavaDoc definitionList = new Vector JavaDoc();
115
116     /**
117      * our resources
118      */

119     protected Vector JavaDoc resources = new Vector JavaDoc();
120
121     /**
122      * executable
123      */

124
125     protected String JavaDoc executable;
126
127     protected static final String JavaDoc REFERENCE_OPTION = "/reference:";
128
129     /**
130      * debug flag. Controls generation of debug information.
131      */

132     protected boolean debug;
133
134     /**
135      * warning level: 0-4, with 4 being most verbose
136      */

137     private int warnLevel;
138
139     /**
140      * main class (or null for automatic choice)
141      */

142     protected String JavaDoc mainClass;
143
144     /**
145      * any extra command options?
146      */

147     protected String JavaDoc extraOptions;
148
149     /**
150      * type of target. Should be one of exe|library|module|winexe|(null)
151      * default is exe; the actual value (if not null) is fed to the command
152      * line. <br>
153      * See /target
154      */

155     protected String JavaDoc targetType;
156
157     /**
158      * utf out flag
159      */

160
161     protected boolean utf8output = false;
162
163     /**
164      * list of extra modules to refer to
165      */

166     protected String JavaDoc additionalModules;
167     /**
168      * filesets of references
169      */

170     protected Vector JavaDoc referenceFilesets = new Vector JavaDoc();
171
172     /**
173      * flag to set to to use @file based command cache
174      */

175     private boolean useResponseFile = false;
176     private static final int AUTOMATIC_RESPONSE_FILE_THRESHOLD = 64;
177
178     // CheckStyle:VisibilityModifier ON
179

180     /**
181      * constructor inits everything and set up the search pattern
182      */

183
184     public DotnetCompile() {
185         clear();
186         setIncludes(getFilePattern());
187     }
188
189     /**
190      * reset all contents.
191      */

192     public void clear() {
193         targetType = null;
194         win32icon = null;
195         srcDir = null;
196         mainClass = null;
197         warnLevel = 3;
198         optimize = false;
199         debug = true;
200         references = null;
201         failOnError = true;
202         additionalModules = null;
203         includeDefaultReferences = true;
204         extraOptions = null;
205     }
206
207
208     /**
209      * Semicolon separated list of DLLs to refer to.
210      *
211      *@param s The new References value
212      */

213     public void setReferences(String JavaDoc s) {
214         references = s;
215     }
216
217
218     /**
219      * get the reference string or null for no argument needed
220      *
221      *@return The References Parameter to CSC
222      */

223     protected String JavaDoc getReferencesParameter() {
224         //bail on no references
225
if (notEmpty(references)) {
226             if (isWindows) {
227                 return '\"' + REFERENCE_OPTION + references + '\"';
228             } else {
229                 return REFERENCE_OPTION + references;
230             }
231         } else {
232             return null;
233         }
234     }
235
236     /**
237      * Path of references to include.
238      * Wildcards should work.
239      *
240      *@param path another path to append
241      */

242     public void setReferenceFiles(Path path) {
243         //demand create pathlist
244
if (referenceFiles == null) {
245             referenceFiles = new Path(this.getProject());
246         }
247         referenceFiles.append(path);
248     }
249
250     /**
251      * add a new reference fileset to the compilation
252      * @param reference the files to use.
253      */

254     public void addReference(FileSet reference) {
255         referenceFilesets.add(reference);
256     }
257
258
259
260     /**
261      * turn the path list into a list of files and a /references argument
262      *
263      *@return null or a string of references.
264      */

265     protected String JavaDoc getReferenceFilesParameter() {
266         //bail on no references
267
if (references == null) {
268             return null;
269         }
270         //iterate through the ref list & generate an entry for each
271
//or just rely on the fact that the toString operator does this, but
272
//noting that the separator is ';' on windows, ':' on unix
273

274         //bail on no references listed
275
if (references.length() == 0) {
276             return null;
277         }
278
279         StringBuffer JavaDoc s = new StringBuffer JavaDoc(REFERENCE_OPTION);
280         if (isWindows) {
281             s.append('\"');
282         }
283         s.append(references);
284         if (isWindows) {
285             s.append('\"');
286         }
287         return s.toString();
288     }
289
290
291     /**
292      * If true, automatically includes the common assemblies
293      * in dotnet, and tells the compiler to link in mscore.dll.
294      *
295      * set the automatic reference inclusion flag on or off this flag controls
296      * the /nostdlib option in CSC
297      *
298      *@param f on/off flag
299      */

300     public void setIncludeDefaultReferences(boolean f) {
301         includeDefaultReferences = f;
302     }
303
304
305     /**
306      * query automatic reference inclusion flag
307      *
308      *@return true if flag is turned on
309      */

310     public boolean getIncludeDefaultReferences() {
311         return includeDefaultReferences;
312     }
313
314
315     /**
316      * get the include default references flag or null for no argument needed
317      *
318      *@return The Parameter to CSC
319      */

320     protected String JavaDoc getIncludeDefaultReferencesParameter() {
321         return "/nostdlib" + (includeDefaultReferences ? "-" : "+");
322     }
323
324
325
326     /**
327      * If true, enables optimization flag.
328      *
329      *@param f on/off flag
330      */

331     public void setOptimize(boolean f) {
332         optimize = f;
333     }
334
335
336     /**
337      * query the optimise flag
338      *
339      *@return true if optimise is turned on
340      */

341     public boolean getOptimize() {
342         return optimize;
343     }
344
345
346     /**
347      * get the optimise flag or null for no argument needed
348      *
349      *@return The Optimize Parameter to CSC
350      */

351     protected String JavaDoc getOptimizeParameter() {
352         return "/optimize" + (optimize ? "+" : "-");
353     }
354
355
356     /**
357      * set the debug flag on or off.
358      *
359      *@param f on/off flag
360      */

361     public void setDebug(boolean f) {
362         debug = f;
363     }
364
365
366     /**
367      * query the debug flag
368      *
369      *@return true if debug is turned on
370      */

371     public boolean getDebug() {
372         return debug;
373     }
374
375
376     /**
377      * get the debug switch argument
378      *
379      *@return The Debug Parameter to CSC
380      */

381     protected String JavaDoc getDebugParameter() {
382         return "/debug" + (debug ? "+" : "-");
383     }
384
385
386     /**
387      * Level of warning currently between 1 and 4
388      * with 4 being the strictest.
389      *
390      *@param warnLevel warn level -see .net docs for valid range (probably
391      * 0-4)
392      */

393     public void setWarnLevel(int warnLevel) {
394         this.warnLevel = warnLevel;
395     }
396
397
398     /**
399      * query warn level
400      *
401      *@return current value
402      */

403     public int getWarnLevel() {
404         return warnLevel;
405     }
406
407
408     /**
409      * get the warn level switch
410      *
411      *@return The WarnLevel Parameter to CSC
412      */

413     protected String JavaDoc getWarnLevelParameter() {
414         return "/warn:" + warnLevel;
415     }
416
417
418     /**
419      * Sets the name of main class for executables.
420      *
421      *@param mainClass The new MainClass value
422      */

423     public void setMainClass(String JavaDoc mainClass) {
424         this.mainClass = mainClass;
425     }
426
427
428     /**
429      * Gets the MainClass attribute
430      *
431      *@return The MainClass value
432      */

433     public String JavaDoc getMainClass() {
434         return this.mainClass;
435     }
436
437
438     /**
439      * get the /main argument or null for no argument needed
440      *
441      *@return The MainClass Parameter to CSC
442      */

443     protected String JavaDoc getMainClassParameter() {
444         if (mainClass != null && mainClass.length() != 0) {
445             return "/main:" + mainClass;
446         } else {
447             return null;
448         }
449     }
450
451
452     /**
453      * Any extra options which are not explicitly supported
454      * by this task.
455      *
456      *@param extraOptions The new ExtraOptions value
457      */

458     public void setExtraOptions(String JavaDoc extraOptions) {
459         this.extraOptions = extraOptions;
460     }
461
462
463     /**
464      * Gets the ExtraOptions attribute
465      *
466      *@return The ExtraOptions value
467      */

468     public String JavaDoc getExtraOptions() {
469         return this.extraOptions;
470     }
471
472
473     /**
474      * get any extra options or null for no argument needed
475      *
476      *@return The ExtraOptions Parameter to CSC
477      */

478     protected String JavaDoc getExtraOptionsParameter() {
479         if (extraOptions != null && extraOptions.length() != 0) {
480             return extraOptions;
481         } else {
482             return null;
483         }
484     }
485
486     /**
487      * get any extra options or null for no argument needed, split
488      * them if they represent multiple options.
489      *
490      * @return The ExtraOptions Parameter to CSC
491      */

492     protected String JavaDoc[] getExtraOptionsParameters() {
493         String JavaDoc extra = getExtraOptionsParameter();
494         return extra == null ? null : Commandline.translateCommandline(extra);
495     }
496
497     /**
498      * Set the destination directory of files to be compiled.
499      *
500      *@param dirName The new DestDir value
501      */

502     public void setDestDir(File JavaDoc dirName) {
503         log("DestDir currently unused", Project.MSG_WARN);
504     }
505
506
507     /**
508      * set the target type to one of exe|library|module|winexe
509      * @param targetType the enumerated value.
510      */

511     public void setTargetType(TargetTypes targetType) {
512         this.targetType = targetType.getValue();
513     }
514     /**
515      * Set the type of target.
516      *
517      *@param ttype The new TargetType value
518      *@exception BuildException if target is not one of
519      * exe|library|module|winexe
520      */

521     public void setTargetType(String JavaDoc ttype)
522              throws BuildException {
523         ttype = ttype.toLowerCase();
524         if (ttype.equals("exe") || ttype.equals("library")
525             || ttype.equals("module") || ttype.equals("winexe")) {
526             targetType = ttype;
527         } else {
528             throw new BuildException("targetType " + ttype
529                     + " is not one of 'exe', 'module', 'winexe' or 'library'");
530         }
531     }
532
533
534     /**
535      * Gets the TargetType attribute
536      *
537      *@return The TargetType value
538      */

539     public String JavaDoc getTargetType() {
540         return targetType;
541     }
542
543
544     /**
545      * get the argument or null for no argument needed
546      *
547      *@return The TargetType Parameter to CSC
548      */

549     protected String JavaDoc getTargetTypeParameter() {
550         if (notEmpty(targetType)) {
551             return "/target:" + targetType;
552         } else {
553             return null;
554         }
555     }
556
557
558     /**
559      * Set the filename of icon to include.
560      *
561      *@param fileName path to the file. Can be relative, absolute, whatever.
562      */

563     public void setWin32Icon(File JavaDoc fileName) {
564         win32icon = fileName;
565     }
566
567
568     /**
569      * get the argument or null for no argument needed
570      *
571      *@return The Win32Icon Parameter to CSC
572      */

573     protected String JavaDoc getWin32IconParameter() {
574         if (win32icon != null) {
575             return "/win32icon:" + win32icon.toString();
576         } else {
577             return null;
578         }
579     }
580
581
582     /**
583      * Sets the filename of a win32 resource (.RES) file to include.
584      * This is not a .NET resource, but what Windows is used to.
585      *
586      *@param fileName path to the file. Can be relative, absolute, whatever.
587      */

588     public void setWin32Res(File JavaDoc fileName) {
589         win32res = fileName;
590     }
591
592     /**
593      * Gets the file of the win32 .res file to include.
594      * @return path to the file.
595      */

596     public File JavaDoc getWin32Res() {
597         return win32res;
598     }
599
600
601     /**
602      * get the argument or null for no argument needed
603      *
604      *@return The Win32Res Parameter to CSC
605      */

606     protected String JavaDoc getWin32ResParameter() {
607         if (win32res != null) {
608             return "/win32res:" + win32res.toString();
609         } else {
610             return null;
611         }
612     }
613
614
615     /**
616      * If true, require all compiler output to be in UTF8 format.
617      *
618      *@param enabled The new utf8Output value
619      */

620     public void setUtf8Output(boolean enabled) {
621         utf8output = enabled;
622     }
623
624
625     /**
626      * Gets the utf8OutpuParameter attribute of the CSharp object
627      *
628      *@return The utf8OutpuParameter value
629      */

630     protected String JavaDoc getUtf8OutputParameter() {
631         return utf8output ? "/utf8output" : null;
632     }
633
634
635     /**
636      * add a define to the list of definitions
637      * @param define the define value.
638      */

639     public void addDefine(DotnetDefine define) {
640         definitionList.addElement(define);
641     }
642
643
644     /**
645      * get a list of definitions or null
646      * @return a string beginning /D: or null for no definitions
647      * @throws BuildException if there is an error.
648      */

649     protected String JavaDoc getDefinitionsParameter() throws BuildException {
650         StringBuffer JavaDoc defines = new StringBuffer JavaDoc();
651         Enumeration JavaDoc defEnum = definitionList.elements();
652         boolean firstDefinition = true;
653         while (defEnum.hasMoreElements()) {
654             //loop through all definitions
655
DotnetDefine define = (DotnetDefine) defEnum.nextElement();
656             if (define.isSet(this)) {
657                 //add those that are set, and a delimiter
658
if (!firstDefinition) {
659                     defines.append(getDefinitionsDelimiter());
660                 }
661                 defines.append(define.getValue(this));
662                 firstDefinition = false;
663             }
664         }
665         if (defines.length() == 0) {
666             return null;
667         } else {
668             return "/d:" + defines;
669         }
670     }
671
672
673     /**
674      * Semicolon separated list of modules to refer to.
675      *
676      *@param params The new additionalModules value
677      */

678     public void setAdditionalModules(String JavaDoc params) {
679         additionalModules = params;
680     }
681
682
683     /**
684      * get the argument or null for no argument needed
685      *
686      *@return The AdditionalModules Parameter to CSC
687      */

688     protected String JavaDoc getAdditionalModulesParameter() {
689         if (notEmpty(additionalModules)) {
690             return "/addmodule:" + additionalModules;
691         } else {
692             return null;
693         }
694     }
695
696
697     /**
698      * get the argument or null for no argument needed
699      *
700      *@return The OutputFile Parameter to CSC
701      */

702     protected String JavaDoc getDestFileParameter() {
703         if (outputFile != null) {
704             return "/out:" + outputFile.toString();
705         } else {
706             return null;
707         }
708     }
709
710
711     /**
712      * If true, fail on compilation errors.
713      *
714      *@param b The new FailOnError value
715      */

716     public void setFailOnError(boolean b) {
717         failOnError = b;
718     }
719
720
721     /**
722      * query fail on error flag
723      *
724      *@return The FailFailOnError value
725      */

726     public boolean getFailOnError() {
727         return failOnError;
728     }
729
730     /**
731      * link or embed a resource
732      * @param resource the resource to use.
733      */

734     public void addResource(DotnetResource resource) {
735         resources.add(resource);
736     }
737
738     /**
739      * This method gets the name of the executable.
740      * @return the name of the executable
741      */

742     protected String JavaDoc getExecutable() {
743         return executable;
744     }
745
746     /**
747      * set the name of the program, overriding the defaults.
748      * Can be used to set the full path to a program, or to switch
749      * to an alternate implementation of the command, such as the Mono or Rotor
750      * versions -provided they use the same command line arguments as the
751      * .NET framework edition
752      * @param executable the name of the program.
753      */

754     public void setExecutable(String JavaDoc executable) {
755         this.executable = executable;
756     }
757
758     /**
759      * test for a string containing something useful
760      *
761      *@param s string in
762      *@return true if the argument is not null or empty
763      */

764     protected boolean notEmpty(String JavaDoc s) {
765         return s != null && s.length() != 0;
766     }
767
768     /**
769      * validation code
770      * @throws BuildException if validation failed
771      */

772     protected void validate()
773             throws BuildException {
774         if (outputFile != null && outputFile.isDirectory()) {
775             throw new BuildException("destFile cannot be a directory");
776         }
777         if (getExecutable() == null) {
778             throw new BuildException("There is no executable defined for this task");
779         }
780     }
781
782     /**
783      * Get the pattern for files to compile.
784      * @return The compilation file pattern.
785      */

786     public String JavaDoc getFilePattern() {
787         return "**/*." + getFileExtension();
788     }
789
790     /**
791      * getter for flag
792      * @return The flag indicating whether the compilation is using a response file.
793      */

794     public boolean isUseResponseFile() {
795         return useResponseFile;
796     }
797
798     /**
799      * Flag to turn on response file use; default=false.
800      * When set the command params are saved to a file and
801      * this is passed in with @file. The task automatically switches
802      * to this mode with big commands; this option is here for
803      * testing and emergencies
804      * @param useResponseFile a <code>boolean</code> value.
805      */

806     public void setUseResponseFile(boolean useResponseFile) {
807         this.useResponseFile = useResponseFile;
808     }
809
810     /**
811      * do the work by building the command line and then calling it
812      *
813      *@throws BuildException if validation or execution failed
814      */

815     public void execute()
816              throws BuildException {
817         log("This task is deprecated and will be removed in a future version\n"
818             + "of Ant. It is now part of the .NET Antlib:\n"
819             + "http://ant.apache.org/antlibs/dotnet/index.html",
820             Project.MSG_WARN);
821
822         validate();
823         NetCommand command = createNetCommand();
824         //set up response file options
825
command.setAutomaticResponseFileThreshold(AUTOMATIC_RESPONSE_FILE_THRESHOLD);
826         command.setUseResponseFile(useResponseFile);
827         //fill in args
828
fillInSharedParameters(command);
829         addResources(command);
830         addCompilerSpecificOptions(command);
831         int referencesOutOfDate
832             = addReferenceFilesets(command, getOutputFileTimestamp());
833         //if the refs are out of date, force a build.
834
boolean forceBuild = referencesOutOfDate > 0;
835         addFilesAndExecute(command, forceBuild);
836
837     }
838
839     /**
840      * Get the delimiter that the compiler uses between references.
841      * For example, c# will return ";"; VB.NET will return ","
842      * @return The string delimiter for the reference string.
843      */

844     public abstract String JavaDoc getReferenceDelimiter();
845
846     /**
847      * Get the extension of filenames to compile.
848      * @return The string extension of files to compile.
849      */

850     public abstract String JavaDoc getFileExtension();
851
852
853     /**
854      * fill in the common information
855      * @param command the net command.
856      */

857     protected void fillInSharedParameters(NetCommand command) {
858         command.setFailOnError(getFailOnError());
859         //fill in args
860
command.addArgument("/nologo");
861         command.addArgument(getAdditionalModulesParameter());
862         command.addArgument(getDebugParameter());
863         command.addArgument(getDefinitionsParameter());
864         command.addArguments(getExtraOptionsParameters());
865         command.addArgument(getMainClassParameter());
866         command.addArgument(getOptimizeParameter());
867         command.addArgument(getDestFileParameter());
868         command.addArgument(getReferencesParameter());
869         command.addArgument(getTargetTypeParameter());
870         command.addArgument(getUtf8OutputParameter());
871         command.addArgument(getWin32IconParameter());
872         command.addArgument(getWin32ResParameter());
873     }
874
875     /**
876      * for every resource declared, we get the (language specific)
877      * resource setting
878      * @param command the net command.
879      */

880     protected void addResources(NetCommand command) {
881         Enumeration JavaDoc e = resources.elements();
882         while (e.hasMoreElements()) {
883             DotnetResource resource = (DotnetResource) e.nextElement();
884             createResourceParameter(command, resource);
885         }
886     }
887
888     /**
889      * Build a C# style parameter.
890      * @param command the command.
891      * @param resource the resource.
892      */

893     protected abstract void createResourceParameter(NetCommand command, DotnetResource resource);
894
895
896     /**
897      * run through the list of reference files and add them to the command
898      * @param command the command to use.
899      * @param outputTimestamp timestamp to compare against
900      * @return number of files out of date
901      */

902
903     protected int addReferenceFilesets(NetCommand command, long outputTimestamp) {
904         int filesOutOfDate = 0;
905         Hashtable JavaDoc filesToBuild = new Hashtable JavaDoc();
906         for (int i = 0; i < referenceFilesets.size(); i++) {
907             FileSet fs = (FileSet) referenceFilesets.elementAt(i);
908             filesOutOfDate += command.scanOneFileset(
909                     fs.getDirectoryScanner(getProject()),
910                     filesToBuild,
911                     outputTimestamp);
912         }
913         //bail out early if there were no files
914
if (filesToBuild.size() == 0) {
915             return 0;
916         }
917         //now scan the hashtable and add the files
918
Enumeration JavaDoc files = filesToBuild.elements();
919         while (files.hasMoreElements()) {
920             File JavaDoc file = (File JavaDoc) files.nextElement();
921             if (isFileManagedBinary(file)) {
922                 if (isWindows) {
923                     command.addArgument(
924                     '"' + REFERENCE_OPTION + file.toString() + '"');
925                 } else {
926                     command.addArgument(REFERENCE_OPTION + file.toString());
927                 }
928             } else {
929                 log("ignoring " + file + " as it is not a managed executable",
930                         Project.MSG_VERBOSE);
931             }
932
933         }
934
935         return filesOutOfDate;
936     }
937
938     /**
939      * create our helper command
940      * @return a command prefilled with the exe name and task name
941      */

942     protected NetCommand createNetCommand() {
943         NetCommand command = new NetCommand(this, getTaskName(), getExecutable());
944         return command;
945     }
946
947     /**
948      * add any compiler specifics
949      * @param command the command to use.
950      */

951     protected abstract void addCompilerSpecificOptions(NetCommand command);
952
953     /**
954      * override point for delimiting definitions.
955      * @return The definitions limiter, i.e., ";"
956      */

957     public String JavaDoc getDefinitionsDelimiter() {
958         return ";";
959     }
960
961
962     /**
963      * test for a file being managed or not
964      * @param file the file to test.
965      * @return true if we think this is a managed executable, and thus OK
966      * for linking
967      * @todo look at the PE header of the exe and see if it is managed or not.
968      */

969     protected static boolean isFileManagedBinary(File JavaDoc file) {
970         String JavaDoc filename = file.toString().toLowerCase();
971         return filename.endsWith(".exe") || filename.endsWith(".dll")
972                 || filename.endsWith(".netmodule");
973     }
974
975     /**
976      * Target types to build.
977      * valid build types are exe|library|module|winexe
978      */

979     public static class TargetTypes extends EnumeratedAttribute {
980         /** {@inheritDoc}. */
981         public String JavaDoc[] getValues() {
982             return new String JavaDoc[] {
983                 "exe",
984                 "library",
985                 "module",
986                 "winexe"
987             };
988         }
989     }
990
991
992 }
993
994
995
Popular Tags