]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Java/Source/Cpptasks/net/sf/antcontrib/cpptasks/arm/ADSCCompiler.java
Restructuring for better separation of Tool packages.
[mirror_edk2.git] / Tools / Java / Source / Cpptasks / net / sf / antcontrib / cpptasks / arm / ADSCCompiler.java
diff --git a/Tools/Java/Source/Cpptasks/net/sf/antcontrib/cpptasks/arm/ADSCCompiler.java b/Tools/Java/Source/Cpptasks/net/sf/antcontrib/cpptasks/arm/ADSCCompiler.java
new file mode 100644 (file)
index 0000000..78489b8
--- /dev/null
@@ -0,0 +1,215 @@
+/*\r
+ * \r
+ * Copyright 2003-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.arm;\r
+import java.io.File;\r
+import java.util.Vector;\r
+\r
+import net.sf.antcontrib.cpptasks.CUtil;\r
+import net.sf.antcontrib.cpptasks.OptimizationEnum;\r
+import net.sf.antcontrib.cpptasks.compiler.CommandLineCCompiler;\r
+import net.sf.antcontrib.cpptasks.compiler.LinkType;\r
+import net.sf.antcontrib.cpptasks.compiler.Linker;\r
+\r
+import org.apache.tools.ant.types.Environment;\r
+/**\r
+ * Adapter for the ARM C Compilers\r
+ * \r
+ * See Doc No: ARM DUI 0151A, Issued: Nov 2001 at\r
+ * http://www.arm.com/arm/User_Guides?OpenDocument\r
+ * \r
+ * @author Curt Arnold\r
+ *  \r
+ */\r
+public class ADSCCompiler extends CommandLineCCompiler {\r
+    /**\r
+     * Header file extensions\r
+     */\r
+    private static final String[] headerExtensions = new String[]{".h", ".hpp",\r
+            ".inl"};\r
+    /**\r
+     * Source file extensions\r
+     */\r
+    private static final String[] sourceExtensions = new String[]{".c", ".cc",\r
+            ".cpp", ".cxx", ".c++"};\r
+    /**\r
+     * Singleton for ARM 32-bit C compiler\r
+     */\r
+    private static final ADSCCompiler armcc = new ADSCCompiler("armcc", false,\r
+            null);\r
+    /**\r
+     * Singleton for ARM 32-bit C++ compiler\r
+     */\r
+    private static final ADSCCompiler armcpp = new ADSCCompiler("armcpp",\r
+            false, null);\r
+    /**\r
+     * Singleton for ARM 16-bit C compiler\r
+     */\r
+    private static final ADSCCompiler tcc = new ADSCCompiler("tcc", false, null);\r
+    /**\r
+     * Singleton for ARM 16-bit C++ compiler\r
+     */\r
+    private static final ADSCCompiler tcpp = new ADSCCompiler("tcpp", false,\r
+            null);\r
+    /**\r
+     * Singleton for ARM 32-bit C compiler\r
+     */\r
+    public static ADSCCompiler getArmCC() {\r
+        return armcc;\r
+    }\r
+    /**\r
+     * Singleton for ARM 32-bit C++ compiler\r
+     */\r
+    public static ADSCCompiler getArmCpp() {\r
+        return armcpp;\r
+    }\r
+    /**\r
+     * Singleton for ARM 16-bit C compiler\r
+     */\r
+    public static ADSCCompiler getThumbCC() {\r
+        return tcpp;\r
+    }\r
+    /**\r
+     * Singleton for ARM 16-bit C++ compiler\r
+     */\r
+    public static ADSCCompiler getThumbCpp() {\r
+        return tcpp;\r
+    }\r
+    private static void quoteFile(StringBuffer buf, String outPath) {\r
+        if (outPath.indexOf(' ') >= 0) {\r
+            buf.append('\"');\r
+            buf.append(outPath);\r
+            buf.append('\"');\r
+        } else {\r
+            buf.append(outPath);\r
+        }\r
+    }\r
+    /**\r
+     * Private constructor\r
+     * \r
+     * @param command\r
+     *            executable name\r
+     * @param newEnvironment\r
+     *            Change environment\r
+     * @param env\r
+     *            New environment\r
+     */\r
+    private ADSCCompiler(String command, boolean newEnvironment, Environment env) {\r
+        super(command, "-vsn", sourceExtensions, headerExtensions, ".o", false,\r
+                null, newEnvironment, env);\r
+    }\r
+    /**\r
+     * Adds command switches for generic configuration options\r
+     * \r
+     * @see net.sf.antcontrib.cpptasks.compiler.CommandLineCompiler#addImpliedArgs(java.util.Vector,\r
+     *      boolean, boolean, boolean,\r
+     *      net.sf.antcontrib.cpptasks.compiler.LinkType)\r
+     */\r
+    protected void addImpliedArgs(Vector args, \r
+               final boolean debug,\r
+            final boolean multithreaded, \r
+                       final boolean exceptions, \r
+                       final LinkType linkType,\r
+                       final Boolean rtti,\r
+                       final OptimizationEnum optimization,\r
+   final Boolean defaultflag) {\r
+        if (debug) {\r
+            args.addElement("-g");\r
+        }\r
+        //\r
+        //   didn't see anything about producing\r
+        //     anything other than executables in the docs\r
+        if (linkType.isExecutable()) {\r
+        } else if (linkType.isSharedLibrary()) {\r
+        }\r
+    }\r
+    /**\r
+     * Adds flags that customize the warnings reported\r
+     * \r
+     * Compiler does not appear to have warning levels but ability to turn off\r
+     * specific errors by explicit switches, could fabricate levels by\r
+     * prioritizing errors.\r
+     * \r
+     * @see net.sf.antcontrib.cpptasks.compiler.CommandLineCompiler#addWarningSwitch(java.util.Vector,\r
+     *      int)\r
+     */\r
+    protected void addWarningSwitch(Vector args, int warnings) {\r
+    }\r
+    /**\r
+     * Add command line options for preprocessor macro\r
+     * \r
+     * @see net.sf.antcontrib.cpptasks.compiler.CommandLineCompiler#getDefineSwitch(java.lang.StringBuffer,\r
+     *      java.lang.String, java.lang.String)\r
+     */\r
+    protected void getDefineSwitch(StringBuffer buffer, String define,\r
+            String value) {\r
+        buffer.append("-D");\r
+        buffer.append(define);\r
+        if (value != null) {\r
+            buffer.append('=');\r
+            buffer.append(value);\r
+        }\r
+    }\r
+    /**\r
+     * ARMINC environment variable contains the default include path\r
+     * \r
+     * @see net.sf.antcontrib.cpptasks.compiler.CommandLineCompiler#getEnvironmentIncludePath()\r
+     */\r
+    protected File[] getEnvironmentIncludePath() {\r
+        return CUtil.getPathFromEnvironment("ARMINC", ";");\r
+    }\r
+    /**\r
+     * Returns command line option to specify include directory\r
+     *  \r
+     */\r
+    protected String getIncludeDirSwitch(String source) {\r
+        StringBuffer buf = new StringBuffer("-I");\r
+        quoteFile(buf, source);\r
+        return buf.toString();\r
+    }\r
+    /*\r
+     * (non-Javadoc)\r
+     * \r
+     * @see net.sf.antcontrib.cpptasks.compiler.Processor#getLinker(net.sf.antcontrib.cpptasks.compiler.LinkType)\r
+     */\r
+    public Linker getLinker(LinkType type) {\r
+        if (type.isStaticLibrary()) {\r
+            return ADSLibrarian.getInstance();\r
+        }\r
+        if (type.isSharedLibrary()) {\r
+            return ADSLinker.getDllInstance();\r
+        }\r
+        return ADSLinker.getInstance();\r
+    }\r
+    /**\r
+     * Maximum command line length\r
+     * \r
+     * @see net.sf.antcontrib.cpptasks.compiler.CommandLineCompiler#getMaximumCommandLength()\r
+     */\r
+    public int getMaximumCommandLength() {\r
+        return 1000;\r
+    }\r
+    /*\r
+     * Adds command to undefine preprocessor macro\r
+     * \r
+     * @see net.sf.antcontrib.cpptasks.compiler.CommandLineCompiler#getUndefineSwitch(java.lang.StringBuffer,\r
+     *      java.lang.String)\r
+     */\r
+    protected void getUndefineSwitch(StringBuffer buffer, String define) {\r
+        buffer.append("-U");\r
+        buffer.append(define);\r
+    }\r
+}\r