]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Java/Source/Cpptasks/net/sf/antcontrib/cpptasks/CompilerDef.java
Retiring the ANT/JAVA build and removing the older EDK II packages that required...
[mirror_edk2.git] / Tools / Java / Source / Cpptasks / net / sf / antcontrib / cpptasks / CompilerDef.java
diff --git a/Tools/Java/Source/Cpptasks/net/sf/antcontrib/cpptasks/CompilerDef.java b/Tools/Java/Source/Cpptasks/net/sf/antcontrib/cpptasks/CompilerDef.java
deleted file mode 100644 (file)
index 0a92a51..0000000
+++ /dev/null
@@ -1,556 +0,0 @@
-/*\r
- * \r
- * Copyright 2001-2004 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
-import java.io.BufferedReader;\r
-import java.io.File;\r
-import java.io.FileReader;\r
-import java.util.Enumeration;\r
-import java.util.Vector;\r
-\r
-import net.sf.antcontrib.cpptasks.compiler.CommandLineCompiler;\r
-import net.sf.antcontrib.cpptasks.compiler.Compiler;\r
-import net.sf.antcontrib.cpptasks.compiler.Processor;\r
-import net.sf.antcontrib.cpptasks.gcc.GccCCompiler;\r
-import net.sf.antcontrib.cpptasks.types.CompilerArgument;\r
-import net.sf.antcontrib.cpptasks.types.ConditionalPath;\r
-import net.sf.antcontrib.cpptasks.types.DefineSet;\r
-import net.sf.antcontrib.cpptasks.types.IncludePath;\r
-import net.sf.antcontrib.cpptasks.types.SystemIncludePath;\r
-import net.sf.antcontrib.cpptasks.types.UndefineArgument;\r
-\r
-import org.apache.tools.ant.BuildException;\r
-import org.apache.tools.ant.types.EnumeratedAttribute;\r
-import org.apache.tools.ant.*;\r
-/**\r
- * A compiler definition. compiler elements may be placed either as children of\r
- * a cc element or the project element. A compiler element with an id attribute\r
- * may be referenced from compiler elements with refid or extends attributes.\r
- * \r
- * @author Adam Murdoch\r
- */\r
-public final class CompilerDef extends ProcessorDef {\r
-    /**\r
-     * Enumerated attribute with the values "none", "severe", "default",\r
-     * "production", "diagnostic", and "failtask".\r
-     */\r
-    public static class WarningLevel extends EnumeratedAttribute {\r
-        public String[] getValues() {\r
-            return new String[]{"none", "severe", "default", "production",\r
-                    "diagnostic", "aserror"};\r
-        }\r
-    }\r
-    /** The source file sets. */\r
-    private final Vector defineSets = new Vector();\r
-    private Boolean exceptions;\r
-    private Boolean rtti;\r
-    private final Vector includePaths = new Vector();\r
-    private Boolean multithreaded;\r
-    private final Vector precompileDefs = new Vector();\r
-    private final Vector sysIncludePaths = new Vector();\r
-    private OptimizationEnum optimization;\r
-    private int warnings = -1;\r
-    private Boolean defaultflag = new Boolean(true);\r
-    public CompilerDef() {\r
-    }\r
-    /**\r
-     * Adds a compiler command-line arg.\r
-     */\r
-    public void addConfiguredCompilerArg(CompilerArgument arg) {\r
-        if (isReference()) {\r
-            throw noChildrenAllowed();\r
-        }\r
-        addConfiguredProcessorArg(arg);\r
-    }\r
-    /**\r
-     * Adds a compiler command-line arg.\r
-     */\r
-    public void addConfiguredCompilerParam(CompilerParam param) {\r
-        if (isReference()) {\r
-            throw noChildrenAllowed();\r
-        }\r
-        addConfiguredProcessorParam(param);\r
-    }\r
-    /**\r
-     * Adds a defineset.\r
-     */\r
-    public void addConfiguredDefineset(DefineSet defs) {\r
-        if (defs == null) {\r
-            throw new NullPointerException("defs");\r
-        }\r
-        if (isReference()) {\r
-            throw noChildrenAllowed();\r
-        }\r
-        defineSets.addElement(defs);\r
-    }\r
-    /**\r
-     * Creates an include path.\r
-     */\r
-    public IncludePath createIncludePath() {\r
-        Project p = getProject();\r
-        if (p == null) {\r
-            throw new java.lang.IllegalStateException("project must be set");\r
-        }\r
-        if (isReference()) {\r
-            throw noChildrenAllowed();\r
-        }\r
-        IncludePath path = new IncludePath(p);\r
-        includePaths.addElement(path);\r
-        return path;\r
-    }\r
-    /**\r
-     * Add a <includepath>or <sysincludepath> if specify the file \r
-     * attribute\r
-     * \r
-     * @throws BuildException\r
-     *             if the specify file not exist\r
-     */\r
-    protected void loadFile(Vector activePath,File file) throws BuildException {\r
-        FileReader fileReader;\r
-        BufferedReader in;\r
-        String str;\r
-        if (! file.exists()){\r
-            throw new BuildException("The file " + file + " is not existed");\r
-        }\r
-        try {\r
-            fileReader = new FileReader(file);\r
-            in = new BufferedReader(fileReader);\r
-            while ( (str = in.readLine()) != null ){                \r
-                if(str.trim() == ""){\r
-                    continue ;\r
-                }\r
-                str = getProject().replaceProperties(str);\r
-                activePath.addElement(str.trim());\r
-            }\r
-        }\r
-        catch(Exception e){\r
-            throw new BuildException(e.getMessage());\r
-        }\r
-    }\r
-    \r
-    /**\r
-     * Specifies precompilation prototype file and exclusions.\r
-     *  \r
-     */\r
-    public PrecompileDef createPrecompile() throws BuildException {\r
-       Project p = getProject();\r
-        if (isReference()) {\r
-            throw noChildrenAllowed();\r
-        }\r
-        PrecompileDef precomp = new PrecompileDef();\r
-        precomp.setProject(p);\r
-        precompileDefs.addElement(precomp);\r
-        return precomp;\r
-    }\r
-    /**\r
-     * Creates 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\r
-     * adapters should recognized the settings from the appropriate environment\r
-     * variables or configuration files.\r
-     */\r
-    public SystemIncludePath createSysIncludePath() {\r
-       Project p = getProject();\r
-        if (p == null) {\r
-            throw new java.lang.IllegalStateException("project must be set");\r
-        }\r
-        if (isReference()) {\r
-            throw noChildrenAllowed();\r
-        }\r
-        SystemIncludePath path = new SystemIncludePath(p);\r
-        sysIncludePaths.addElement(path);\r
-        return path;\r
-    }\r
-    public void execute() throws org.apache.tools.ant.BuildException {\r
-        throw new org.apache.tools.ant.BuildException(\r
-                "Not an actual task, but looks like one for documentation purposes");\r
-    }\r
-    public UndefineArgument[] getActiveDefines() {\r
-       Project p = getProject();\r
-        if (p == null) {\r
-            throw new java.lang.IllegalStateException(\r
-                    "project must be set before this call");\r
-        }\r
-        if (isReference()) {\r
-            return ((CompilerDef) getCheckedRef(CompilerDef.class,\r
-                    "CompilerDef")).getActiveDefines();\r
-        }\r
-        Vector actives = new Vector();\r
-        for (int i = 0; i < defineSets.size(); i++) {\r
-            DefineSet currentSet = (DefineSet) defineSets.elementAt(i);\r
-            UndefineArgument[] defines = currentSet.getDefines();\r
-            for (int j = 0; j < defines.length; j++) {\r
-                if (defines[j].isActive(p)) {\r
-                    actives.addElement(defines[j]);\r
-                }\r
-            }\r
-        }\r
-        UndefineArgument[] retval = new UndefineArgument[actives.size()];\r
-        actives.copyInto(retval);\r
-        return retval;\r
-    }\r
-    /**\r
-     * Returns the compiler-specific include path.\r
-     */\r
-    public String[] getActiveIncludePaths() {\r
-        if (isReference()) {\r
-            return ((CompilerDef) getCheckedRef(CompilerDef.class,\r
-                    "CompilerDef")).getActiveIncludePaths();\r
-        }\r
-        return getActivePaths(includePaths);\r
-    }\r
-    private String[] getActivePaths(Vector paths) {\r
-       Project p = getProject();\r
-        if (p == null) {\r
-            throw new java.lang.IllegalStateException("project not set");\r
-        }\r
-        Vector activePaths = new Vector(paths.size());\r
-        for (int i = 0; i < paths.size(); i++) {\r
-            ConditionalPath path = (ConditionalPath) paths.elementAt(i);\r
-            if (path.isActive(p)) {\r
-                if (path.getFile() == null) {\r
-                    String[] pathEntries = path.list();\r
-                    for (int j = 0; j < pathEntries.length; j++) {\r
-                        activePaths.addElement(pathEntries[j]);\r
-                    }\r
-                }\r
-                else {\r
-                    loadFile(activePaths, path.getFile());\r
-                }\r
-            }\r
-        }\r
-        String[] pathNames = new String[activePaths.size()];\r
-        activePaths.copyInto(pathNames);\r
-        return pathNames;\r
-    }\r
-    public PrecompileDef getActivePrecompile(CompilerDef ccElement) {\r
-        if (isReference()) {\r
-            return ((CompilerDef) getCheckedRef(CompilerDef.class,\r
-                    "CompilerDef")).getActivePrecompile(ccElement);\r
-        }\r
-        PrecompileDef current = null;\r
-        Enumeration enumPrecompilerDef = precompileDefs.elements();\r
-        while (enumPrecompilerDef.hasMoreElements()) {\r
-            current = (PrecompileDef) enumPrecompilerDef.nextElement();\r
-            if (current.isActive()) {\r
-                return current;\r
-            }\r
-        }\r
-        CompilerDef extendedDef = (CompilerDef) getExtends();\r
-        if (extendedDef != null) {\r
-            current = extendedDef.getActivePrecompile(null);\r
-            if (current != null) {\r
-                return current;\r
-            }\r
-        }\r
-        if (ccElement != null && getInherit()) {\r
-            return ccElement.getActivePrecompile(null);\r
-        }\r
-        return null;\r
-    }\r
-    public String[] getActiveSysIncludePaths() {\r
-        if (isReference()) {\r
-            return ((CompilerDef) getCheckedRef(CompilerDef.class,\r
-                    "CompilerDef")).getActiveSysIncludePaths();\r
-        }\r
-        return getActivePaths(sysIncludePaths);\r
-    }\r
-    public final boolean getExceptions(CompilerDef[] defaultProviders, int index) {\r
-        if (isReference()) {\r
-            return ((CompilerDef) getCheckedRef(CompilerDef.class,\r
-                    "CompilerDef")).getExceptions(defaultProviders, index);\r
-        }\r
-        if (exceptions != null) {\r
-            return exceptions.booleanValue();\r
-        } else {\r
-            if (defaultProviders != null && index < defaultProviders.length) {\r
-                return defaultProviders[index].getExceptions(defaultProviders,\r
-                        index + 1);\r
-            }\r
-        }\r
-        return false;\r
-    }\r
-    public final Boolean getRtti(CompilerDef[] defaultProviders, int index) {\r
-        if (isReference()) {\r
-            return ((CompilerDef) getCheckedRef(CompilerDef.class,\r
-                    "CompilerDef")).getRtti(defaultProviders, index);\r
-        }\r
-        if (rtti != null) {\r
-            return rtti;\r
-        } else {\r
-            if (defaultProviders != null && index < defaultProviders.length) {\r
-                return defaultProviders[index].getRtti(defaultProviders,\r
-                        index + 1);\r
-            }\r
-        }\r
-        return null;\r
-    }\r
-    public final Boolean getDefaultflag(CompilerDef[] defaultProviders, int index) {\r
-        if (isReference()) {\r
-            return ((CompilerDef) getCheckedRef(CompilerDef.class,\r
-                  "CompilerDef")).getDefaultflag(defaultProviders, index);\r
-        }\r
-        return defaultflag;\r
-    }\r
-    public final OptimizationEnum getOptimization(CompilerDef[] defaultProviders, int index) {\r
-        if (isReference()) {\r
-            return ((CompilerDef) getCheckedRef(CompilerDef.class,\r
-                    "CompilerDef")).getOptimization(defaultProviders, index);\r
-        }\r
-        if (optimization != null) {\r
-            return optimization;\r
-        } else {\r
-            if (defaultProviders != null && index < defaultProviders.length) {\r
-                return defaultProviders[index].getOptimization(defaultProviders,\r
-                        index + 1);\r
-            }\r
-        }\r
-        return null;\r
-    }\r
-    \r
-    public boolean getMultithreaded(CompilerDef[] defaultProviders, int index) {\r
-        if (isReference()) {\r
-            return ((CompilerDef) getCheckedRef(CompilerDef.class,\r
-                    "CompilerDef")).getMultithreaded(defaultProviders, index);\r
-        }\r
-        if (multithreaded != null) {\r
-            return multithreaded.booleanValue();\r
-        } else {\r
-            if (defaultProviders != null && index < defaultProviders.length) {\r
-                return defaultProviders[index].getMultithreaded(\r
-                        defaultProviders, index + 1);\r
-            }\r
-        }\r
-        return true;\r
-    }\r
-    public Processor getProcessor() {\r
-        Processor processor = super.getProcessor();\r
-        if (processor == null) {\r
-            processor = GccCCompiler.getInstance();\r
-        }\r
-        if (getLibtool() && processor instanceof CommandLineCompiler) {\r
-            CommandLineCompiler compiler = (CommandLineCompiler) processor;\r
-            processor = compiler.getLibtoolCompiler();\r
-        }\r
-        return processor;\r
-    }\r
-    public int getWarnings(CompilerDef[] defaultProviders, int index) {\r
-        if (isReference()) {\r
-            return ((CompilerDef) getCheckedRef(CompilerDef.class,\r
-                    "CompilerDef")).getWarnings(defaultProviders, index);\r
-        }\r
-        if (warnings == -1) {\r
-            if (defaultProviders != null && index < defaultProviders.length) {\r
-                return defaultProviders[index].getWarnings(defaultProviders,\r
-                        index + 1);\r
-            }\r
-        }\r
-        return warnings;\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) throws BuildException {\r
-        if (isReference()) {\r
-            throw tooManyAttributes();\r
-        }\r
-        super.setClassname(classname);\r
-        Processor proc = getProcessor();\r
-        if (!(proc instanceof Compiler)) {\r
-            throw new BuildException(classname + " does not implement Compiler");\r
-        }\r
-    }\r
-    /**\r
-     * Enables or disables exception support.\r
-     * \r
-     * @param exceptions\r
-     *            if true, exceptions are supported.\r
-     *  \r
-     */\r
-    public void setExceptions(boolean exceptions) {\r
-        if (isReference()) {\r
-            throw tooManyAttributes();\r
-        }\r
-        this.exceptions = booleanValueOf(exceptions);\r
-    }\r
-\r
-    /**\r
-     * Enables or disables run-time type information.\r
-     * \r
-     * @param rtti\r
-     *            if true, run-time type information is supported.\r
-     *  \r
-     */\r
-    public void setRtti(boolean rtti) {\r
-        if (isReference()) {\r
-            throw tooManyAttributes();\r
-        }\r
-        this.rtti = booleanValueOf(rtti);\r
-    }\r
-    \r
-    /**\r
-     * Enables or disables generation of multithreaded code. Unless specified,\r
-     * multithreaded code generation is enabled.\r
-     * \r
-     * @param multi\r
-     *            If true, generated code may be multithreaded.\r
-     */\r
-    public void setMultithreaded(boolean multithreaded) {\r
-        if (isReference()) {\r
-            throw tooManyAttributes();\r
-        }\r
-        this.multithreaded = booleanValueOf(multithreaded);\r
-    }\r
-    /**\r
-     * Sets compiler type.\r
-     * \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) throws BuildException {\r
-        if (isReference()) {\r
-            throw tooManyAttributes();\r
-        }\r
-        Compiler compiler = name.getCompiler();\r
-        setProcessor(compiler);\r
-    }\r
-    protected void setProcessor(Processor proc) throws BuildException {\r
-        try {\r
-            super.setProcessor((Compiler) proc);\r
-        } catch (ClassCastException ex) {\r
-            throw new BuildException(ex);\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
-        warnings = level.getIndex();\r
-    }\r
-    /**\r
-     * Sets optimization level.\r
-     * \r
-     * @param value optimization level\r
-     */\r
-    public void setOptimize(OptimizationEnum value) {\r
-       if (isReference()) {\r
-               throw tooManyAttributes();\r
-       }\r
-       this.optimization = value;\r
-    }\r
-    /**\r
-     * Enables or disables default flags.\r
-     * \r
-     * @param defaultflag\r
-     *            if true, default flags will add to command line.\r
-     *  \r
-     */\r
-    public void setDefaultflag(boolean defaultflag) {\r
-        if (isReference()) {\r
-            throw tooManyAttributes();\r
-        }\r
-        this.defaultflag = booleanValueOf(defaultflag);\r
-    }\r
-}\r