--- /dev/null
+/*\r
+ * \r
+ * Copyright 2001-2005 The Ant-Contrib project\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+package net.sf.antcontrib.cpptasks;\r
+\r
+import java.io.File;\r
+import java.io.IOException;\r
+import java.util.Enumeration;\r
+import java.util.Hashtable;\r
+import java.util.Iterator;\r
+import java.util.Vector;\r
+\r
+import net.sf.antcontrib.cpptasks.compiler.AslcompilerConfiguration;\r
+import net.sf.antcontrib.cpptasks.compiler.AssemblerConfiguration;\r
+import net.sf.antcontrib.cpptasks.compiler.CompilerConfiguration;\r
+import net.sf.antcontrib.cpptasks.compiler.LinkType;\r
+import net.sf.antcontrib.cpptasks.compiler.Linker;\r
+import net.sf.antcontrib.cpptasks.compiler.LinkerConfiguration;\r
+import net.sf.antcontrib.cpptasks.compiler.Processor;\r
+import net.sf.antcontrib.cpptasks.compiler.ProcessorConfiguration;\r
+import net.sf.antcontrib.cpptasks.types.AslcompilerArgument;\r
+import net.sf.antcontrib.cpptasks.types.AssemblerArgument;\r
+import net.sf.antcontrib.cpptasks.types.CompilerArgument;\r
+import net.sf.antcontrib.cpptasks.types.ConditionalFileSet;\r
+import net.sf.antcontrib.cpptasks.types.DefineSet;\r
+import net.sf.antcontrib.cpptasks.types.IncludePath;\r
+import net.sf.antcontrib.cpptasks.types.LibrarySet;\r
+import net.sf.antcontrib.cpptasks.types.LinkerArgument;\r
+import net.sf.antcontrib.cpptasks.types.SystemIncludePath;\r
+import net.sf.antcontrib.cpptasks.types.SystemLibrarySet;\r
+import net.sf.antcontrib.cpptasks.userdefine.UserDefineCompiler;\r
+import net.sf.antcontrib.cpptasks.userdefine.UserDefineDef;\r
+import net.sf.antcontrib.cpptasks.VersionInfo;\r
+\r
+import org.apache.tools.ant.BuildException;\r
+import org.apache.tools.ant.Project;\r
+import org.apache.tools.ant.Task;\r
+import org.apache.tools.ant.types.Environment;\r
+\r
+/**\r
+ * Compile, link, assembler and asl compile task.\r
+ * \r
+ * <p>\r
+ * This task can compile various source languages and produce executables,\r
+ * shared libraries (aka DLL's) and static libraries. Compiler adaptors are\r
+ * currently available for several C/C++ compilers, FORTRAN, MIDL and Windows\r
+ * Resource files. Assembler adaptors are currently available for MASM and GAS.\r
+ * And aslcompiler support to ASL and IASL command.\r
+ * </p>\r
+ * \r
+ * \r
+ * <p>\r
+ * Copyright (c) 2001-2005, The Ant-Contrib project.\r
+ * </p>\r
+ * \r
+ * <p>\r
+ * Licensed under the Apache Software License 2.0,\r
+ * http://www.apache.org/licenses/LICENSE-2.0.\r
+ * </p>\r
+ * \r
+ * <p>\r
+ * For use with Apache Ant 1.5 or later. This software is not a product of the\r
+ * of the Apache Software Foundation and no endorsement is implied.\r
+ * </p>\r
+ * \r
+ * <p>\r
+ * THIS SOFTWARE IS PROVIDED 'AS-IS', See\r
+ * http://www.apache.org/licenses/LICENSE-2.0 for additional disclaimers.\r
+ * </p>\r
+ * \r
+ * To use:\r
+ * <ol>\r
+ * <li>Place cpptasks.jar into the lib directory of Ant 1.5 or later.</li>\r
+ * <li>Add <taskdef resource="cpptasks.tasks"/> and <typedef\r
+ * resource="cpptasks.types"/> to build.xml.</li>\r
+ * <li>Add <cc/>, <compiler/> <linker/> <assembler/>\r
+ * and <aslcompiler/> elements to project.</li>\r
+ * <li>Set path and environment variables to be able to run compiler from\r
+ * command line.</li>\r
+ * <li>Build project.</li>\r
+ * </ol>\r
+ * \r
+ * @author Adam Murdoch\r
+ * @author Curt Arnold\r
+ */\r
+public class CCTask extends Task {\r
+ private class SystemLibraryCollector implements FileVisitor {\r
+ private Hashtable libraries;\r
+\r
+ private Linker linker;\r
+\r
+ public SystemLibraryCollector (Linker linker, Hashtable libraries) {\r
+ this.linker = linker;\r
+ this.libraries = libraries;\r
+ }\r
+\r
+ public void visit(File basedir, String filename) {\r
+ if (linker.bid(filename) > 0) {\r
+ File libfile = new File(basedir, filename);\r
+ String key = linker.getLibraryKey(libfile);\r
+ libraries.put(key, libfile);\r
+ }\r
+ }\r
+ }\r
+\r
+ private static final ProcessorConfiguration[] EMPTY_CONFIG_ARRAY = new ProcessorConfiguration[0];\r
+\r
+ /**\r
+ * Builds a Hashtable to targets needing to be rebuilt keyed by compiler\r
+ * configuration\r
+ */\r
+ public static Hashtable getTargetsToBuildByConfiguration(Hashtable targets) {\r
+ Hashtable targetsByConfig = new Hashtable();\r
+ Enumeration targetEnum = targets.elements();\r
+ while (targetEnum.hasMoreElements()) {\r
+ TargetInfo target = (TargetInfo) targetEnum.nextElement();\r
+ if (target.getRebuild()) {\r
+ Vector targetsForSameConfig = (Vector) targetsByConfig\r
+ .get(target.getConfiguration());\r
+ if (targetsForSameConfig != null) {\r
+ targetsForSameConfig.addElement(target);\r
+ } else {\r
+ targetsForSameConfig = new Vector();\r
+ targetsForSameConfig.addElement(target);\r
+ targetsByConfig.put(target.getConfiguration(),\r
+ targetsForSameConfig);\r
+ }\r
+ }\r
+ }\r
+ return targetsByConfig;\r
+ }\r
+\r
+ /** The userdefine definitions. */\r
+ private Vector _userdefines = new Vector();\r
+ \r
+ /** The compiler definitions. */\r
+ private Vector _compilers = new Vector();\r
+\r
+ /** The output file type. */\r
+ // private LinkType _linkType = LinkType.EXECUTABLE;\r
+ /** The library sets. */\r
+ private Vector _libsets = new Vector();\r
+\r
+ /** The aslcompiler definitions. */\r
+ private Vector _aslcompiler = new Vector();\r
+\r
+ /** The assembler definitions. */\r
+ private Vector _assemblers = new Vector();\r
+\r
+ /** The linker definitions. */\r
+ private Vector _linkers = new Vector();\r
+\r
+ /** The object directory. */\r
+ private File _objDir;\r
+\r
+ /** The output file. */\r
+ private File _outfile;\r
+ \r
+ private boolean userdefine = false;\r
+ private String arch;\r
+ private String os;\r
+ private String vendor;\r
+ \r
+ /** the flag for assembler */\r
+ private boolean assembler = true;\r
+\r
+ /** the flag for aslcompiler */\r
+ private boolean aslcompiler = true;\r
+\r
+ /** The linker definitions. */\r
+ private final Vector targetPlatforms = new Vector();\r
+\r
+ /** The distributer definitions. */\r
+ private Vector distributers = new Vector();\r
+\r
+ /**\r
+ * If true, stop build on compile failure.\r
+ */\r
+ protected boolean failOnError = true;\r
+\r
+ /**\r
+ * Content that appears in <cc>and also in <compiler>are maintained by a\r
+ * captive CompilerDef instance\r
+ */\r
+ private final CompilerDef compilerDef = new CompilerDef();\r
+\r
+ /**\r
+ * Content that appears in <cc>and also in <aslcompiler>are maintained by a\r
+ * captive AslcompilerDef instance\r
+ */\r
+ private final AslcompilerDef aslcompilerDef = new AslcompilerDef();\r
+\r
+ /** The OS390 dataset to build to object to */\r
+ private String dataset;\r
+\r
+ /**\r
+ * \r
+ * Depth of dependency checking\r
+ * \r
+ * Values < 0 indicate full dependency checking Values >= 0 indicate partial\r
+ * dependency checking and for superficial compilation checks. Will throw\r
+ * BuildException before attempting link\r
+ */\r
+ private int dependencyDepth = -1;\r
+\r
+ /**\r
+ * Content that appears in <cc>and also in <assembler>are maintained by a\r
+ * captive AssemblerDef instance\r
+ */\r
+ private final AssemblerDef assemblerDef = new AssemblerDef();\r
+\r
+ /**\r
+ * Content that appears in <cc>and also in <linker>are maintained by a\r
+ * captive CompilerDef instance\r
+ */\r
+ private final LinkerDef linkerDef = new LinkerDef();\r
+\r
+ /**\r
+ * contains the subsystem, output type and\r
+ * \r
+ */\r
+ private final LinkType linkType = new LinkType();\r
+\r
+ /**\r
+ * The property name which will be set with the physical filename of the\r
+ * file that is generated by the linker\r
+ */\r
+ private String outputFileProperty;\r
+\r
+ /**\r
+ * if relentless = true, compilations should attempt to compile as many\r
+ * files as possible before throwing a BuildException\r
+ */\r
+ private boolean relentless;\r
+\r
+ public CCTask () {\r
+ }\r
+\r
+ \r
+ public void addConfiguredCommand(UserDefineDef userdefineDef) {\r
+ if (userdefineDef == null) {\r
+ throw new NullPointerException("UserDefineDef");\r
+ }\r
+ userdefineDef.setProject(getProject());\r
+ _userdefines.addElement(userdefineDef);\r
+ }\r
+ /**\r
+ * Adds a asl compiler definition or reference.\r
+ * \r
+ * @param Aslcompiler\r
+ * aslcompiler\r
+ * @throws NullPointerException\r
+ * if aslcompiler is null\r
+ */\r
+ public void addConfiguredAslcompiler(AslcompilerDef aslcompier) {\r
+ if (aslcompier == null) {\r
+ throw new NullPointerException("aslcompier");\r
+ }\r
+ aslcompier.setProject(getProject());\r
+ _aslcompiler.addElement(aslcompier);\r
+ }\r
+\r
+ /**\r
+ * Adds a asl command-line arg. Argument will be inherited by all nested\r
+ * aslcompiler elements that do not have inherit="false".\r
+ * \r
+ */\r
+ public void addConfiguredAslcompilerArg(AslcompilerArgument arg) {\r
+ aslcompilerDef.addConfiguredAslcompilerArg(arg);\r
+ }\r
+\r
+ /**\r
+ * Adds a assembler definition or reference.\r
+ * \r
+ * @param assembler\r
+ * assemblera\r
+ * @throws NullPointerException\r
+ * if assembler is null\r
+ */\r
+ public void addConfiguredAssembler(AssemblerDef assembler) {\r
+ if (assembler == null) {\r
+ throw new NullPointerException("assembler");\r
+ }\r
+ assembler.setProject(getProject());\r
+ _assemblers.addElement(assembler);\r
+ }\r
+\r
+ /**\r
+ * Adds a assembler command-line arg. Argument will be inherited by all\r
+ * nested assembler elements that do not have inherit="false".\r
+ * \r
+ */\r
+ public void addConfiguredAssemblerArg(AssemblerArgument arg) {\r
+ assemblerDef.addConfiguredAssemblerArg(arg);\r
+ }\r
+\r
+ /**\r
+ * Adds a compiler definition or reference.\r
+ * \r
+ * @param compiler\r
+ * compiler\r
+ * @throws NullPointerException\r
+ * if compiler is null\r
+ */\r
+ public void addConfiguredCompiler(CompilerDef compiler) {\r
+ if (compiler == null) {\r
+ throw new NullPointerException("compiler");\r
+ }\r
+ compiler.setProject(getProject());\r
+ _compilers.addElement(compiler);\r
+ }\r
+\r
+ /**\r
+ * Adds a compiler command-line arg. Argument will be inherited by all\r
+ * nested compiler elements that do not have inherit="false".\r
+ * \r
+ */\r
+ public void addConfiguredCompilerArg(CompilerArgument arg) {\r
+ compilerDef.addConfiguredCompilerArg(arg);\r
+ }\r
+\r
+ /**\r
+ * Adds a defineset. Will be inherited by all compiler elements that do not\r
+ * have inherit="false".\r
+ * \r
+ * @param defs\r
+ * Define set\r
+ */\r
+ public void addConfiguredDefineset(DefineSet defs) {\r
+ compilerDef.addConfiguredDefineset(defs);\r
+ }\r
+\r
+ /**\r
+ * Adds a linker definition. The first linker that is not disqualified by\r
+ * its "if" and "unless" attributes will perform the link. If no child\r
+ * linker element is active, the linker implied by the cc elements name or\r
+ * classname attribute will be used.\r
+ * \r
+ * @param linker\r
+ * linker\r
+ * @throws NullPointerException\r
+ * if linker is null\r
+ */\r
+ public void addConfiguredLinker(LinkerDef linker) {\r
+ if (linker == null) {\r
+ throw new NullPointerException("linker");\r
+ }\r
+ linker.setProject(getProject());\r
+ _linkers.addElement(linker);\r
+ }\r
+\r
+ /**\r
+ * Adds a linker command-line arg. Argument will be inherited by all nested\r
+ * linker elements that do not have inherit="false".\r
+ */\r
+ public void addConfiguredLinkerArg(LinkerArgument arg) {\r
+ linkerDef.addConfiguredLinkerArg(arg);\r
+ }\r
+\r
+ /**\r
+ * Add an environment variable to the launched process.\r
+ */\r
+ public void addEnv(Environment.Variable var) {\r
+ compilerDef.addEnv(var);\r
+ linkerDef.addEnv(var);\r
+ assemblerDef.addEnv(var);\r
+ aslcompilerDef.addEnv(var);\r
+ }\r
+\r
+ /**\r
+ * Adds a source file set.\r
+ * \r
+ * Files in these filesets will be auctioned to the available compiler\r
+ * configurations, with the default compiler implied by the cc element\r
+ * bidding last. If no compiler is interested in the file, it will be passed\r
+ * to the linker.\r
+ * \r
+ * To have a file be processed by a particular compiler configuration, add a\r
+ * fileset to the corresponding compiler element.\r
+ */\r
+ public void addFileset(ConditionalFileSet srcSet) {\r
+ compilerDef.addFileset(srcSet);\r
+ }\r
+\r
+ /**\r
+ * Adds a library set.\r
+ * \r
+ * Library sets will be inherited by all linker elements that do not have\r
+ * inherit="false".\r
+ * \r
+ * @param libset\r
+ * library set\r
+ * @throws NullPointerException\r
+ * if libset is null.\r
+ */\r
+ public void addLibset(LibrarySet libset) {\r
+ if (libset == null) {\r
+ throw new NullPointerException("libset");\r
+ }\r
+ linkerDef.addLibset(libset);\r
+ }\r
+\r
+ /**\r
+ * Adds a system library set. Timestamps and locations of system library\r
+ * sets are not used in dependency analysis.\r
+ * \r
+ * Essential libraries (such as C Runtime libraries) should not be specified\r
+ * since the task will attempt to identify the correct libraries based on\r
+ * the multithread, debug and runtime attributes.\r
+ * \r
+ * System library sets will be inherited by all linker elements that do not\r
+ * have inherit="false".\r
+ * \r
+ * @param libset\r
+ * library set\r
+ * @throws NullPointerException\r
+ * if libset is null.\r
+ */\r
+ public void addSyslibset(SystemLibrarySet libset) {\r
+ if (libset == null) {\r
+ throw new NullPointerException("libset");\r
+ }\r
+ linkerDef.addSyslibset(libset);\r
+ }\r
+\r
+ /**\r
+ * Checks all targets that are not forced to be rebuilt or are missing\r
+ * object files to be checked for modified include files\r
+ * \r
+ * @returns total number of targets to be rebuilt\r
+ * \r
+ */\r
+ protected int checkForChangedIncludeFiles(Hashtable targets) {\r
+ int potentialTargets = 0;\r
+ int definiteTargets = 0;\r
+ Enumeration targetEnum = targets.elements();\r
+ while (targetEnum.hasMoreElements()) {\r
+ TargetInfo target = (TargetInfo) targetEnum.nextElement();\r
+ if (!target.getRebuild()) {\r
+ potentialTargets++;\r
+ } else {\r
+ definiteTargets++;\r
+ }\r
+ }\r
+ //\r
+ // If there were remaining targets that\r
+ // might be out of date\r
+ //\r
+ if (potentialTargets > 0) {\r
+ log("Starting dependency analysis for "\r
+ + Integer.toString(potentialTargets) + " files.");\r
+ DependencyTable dependencyTable = new DependencyTable(_objDir);\r
+ try {\r
+ dependencyTable.load();\r
+ } catch (Exception ex) {\r
+ log("Problem reading dependencies.xml: " + ex.toString());\r
+ }\r
+ targetEnum = targets.elements();\r
+ while (targetEnum.hasMoreElements()) {\r
+ TargetInfo target = (TargetInfo) targetEnum.nextElement();\r
+ if (!target.getRebuild()) {\r
+ if (dependencyTable.needsRebuild(this, target,\r
+ dependencyDepth)) {\r
+ target.mustRebuild();\r
+ }\r
+ }\r
+ }\r
+ dependencyTable.commit(this);\r
+ }\r
+ //\r
+ // count files being rebuilt now\r
+ //\r
+ int currentTargets = 0;\r
+ targetEnum = targets.elements();\r
+ while (targetEnum.hasMoreElements()) {\r
+ TargetInfo target = (TargetInfo) targetEnum.nextElement();\r
+ if (target.getRebuild()) {\r
+ currentTargets++;\r
+ }\r
+ }\r
+ if (potentialTargets > 0) {\r
+ log(Integer.toString(potentialTargets - currentTargets\r
+ + definiteTargets)\r
+ + " files are up to date.");\r
+ log(Integer.toString(currentTargets - definiteTargets)\r
+ + " files to be recompiled from dependency analysis.");\r
+ }\r
+ log(Integer.toString(currentTargets) + " total files to be compiled.");\r
+ return currentTargets;\r
+ }\r
+\r
+ protected LinkerConfiguration collectExplicitObjectFiles(\r
+ Vector objectFiles, Vector sysObjectFiles) {\r
+ //\r
+ // find the first eligible linker\r
+ //\r
+ //\r
+ ProcessorConfiguration linkerConfig = null;\r
+ LinkerDef selectedLinkerDef = null;\r
+ Linker selectedLinker = null;\r
+ Hashtable sysLibraries = new Hashtable();\r
+ TargetDef targetPlatform = getTargetPlatform();\r
+ FileVisitor objCollector = null;\r
+ FileVisitor sysLibraryCollector = null;\r
+ for (int i = 0; i < _linkers.size(); i++) {\r
+ LinkerDef currentLinkerDef = (LinkerDef) _linkers.elementAt(i);\r
+ if (currentLinkerDef.isActive()) {\r
+ selectedLinkerDef = currentLinkerDef;\r
+ selectedLinker = currentLinkerDef.getProcessor().getLinker(\r
+ linkType);\r
+ //\r
+ // skip the linker if it doesn't know how to\r
+ // produce the specified link type\r
+ if (selectedLinker != null) {\r
+ linkerConfig = currentLinkerDef.createConfiguration(this,\r
+ linkType, linkerDef, targetPlatform);\r
+ if (linkerConfig != null) {\r
+ //\r
+ // create collectors for object files\r
+ // and system libraries\r
+ objCollector = new ObjectFileCollector(selectedLinker,\r
+ objectFiles);\r
+ sysLibraryCollector = new SystemLibraryCollector(\r
+ selectedLinker, sysLibraries);\r
+ //\r
+ // if the <linker> has embedded <fileset>'s\r
+ // (such as linker specific libraries)\r
+ // add them as object files.\r
+ //\r
+ if (currentLinkerDef.hasFileSets()) {\r
+ currentLinkerDef.visitFiles(objCollector);\r
+ }\r
+ //\r
+ // user libraries are just a specialized form\r
+ // of an object fileset\r
+ selectedLinkerDef.visitUserLibraries(selectedLinker,\r
+ objCollector);\r
+ }\r
+ break;\r
+ }\r
+ }\r
+ }\r
+ if (linkerConfig == null) {\r
+ linkerConfig = linkerDef.createConfiguration(this, linkType, null,\r
+ targetPlatform);\r
+ selectedLinker = (Linker) linkerDef.getProcessor().getLinker(\r
+ linkType);\r
+ objCollector = new ObjectFileCollector(selectedLinker, objectFiles);\r
+ sysLibraryCollector = new SystemLibraryCollector(selectedLinker,\r
+ sysLibraries);\r
+ }\r
+ //\r
+ // unless there was a <linker> element that\r
+ // explicitly did not inherit files from\r
+ // containing <cc> element\r
+ if (selectedLinkerDef == null || selectedLinkerDef.getInherit()) {\r
+ linkerDef.visitUserLibraries(selectedLinker, objCollector);\r
+ linkerDef.visitSystemLibraries(selectedLinker, sysLibraryCollector);\r
+ }\r
+ //\r
+ // if there was a <syslibset> in a nested <linker>\r
+ // evaluate it last so it takes priority over\r
+ // identically named libs from <cc> element\r
+ //\r
+ if (selectedLinkerDef != null) {\r
+ //\r
+ // add any system libraries to the hashtable\r
+ // done in reverse order so the earliest\r
+ // on the classpath takes priority\r
+ selectedLinkerDef.visitSystemLibraries(selectedLinker,\r
+ sysLibraryCollector);\r
+ }\r
+ //\r
+ // copy over any system libraries to the\r
+ // object files vector\r
+ //\r
+ Enumeration sysLibEnum = sysLibraries.elements();\r
+ while (sysLibEnum.hasMoreElements()) {\r
+ sysObjectFiles.addElement(sysLibEnum.nextElement());\r
+ }\r
+ return (LinkerConfiguration) linkerConfig;\r
+ }\r
+\r
+ /**\r
+ * Adds an include path.\r
+ * \r
+ * Include paths will be inherited by nested compiler elements that do not\r
+ * have inherit="false".\r
+ */\r
+ public IncludePath createIncludePath() {\r
+ return compilerDef.createIncludePath();\r
+ }\r
+\r
+ /**\r
+ * Specifies precompilation prototype file and exclusions. Inherited by all\r
+ * compilers that do not have inherit="false".\r
+ * \r
+ */\r
+ public PrecompileDef createPrecompile() throws BuildException {\r
+ return compilerDef.createPrecompile();\r
+ }\r
+\r
+ /**\r
+ * Adds a system include path. Locations and timestamps of files located\r
+ * using the system include paths are not used in dependency analysis.\r
+ * \r
+ * \r
+ * Standard include locations should not be specified. The compiler adapters\r
+ * should recognized the settings from the appropriate environment variables\r
+ * or configuration files.\r
+ * \r
+ * System include paths will be inherited by nested compiler elements that\r
+ * do not have inherit="false".\r
+ */\r
+ public SystemIncludePath createSysIncludePath() {\r
+ return compilerDef.createSysIncludePath();\r
+ }\r
+\r
+ /**\r
+ * Executes the task. Compiles the given files.\r
+ * \r
+ * @throws BuildException\r
+ * if someting goes wrong with the build\r
+ */\r
+ public void execute() throws BuildException {\r
+ //\r
+ // if link type allowed objdir to be defaulted\r
+ // provide it from outfile\r
+ if (_objDir == null) {\r
+ if (_outfile != null) {\r
+ _objDir = new File(_outfile.getParent());\r
+ } else {\r
+ _objDir = new File(".");\r
+ }\r
+ }\r
+\r
+ //\r
+ // if the object directory does not exist\r
+ //\r
+ if (!_objDir.exists()) {\r
+ throw new BuildException("Object directory does not exist");\r
+ }\r
+ \r
+ //\r
+ // if userdefine is true, then run all user defined command\r
+ //\r
+ if (userdefine) {\r
+ Iterator iter = _userdefines.iterator();\r
+ while( iter.hasNext()) {\r
+ UserDefineDef userdefineDef = (UserDefineDef)iter.next();\r
+ UserDefineCompiler userdefineCompiler = new UserDefineCompiler(this, userdefineDef);\r
+ userdefineCompiler.command(this, userdefineDef);\r
+ }\r
+ return ;\r
+ }\r
+ \r
+ TargetHistoryTable objHistory = new TargetHistoryTable(this, _objDir);\r
+ //\r
+ // determine the eventual linker configuration\r
+ // (may be null) and collect any explicit\r
+ // object files or libraries\r
+ Vector objectFiles = new Vector();\r
+ Vector sysObjectFiles = new Vector();\r
+ LinkerConfiguration linkerConfig = collectExplicitObjectFiles(\r
+ objectFiles, sysObjectFiles);\r
+ //\r
+ // Assembler hashtable of all files\r
+ // that we know how to compile (keyed by output file name)\r
+ //\r
+ Hashtable targets = getTargets(linkerConfig, objectFiles);\r
+ Hashtable acpiTarget = new Hashtable();\r
+ if (aslcompiler) {\r
+ acpiTarget = getAcpiTargets(linkerConfig, new Vector());\r
+ }\r
+ Hashtable assemblerTarget = new Hashtable();\r
+ if (assembler) {\r
+ assemblerTarget = getAssemblerTargets(linkerConfig, objectFiles);\r
+ }\r
+ TargetInfo linkTarget = null;\r
+ //\r
+ // if output file is not specified,\r
+ // then skip link step\r
+ //\r
+ if (_outfile != null) {\r
+ linkTarget = getLinkTarget(linkerConfig, objectFiles,\r
+ sysObjectFiles, targets, assemblerTarget);\r
+ }\r
+ //\r
+ // If specify the aslcompiler, then call asl compiler\r
+ //\r
+ if (aslcompiler) {\r
+ BuildException acpiException = null;\r
+ Hashtable targetsByConfig = getTargetsToBuildByConfiguration(acpiTarget);\r
+ Enumeration acpiTargetEnum = targetsByConfig.elements();\r
+ Vector[] targetVectors = new Vector[targetsByConfig.size()];\r
+ int index = 0;\r
+ while (acpiTargetEnum.hasMoreElements()) {\r
+ Vector targetsForConfig = (Vector) acpiTargetEnum.nextElement();\r
+ targetVectors[index++] = targetsForConfig;\r
+ }\r
+ for (int i = 0; i < targetVectors.length; i++) {\r
+ //\r
+ // get the targets for this configuration\r
+ //\r
+ Vector targetsForConfig = targetVectors[i];\r
+ //\r
+ // get the configuration from the first entry\r
+ //\r
+ AslcompilerConfiguration config = (AslcompilerConfiguration) ((TargetInfo) targetsForConfig\r
+ .elementAt(0)).getConfiguration();\r
+ //\r
+ // prepare the list of source files\r
+ //\r
+ String[] sourceFiles = new String[targetsForConfig.size()];\r
+ Enumeration targetsEnum = targetsForConfig.elements();\r
+ index = 0;\r
+ while (targetsEnum.hasMoreElements()) {\r
+ TargetInfo targetInfo = ((TargetInfo) targetsEnum\r
+ .nextElement());\r
+ sourceFiles[index++] = targetInfo.getSources()[0]\r
+ .toString();\r
+ }\r
+ try {\r
+ config.aslcompiler(this, _objDir, sourceFiles);\r
+ log(sourceFiles.length\r
+ + " total ACPI source files to be compiled.");\r
+ } catch (BuildException ex) {\r
+ if (acpiException == null) {\r
+ acpiException = ex;\r
+ }\r
+ if (!relentless)\r
+ break;\r
+ }\r
+ }\r
+ }\r
+ //\r
+ // If specify the assembler, then call assembler\r
+ //\r
+ if (assembler) {\r
+ BuildException assemblerException = null;\r
+ Hashtable targetsByConfig = getTargetsToBuildByConfiguration(assemblerTarget);\r
+ Enumeration assembleTargetEnum = targetsByConfig.elements();\r
+ Vector[] targetVectors = new Vector[targetsByConfig.size()];\r
+ int index = 0;\r
+ while (assembleTargetEnum.hasMoreElements()) {\r
+ Vector targetsForConfig = (Vector) assembleTargetEnum\r
+ .nextElement();\r
+ targetVectors[index++] = targetsForConfig;\r
+ }\r
+ for (int i = 0; i < targetVectors.length; i++) {\r
+ //\r
+ // get the targets for this configuration\r
+ //\r
+ Vector targetsForConfig = targetVectors[i];\r
+ //\r
+ // get the configuration from the first entry\r
+ //\r
+ AssemblerConfiguration config = (AssemblerConfiguration) ((TargetInfo) targetsForConfig\r
+ .elementAt(0)).getConfiguration();\r
+ //\r
+ // prepare the list of source files\r
+ //\r
+ String[] sourceFiles = new String[targetsForConfig.size()];\r
+ Enumeration targetsEnum = targetsForConfig.elements();\r
+ index = 0;\r
+ while (targetsEnum.hasMoreElements()) {\r
+ TargetInfo targetInfo = ((TargetInfo) targetsEnum\r
+ .nextElement());\r
+ sourceFiles[index++] = targetInfo.getSources()[0]\r
+ .toString();\r
+ }\r
+ try {\r
+ config.assembler(this, _objDir, sourceFiles);\r
+ log(sourceFiles.length + " total files to be assembled.");\r
+ } catch (BuildException ex) {\r
+ if (assemblerException == null) {\r
+ assemblerException = ex;\r
+ }\r
+ if (!relentless)\r
+ break;\r
+ }\r
+ }\r
+ //\r
+ // if we threw a assembler exception and\r
+ // didn't throw it at the time because\r
+ // we were relentless then\r
+ // save the history and\r
+ // throw the exception\r
+ //\r
+ if (assemblerException != null) {\r
+ if (failOnError) {\r
+ throw assemblerException;\r
+ } else {\r
+ log(assemblerException.getMessage(), Project.MSG_ERR);\r
+ return;\r
+ }\r
+ }\r
+ }\r
+\r
+ //\r
+ // mark targets that don't have a history record or\r
+ // whose source last modification time is not\r
+ // the same as the history to be rebuilt\r
+ //\r
+ objHistory.markForRebuild(targets);\r
+ CCTaskProgressMonitor monitor = new CCTaskProgressMonitor(objHistory);\r
+ //\r
+ // check for changed include files\r
+ //\r
+ int rebuildCount = checkForChangedIncludeFiles(targets);\r
+ if (rebuildCount > 0) {\r
+ BuildException compileException = null;\r
+ //\r
+ // compile all targets with getRebuild() == true\r
+ //\r
+ Hashtable targetsByConfig = getTargetsToBuildByConfiguration(targets);\r
+ //\r
+ // build array containing Vectors with precompiled generation\r
+ // steps going first\r
+ //\r
+ Vector[] targetVectors = new Vector[targetsByConfig.size()];\r
+ int index = 0;\r
+ Enumeration targetVectorEnum = targetsByConfig.elements();\r
+ while (targetVectorEnum.hasMoreElements()) {\r
+ Vector targetsForConfig = (Vector) targetVectorEnum\r
+ .nextElement();\r
+ //\r
+ // get the configuration from the first entry\r
+ //\r
+ CompilerConfiguration config = (CompilerConfiguration) ((TargetInfo) targetsForConfig\r
+ .elementAt(0)).getConfiguration();\r
+ if (config.isPrecompileGeneration()) {\r
+ targetVectors[index++] = targetsForConfig;\r
+ }\r
+ }\r
+ targetVectorEnum = targetsByConfig.elements();\r
+ while (targetVectorEnum.hasMoreElements()) {\r
+ Vector targetsForConfig = (Vector) targetVectorEnum\r
+ .nextElement();\r
+ for (int i = 0; i < targetVectors.length; i++) {\r
+ if (targetVectors[i] == targetsForConfig) {\r
+ break;\r
+ }\r
+ if (targetVectors[i] == null) {\r
+ targetVectors[i] = targetsForConfig;\r
+ break;\r
+ }\r
+ }\r
+ }\r
+ for (int i = 0; i < targetVectors.length; i++) {\r
+ //\r
+ // get the targets for this configuration\r
+ //\r
+ Vector targetsForConfig = targetVectors[i];\r
+ //\r
+ // get the configuration from the first entry\r
+ //\r
+ CompilerConfiguration config = (CompilerConfiguration) ((TargetInfo) targetsForConfig\r
+ .elementAt(0)).getConfiguration();\r
+ //\r
+ // prepare the list of source files\r
+ //\r
+ String[] sourceFiles = new String[targetsForConfig.size()];\r
+ Enumeration targetsEnum = targetsForConfig.elements();\r
+ index = 0;\r
+ while (targetsEnum.hasMoreElements()) {\r
+ TargetInfo targetInfo = ((TargetInfo) targetsEnum\r
+ .nextElement());\r
+ sourceFiles[index++] = targetInfo.getSources()[0]\r
+ .toString();\r
+ }\r
+ try {\r
+ config.compile(this, _objDir, sourceFiles, relentless,\r
+ monitor);\r
+ } catch (BuildException ex) {\r
+ if (compileException == null) {\r
+ compileException = ex;\r
+ }\r
+ if (!relentless)\r
+ break;\r
+ }\r
+ }\r
+ //\r
+ // save the details of the object file compilation\r
+ // settings to disk for dependency analysis\r
+ //\r
+ try {\r
+ objHistory.commit();\r
+ } catch (IOException ex) {\r
+ this.log("Error writing history.xml: " + ex.toString());\r
+ }\r
+ //\r
+ // if we threw a compile exception and\r
+ // didn't throw it at the time because\r
+ // we were relentless then\r
+ // save the history and\r
+ // throw the exception\r
+ //\r
+ if (compileException != null) {\r
+ if (failOnError) {\r
+ throw compileException;\r
+ } else {\r
+ log(compileException.getMessage(), Project.MSG_ERR);\r
+ return;\r
+ }\r
+ }\r
+ }\r
+ //\r
+ // if the dependency tree was not fully\r
+ // evaluated, then throw an exception\r
+ // since we really didn't do what we\r
+ // should have done\r
+ //\r
+ //\r
+ if (dependencyDepth >= 0) {\r
+ throw new BuildException(\r
+ "All files at depth "\r
+ + Integer.toString(dependencyDepth)\r
+ + " from changes successfully compiled.\n"\r
+ + "Remove or change dependencyDepth to -1 to perform full compilation.");\r
+ }\r
+ //\r
+ // if no link target then\r
+ // commit the history for the object files\r
+ // and leave the task\r
+ if (linkTarget != null) {\r
+ //\r
+ // get the history for the link target (may be the same\r
+ // as the object history)\r
+ TargetHistoryTable linkHistory = getLinkHistory(objHistory);\r
+ //\r
+ // see if it needs to be rebuilt\r
+ //\r
+ linkHistory.markForRebuild(linkTarget);\r
+ //\r
+ // if it needs to be rebuilt, rebuild it\r
+ //\r
+ File output = linkTarget.getOutput();\r
+ if (linkTarget.getRebuild()) {\r
+ log("Starting link");\r
+ LinkerConfiguration linkConfig = (LinkerConfiguration) linkTarget\r
+ .getConfiguration();\r
+ if (failOnError) {\r
+ linkConfig.link(this, linkTarget);\r
+ } else {\r
+ try {\r
+ linkConfig.link(this, linkTarget);\r
+ } catch (BuildException ex) {\r
+ log(ex.getMessage(), Project.MSG_ERR);\r
+ return;\r
+ }\r
+ }\r
+ if (outputFileProperty != null)\r
+ getProject().setProperty(outputFileProperty,\r
+ output.getAbsolutePath());\r
+ linkHistory.update(linkTarget);\r
+ try {\r
+ linkHistory.commit();\r
+ } catch (IOException ex) {\r
+ log("Error writing link history.xml: " + ex.toString());\r
+ }\r
+ } else {\r
+ if (outputFileProperty != null)\r
+ getProject().setProperty(outputFileProperty,\r
+ output.getAbsolutePath());\r
+ }\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Gets the dataset.\r
+ * \r
+ * @return Returns a String\r
+ */\r
+ public String getDataset() {\r
+ return dataset;\r
+ }\r
+\r
+ protected TargetHistoryTable getLinkHistory(TargetHistoryTable objHistory) {\r
+ File outputFileDir = new File(_outfile.getParent());\r
+ //\r
+ // if the output file is being produced in the link\r
+ // directory, then we can use the same history file\r
+ //\r
+ if (_objDir.equals(outputFileDir)) {\r
+ return objHistory;\r
+ }\r
+ return new TargetHistoryTable(this, outputFileDir);\r
+ }\r
+\r
+ protected TargetInfo getLinkTarget(LinkerConfiguration linkerConfig,\r
+ Vector objectFiles, Vector sysObjectFiles,\r
+ Hashtable compileTargets, Hashtable assemblerTargets) {\r
+ //\r
+ // walk the compile phase targets and\r
+ // add those sources that have already been\r
+ // assigned to the linker or\r
+ // our output files the linker knows how to consume\r
+ // files the linker knows how to consume\r
+ //\r
+ Enumeration compileTargetsEnum = compileTargets.elements();\r
+ while (compileTargetsEnum.hasMoreElements()) {\r
+ TargetInfo compileTarget = (TargetInfo) compileTargetsEnum\r
+ .nextElement();\r
+ //\r
+ // output of compile tasks\r
+ //\r
+ int bid = linkerConfig.bid(compileTarget.getOutput().toString());\r
+ if (bid > 0) {\r
+ objectFiles.addElement(compileTarget.getOutput());\r
+ }\r
+ }\r
+ //\r
+ // walk the assembler phase targets and\r
+ // add those sources that have already been\r
+ // assigned to the linker or\r
+ // our output files the linker knows how to consume\r
+ // files the linker knows how to consume\r
+ //\r
+ Enumeration assembleTargetsEnum = assemblerTargets.elements();\r
+ while (assembleTargetsEnum.hasMoreElements()) {\r
+ TargetInfo assemblerTarget = (TargetInfo) assembleTargetsEnum\r
+ .nextElement();\r
+ //\r
+ // output of assemble tasks\r
+ //\r
+ int bid = linkerConfig.bid(assemblerTarget.getOutput().toString());\r
+ if (bid > 0) {\r
+ objectFiles.addElement(assemblerTarget.getOutput());\r
+ }\r
+ }\r
+ File[] objectFileArray = new File[objectFiles.size()];\r
+ objectFiles.copyInto(objectFileArray);\r
+ File[] sysObjectFileArray = new File[sysObjectFiles.size()];\r
+ sysObjectFiles.copyInto(sysObjectFileArray);\r
+ String baseName = _outfile.getName();\r
+ String fullName = linkerConfig.getOutputFileName(baseName);\r
+ File outputFile = new File(_outfile.getParent(), fullName);\r
+ return new TargetInfo(linkerConfig, objectFileArray,\r
+ sysObjectFileArray, outputFile, linkerConfig\r
+ .getRebuild());\r
+ }\r
+\r
+ public File getObjdir() {\r
+ return _objDir;\r
+ }\r
+\r
+ public File getOutfile() {\r
+ return _outfile;\r
+ }\r
+\r
+ public TargetDef getTargetPlatform() {\r
+ return null;\r
+ }\r
+\r
+ /**\r
+ * This method collects a Hashtable, keyed by output file name, of\r
+ * TargetInfo's for every source file that is specified in the filesets of\r
+ * the <aslcompiler> elements. The TargetInfo's contain the appropriate ACPI\r
+ * configurations for their possible acpi\r
+ * \r
+ */\r
+ private Hashtable getAcpiTargets(LinkerConfiguration linkerConfig,\r
+ Vector objectFiles) {\r
+ Hashtable targets = new Hashtable(1000);\r
+ TargetDef targetPlatform = getTargetPlatform();\r
+ Vector biddingProcessors = new Vector(_aslcompiler.size());\r
+ for (int i = 0; i < _aslcompiler.size(); i++) {\r
+ AslcompilerDef currentAslDef = (AslcompilerDef) _aslcompiler\r
+ .elementAt(i);\r
+ if (currentAslDef.isActive()) {\r
+ ProcessorConfiguration config = currentAslDef\r
+ .createConfiguration(this, linkType,\r
+ aslcompilerDef, targetPlatform);\r
+ //\r
+ // if the aslcompiler has a fileset\r
+ // then allow it to add its files to\r
+ // the set of potential targets\r
+ //\r
+ ProcessorConfiguration[] localConfigs = new ProcessorConfiguration[] { config };\r
+ if (currentAslDef.hasFileSets()) {\r
+ TargetMatcher matcher = new TargetMatcher(this, _objDir,\r
+ localConfigs, linkerConfig, objectFiles,\r
+ targets);\r
+ currentAslDef.visitFiles(matcher);\r
+ }\r
+ biddingProcessors.addElement(config);\r
+ }\r
+ }\r
+ //\r
+ // add fallback compiler at the end\r
+ //\r
+ ProcessorConfiguration config = aslcompilerDef.createConfiguration(\r
+ this, linkType, null, targetPlatform);\r
+ biddingProcessors.addElement(config);\r
+ ProcessorConfiguration[] bidders = new ProcessorConfiguration[biddingProcessors\r
+ .size()];\r
+ biddingProcessors.copyInto(bidders);\r
+ TargetMatcher matcher = new TargetMatcher(this, _objDir, bidders,\r
+ linkerConfig, objectFiles, targets);\r
+ aslcompilerDef.visitFiles(matcher);\r
+ return targets;\r
+ }\r
+\r
+ /**\r
+ * This method collects a Hashtable, keyed by output file name, of\r
+ * TargetInfo's for every source file that is specified in the filesets of\r
+ * the <assembler> elements. The TargetInfo's contain the appropriate\r
+ * assembler configurations for their possible assembly\r
+ * \r
+ */\r
+ private Hashtable getAssemblerTargets(LinkerConfiguration linkerConfig,\r
+ Vector objectFiles) {\r
+ Hashtable targets = new Hashtable(1000);\r
+ TargetDef targetPlatform = getTargetPlatform();\r
+ Vector biddingProcessors = new Vector(_assemblers.size());\r
+ for (int i = 0; i < _assemblers.size(); i++) {\r
+ AssemblerDef currentAssemblerDef = (AssemblerDef) _assemblers\r
+ .elementAt(i);\r
+ if (currentAssemblerDef.isActive()) {\r
+ ProcessorConfiguration config = currentAssemblerDef\r
+ .createConfiguration(this, linkType,\r
+ assemblerDef, targetPlatform);\r
+ //\r
+ // if the assembler has a fileset\r
+ // then allow it to add its files to\r
+ // the set of potential targets\r
+ //\r
+ ProcessorConfiguration[] localConfigs = new ProcessorConfiguration[] { config };\r
+ if (currentAssemblerDef.hasFileSets()) {\r
+ TargetMatcher matcher = new TargetMatcher(this, _objDir,\r
+ localConfigs, linkerConfig, objectFiles,\r
+ targets);\r
+ currentAssemblerDef.visitFiles(matcher);\r
+ }\r
+ biddingProcessors.addElement(config);\r
+ }\r
+ }\r
+ //\r
+ // add fallback assembler at the end\r
+ //\r
+ ProcessorConfiguration config = assemblerDef.createConfiguration(this,\r
+ linkType, null, targetPlatform);\r
+ biddingProcessors.addElement(config);\r
+ ProcessorConfiguration[] bidders = new ProcessorConfiguration[biddingProcessors\r
+ .size()];\r
+ biddingProcessors.copyInto(bidders);\r
+ TargetMatcher matcher = new TargetMatcher(this, _objDir, bidders,\r
+ linkerConfig, objectFiles, targets);\r
+ assemblerDef.visitFiles(matcher);\r
+ return targets;\r
+ }\r
+\r
+ /**\r
+ * This method collects a Hashtable, keyed by output file name, of\r
+ * TargetInfo's for every source file that is specified in the filesets of\r
+ * the <cc>and nested <compiler>elements. The TargetInfo's contain the\r
+ * appropriate compiler configurations for their possible compilation\r
+ * \r
+ */\r
+ private Hashtable getTargets(LinkerConfiguration linkerConfig,\r
+ Vector objectFiles) {\r
+ Hashtable targets = new Hashtable(1000);\r
+ TargetDef targetPlatform = getTargetPlatform();\r
+ //\r
+ // find active (specialized) compilers\r
+ //\r
+ Vector biddingProcessors = new Vector(_compilers.size());\r
+ for (int i = 0; i < _compilers.size(); i++) {\r
+ CompilerDef currentCompilerDef = (CompilerDef) _compilers\r
+ .elementAt(i);\r
+ if (currentCompilerDef.isActive()) {\r
+ ProcessorConfiguration config = currentCompilerDef\r
+ .createConfiguration(this, linkType,\r
+ compilerDef, targetPlatform);\r
+ //\r
+ // see if this processor had a precompile child element\r
+ //\r
+ PrecompileDef precompileDef = currentCompilerDef\r
+ .getActivePrecompile(compilerDef);\r
+ ProcessorConfiguration[] localConfigs = new ProcessorConfiguration[] { config };\r
+ //\r
+ // if it does then\r
+ //\r
+ if (precompileDef != null) {\r
+ File prototype = precompileDef.getPrototype();\r
+ //\r
+ // will throw exceptions if prototype doesn't exist, etc\r
+ //\r
+ if (!prototype.exists()) {\r
+ throw new BuildException("prototype ("\r
+ + prototype.toString()\r
+ + ") does not exist.");\r
+ }\r
+ if (prototype.isDirectory()) {\r
+ throw new BuildException("prototype ("\r
+ + prototype.toString()\r
+ + ") is a directory.");\r
+ }\r
+ String[] exceptFiles = precompileDef.getExceptFiles();\r
+ //\r
+ // create a precompile building and precompile using\r
+ // variants of the configuration\r
+ // or return null if compiler doesn't support\r
+ // precompilation\r
+ CompilerConfiguration[] configs = ((CompilerConfiguration) config)\r
+ .createPrecompileConfigurations(prototype,\r
+ exceptFiles);\r
+ if (configs != null && configs.length == 2) {\r
+ //\r
+ // visit the precompiled file to add it into the\r
+ // targets list (just like any other file if\r
+ // compiler doesn't support precompilation)\r
+ TargetMatcher matcher = new TargetMatcher(\r
+ this,\r
+ _objDir,\r
+ new ProcessorConfiguration[] { configs[0] },\r
+ linkerConfig, objectFiles, targets);\r
+ matcher.visit(new File(prototype.getParent()),\r
+ prototype.getName());\r
+ //\r
+ // only the configuration that uses the\r
+ // precompiled header gets added to the bidding list\r
+ biddingProcessors.addElement(configs[1]);\r
+ localConfigs = new ProcessorConfiguration[2];\r
+ localConfigs[0] = configs[1];\r
+ localConfigs[1] = config;\r
+ }\r
+ }\r
+ //\r
+ // if the compiler has a fileset\r
+ // then allow it to add its files\r
+ // to the set of potential targets\r
+ if (currentCompilerDef.hasFileSets()) {\r
+ TargetMatcher matcher = new TargetMatcher(this, _objDir,\r
+ localConfigs, linkerConfig, objectFiles,\r
+ targets);\r
+ currentCompilerDef.visitFiles(matcher);\r
+ }\r
+ biddingProcessors.addElement(config);\r
+ }\r
+ }\r
+ //\r
+ // add fallback compiler at the end\r
+ //\r
+ ProcessorConfiguration config = compilerDef.createConfiguration(this,\r
+ linkType, null, targetPlatform);\r
+ biddingProcessors.addElement(config);\r
+ ProcessorConfiguration[] bidders = new ProcessorConfiguration[biddingProcessors\r
+ .size()];\r
+ biddingProcessors.copyInto(bidders);\r
+ //\r
+ // bid out the <fileset>'s in the cctask\r
+ //\r
+ TargetMatcher matcher = new TargetMatcher(this, _objDir, bidders,\r
+ linkerConfig, objectFiles, targets);\r
+ compilerDef.visitFiles(matcher);\r
+ return targets;\r
+ }\r
+\r
+ /**\r
+ * Sets the default compiler adapter. Use the "name" attribute when the\r
+ * compiler is a supported compiler.\r
+ * \r
+ * @param classname\r
+ * fully qualified classname which implements CompilerAdapter\r
+ */\r
+ public void setClassname(String classname) {\r
+ compilerDef.setClassname(classname);\r
+ linkerDef.setClassname(classname);\r
+ assemblerDef.setClassname(classname);\r
+ aslcompilerDef.setClassname(classname);\r
+ }\r
+\r
+ /**\r
+ * Sets the dataset for OS/390 builds.\r
+ * \r
+ * @param dataset\r
+ * The dataset to set\r
+ */\r
+ public void setDataset(String dataset) {\r
+ this.dataset = dataset;\r
+ }\r
+\r
+ /**\r
+ * Enables or disables generation of debug info.\r
+ */\r
+ public void setDebug(boolean debug) {\r
+ compilerDef.setDebug(debug);\r
+ linkerDef.setDebug(debug);\r
+ assemblerDef.setDebug(debug);\r
+ aslcompilerDef.setDebug(debug);\r
+ }\r
+\r
+ /**\r
+ * Deprecated.\r
+ * \r
+ * Controls the depth of the dependency evaluation. Used to do a quick check\r
+ * of changes before a full build.\r
+ * \r
+ * Any negative value which will perform full dependency checking. Positive\r
+ * values will truncate dependency checking. A value of 0 will cause only\r
+ * those files that changed to be recompiled, a value of 1 which cause files\r
+ * that changed or that explicitly include a file that changed to be\r
+ * recompiled.\r
+ * \r
+ * Any non-negative value will cause a BuildException to be thrown before\r
+ * attempting a link or completing the task.\r
+ * \r
+ */\r
+ public void setDependencyDepth(int depth) {\r
+ dependencyDepth = depth;\r
+ }\r
+\r
+ /**\r
+ * Enables generation of exception handling code\r
+ */\r
+ public void setExceptions(boolean exceptions) {\r
+ compilerDef.setExceptions(exceptions);\r
+ }\r
+\r
+ /**\r
+ * Enables run-time type information.\r
+ */\r
+ public void setRtti(boolean rtti) {\r
+ compilerDef.setRtti(rtti);\r
+ }\r
+\r
+ // public LinkType getLinkType() {\r
+ // return linkType;\r
+ // }\r
+ /**\r
+ * Enables or disables incremental linking.\r
+ * \r
+ * @param incremental\r
+ * new state\r
+ */\r
+ public void setIncremental(boolean incremental) {\r
+ linkerDef.setIncremental(incremental);\r
+ }\r
+\r
+ /**\r
+ * Set use of libtool.\r
+ * \r
+ * If set to true, the "libtool " will be prepended to the command line for\r
+ * compatible processors\r
+ * \r
+ * @param libtool\r
+ * If true, use libtool.\r
+ */\r
+ public void setLibtool(boolean libtool) {\r
+ compilerDef.setLibtool(libtool);\r
+ linkerDef.setLibtool(libtool);\r
+ assemblerDef.setLibtool(libtool);\r
+ aslcompilerDef.setLibtool(libtool);\r
+ }\r
+\r
+ /**\r
+ * Sets the output file type. Supported values "executable", "shared", and\r
+ * "static". Deprecated, specify outtype instead.\r
+ * \r
+ * @deprecated\r
+ */\r
+ public void setLink(OutputTypeEnum outputType) {\r
+ linkType.setOutputType(outputType);\r
+ }\r
+\r
+ /**\r
+ * Enables or disables generation of multithreaded code\r
+ * \r
+ * @param multi\r
+ * If true, generated code may be multithreaded.\r
+ */\r
+ public void setMultithreaded(boolean multi) {\r
+ compilerDef.setMultithreaded(multi);\r
+ }\r
+\r
+ //\r
+ // keep near duplicate comment at CompilerDef.setName in sync\r
+ //\r
+ /**\r
+ * Sets type of the default compiler and linker.\r
+ * \r
+ * <table width="100%" border="1"> <thead>Supported compilers </thead>\r
+ * <tr>\r
+ * <td>gcc (default)</td>\r
+ * <td>GCC C++ compiler</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>g++</td>\r
+ * <td>GCC C++ compiler</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>c++</td>\r
+ * <td>GCC C++ compiler</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>g77</td>\r
+ * <td>GNU FORTRAN compiler</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>msvc</td>\r
+ * <td>Microsoft Visual C++</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>bcc</td>\r
+ * <td>Borland C++ Compiler</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>msrc</td>\r
+ * <td>Microsoft Resource Compiler</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>brc</td>\r
+ * <td>Borland Resource Compiler</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>df</td>\r
+ * <td>Compaq Visual Fortran Compiler</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>midl</td>\r
+ * <td>Microsoft MIDL Compiler</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>icl</td>\r
+ * <td>Intel C++ compiler for Windows (IA-32)</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>ecl</td>\r
+ * <td>Intel C++ compiler for Windows (IA-64)</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>icc</td>\r
+ * <td>Intel C++ compiler for Linux (IA-32)</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>ecc</td>\r
+ * <td>Intel C++ compiler for Linux (IA-64)</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>CC</td>\r
+ * <td>Sun ONE C++ compiler</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>aCC</td>\r
+ * <td>HP aC++ C++ Compiler</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>os390</td>\r
+ * <td>OS390 C Compiler</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>os400</td>\r
+ * <td>Icc Compiler</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>sunc89</td>\r
+ * <td>Sun C89 C Compiler</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>xlC</td>\r
+ * <td>VisualAge C Compiler</td>\r
+ * </tr>\r
+ * </table>\r
+ * \r
+ */\r
+ public void setName(CompilerEnum name) {\r
+ compilerDef.setName(name);\r
+ Processor compiler = compilerDef.getProcessor();\r
+ Linker linker = compiler.getLinker(linkType);\r
+ linkerDef.setProcessor(linker);\r
+ }\r
+\r
+ /**\r
+ * Do not propagate old environment when new environment variables are\r
+ * specified.\r
+ */\r
+ public void setNewenvironment(boolean newenv) {\r
+ compilerDef.setNewenvironment(newenv);\r
+ linkerDef.setNewenvironment(newenv);\r
+ assemblerDef.setNewenvironment(newenv);\r
+ aslcompilerDef.setNewenvironment(newenv);\r
+ }\r
+\r
+ /**\r
+ * Sets the destination directory for object files.\r
+ * \r
+ * Generally this should be a property expression that evaluates to distinct\r
+ * debug and release object file directories.\r
+ * \r
+ * @param dir\r
+ * object directory\r
+ */\r
+ public void setObjdir(File dir) {\r
+ if (dir == null) {\r
+ throw new NullPointerException("dir");\r
+ }\r
+ _objDir = dir;\r
+ }\r
+\r
+ /**\r
+ * Sets the output file name. If not specified, the task will only compile\r
+ * files and not attempt to link. If an extension is not specified, the task\r
+ * may use a system appropriate extension and prefix, for example,\r
+ * outfile="example" may result in "libexample.so" being created.\r
+ * \r
+ * @param outfile\r
+ * output file name\r
+ */\r
+ public void setOutfile(File outfile) {\r
+ //\r
+ // if file name was empty, skip link step\r
+ //\r
+ if (outfile == null || outfile.toString().length() > 0) {\r
+ _outfile = outfile;\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Specifies the name of a property to set with the physical filename that\r
+ * is produced by the linker\r
+ */\r
+ public void setOutputFileProperty(String outputFileProperty) {\r
+ this.outputFileProperty = outputFileProperty;\r
+ }\r
+\r
+ /**\r
+ * Sets the output file type. Supported values "executable", "shared", and\r
+ * "static".\r
+ */\r
+ public void setOuttype(OutputTypeEnum outputType) {\r
+ linkType.setOutputType(outputType);\r
+ }\r
+\r
+ /**\r
+ * Sets the project.\r
+ */\r
+ public void setProject(Project project) {\r
+ super.setProject(project);\r
+ compilerDef.setProject(project);\r
+ linkerDef.setProject(project);\r
+ assemblerDef.setProject(project);\r
+ aslcompilerDef.setProject(project);\r
+ }\r
+\r
+ /**\r
+ * If set to true, all files will be rebuilt.\r
+ * \r
+ * @paran rebuildAll If true, all files will be rebuilt. If false, up to\r
+ * date files will not be rebuilt.\r
+ */\r
+ public void setRebuild(boolean rebuildAll) {\r
+ compilerDef.setRebuild(rebuildAll);\r
+ linkerDef.setRebuild(rebuildAll);\r
+ assemblerDef.setRebuild(rebuildAll);\r
+ aslcompilerDef.setRebuild(rebuildAll);\r
+ }\r
+\r
+ /**\r
+ * If set to true, compilation errors will not stop the task until all files\r
+ * have been attempted.\r
+ * \r
+ * @param relentless\r
+ * If true, don't stop on the first compilation error\r
+ * \r
+ */\r
+ public void setRelentless(boolean relentless) {\r
+ this.relentless = relentless;\r
+ }\r
+\r
+ /**\r
+ * Sets the type of runtime library, possible values "dynamic", "static".\r
+ */\r
+ public void setRuntime(RuntimeType rtlType) {\r
+ linkType.setStaticRuntime((rtlType.getIndex() == 1));\r
+ }\r
+\r
+ /**\r
+ * Sets the nature of the subsystem under which that the program will\r
+ * execute.\r
+ * \r
+ * <table width="100%" border="1"> <thead>Supported subsystems </thead>\r
+ * <tr>\r
+ * <td>gui</td>\r
+ * <td>Graphical User Interface</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>console</td>\r
+ * <td>Command Line Console</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>other</td>\r
+ * <td>Other</td>\r
+ * </tr>\r
+ * </table>\r
+ * \r
+ * @param subsystem\r
+ * subsystem\r
+ * @throws NullPointerException\r
+ * if subsystem is null\r
+ */\r
+ public void setSubsystem(SubsystemEnum subsystem) {\r
+ if (subsystem == null) {\r
+ throw new NullPointerException("subsystem");\r
+ }\r
+ linkType.setSubsystem(subsystem);\r
+ }\r
+\r
+ /**\r
+ * Enumerated attribute with the values "none", "severe", "default",\r
+ * "production", "diagnostic", and "failtask".\r
+ */\r
+ public void setWarnings(CompilerDef.WarningLevel level) {\r
+ compilerDef.setWarnings(level);\r
+ }\r
+\r
+ /**\r
+ * Indicates whether the build will continue even if there are compilation\r
+ * errors; defaults to true.\r
+ * \r
+ * @param fail\r
+ * if true halt the build on failure\r
+ */\r
+ public void setFailonerror(boolean fail) {\r
+ failOnError = fail;\r
+ }\r
+\r
+ /**\r
+ * Gets the failonerror flag.\r
+ * \r
+ * @return the failonerror flag\r
+ */\r
+ public boolean getFailonerror() {\r
+ return failOnError;\r
+ }\r
+\r
+ /**\r
+ * Adds descriptive version information to be included in the generated\r
+ * file. The first active version info block will be used. (Non-functional\r
+ * prototype)\r
+ */\r
+ public void addConfiguredVersioninfo(VersionInfo info) {\r
+ linkerDef.addConfiguredVersioninfo(info);\r
+ }\r
+\r
+ /**\r
+ * Adds a target definition or reference (Non-functional prototype).\r
+ * \r
+ * @param target\r
+ * target\r
+ * @throws NullPointerException\r
+ * if compiler is null\r
+ */\r
+ public void addConfiguredTarget(TargetDef target) {\r
+ if (target == null) {\r
+ throw new NullPointerException("target");\r
+ }\r
+ target.setProject(getProject());\r
+ targetPlatforms.addElement(target);\r
+ }\r
+\r
+ /**\r
+ * Adds a distributer definition or reference (Non-functional prototype).\r
+ * \r
+ * @param distributer\r
+ * distributer\r
+ * @throws NullPointerException\r
+ * if compiler is null\r
+ */\r
+ public void addConfiguredDistributer(DistributerDef distributer) {\r
+ if (distributer == null) {\r
+ throw new NullPointerException("distributer");\r
+ }\r
+ distributer.setProject(getProject());\r
+ distributers.addElement(distributer);\r
+ }\r
+\r
+ /**\r
+ * Sets optimization.\r
+ * @param optimization\r
+ */\r
+ public void setOptimize(OptimizationEnum optimization) {\r
+ compilerDef.setOptimize(optimization);\r
+ }\r
+\r
+ public boolean isAssembler() {\r
+ return assembler;\r
+ }\r
+\r
+ public void setAssembler(boolean assembler) {\r
+ this.assembler = assembler;\r
+ }\r
+\r
+ public boolean isAslcompiler() {\r
+ return aslcompiler;\r
+ }\r
+\r
+ public void setAslcompiler(boolean aslcompiler) {\r
+ this.aslcompiler = aslcompiler;\r
+ }\r
+\r
+ public boolean isUserdefine() {\r
+ return userdefine;\r
+ }\r
+\r
+ public void setUserdefine(boolean userdefine) {\r
+ this.userdefine = userdefine;\r
+ }\r
+\r
+ public String getArch() {\r
+ return arch;\r
+ }\r
+\r
+ public void setArch(String arch) {\r
+ this.arch = arch;\r
+ }\r
+\r
+ public String getOs() {\r
+ return os;\r
+ }\r
+\r
+ public void setOs(String os) {\r
+ this.os = os;\r
+ }\r
+\r
+ public String getVendor() {\r
+ return vendor;\r
+ }\r
+\r
+ public void setVendor(String vendor) {\r
+ this.vendor = vendor;\r
+ }\r
+ \r
+ \r
+}\r