]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Java/Source/Cpptasks/net/sf/antcontrib/cpptasks/devstudio/DevStudioResourceCompiler.java
Restructuring for better separation of Tool packages.
[mirror_edk2.git] / Tools / Java / Source / Cpptasks / net / sf / antcontrib / cpptasks / devstudio / DevStudioResourceCompiler.java
diff --git a/Tools/Java/Source/Cpptasks/net/sf/antcontrib/cpptasks/devstudio/DevStudioResourceCompiler.java b/Tools/Java/Source/Cpptasks/net/sf/antcontrib/cpptasks/devstudio/DevStudioResourceCompiler.java
new file mode 100644 (file)
index 0000000..d6e2fd4
--- /dev/null
@@ -0,0 +1,117 @@
+/*\r
+ * \r
+ * Copyright 2002-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.devstudio;\r
+import java.io.File;\r
+import java.util.Vector;\r
+\r
+import net.sf.antcontrib.cpptasks.CUtil;\r
+import net.sf.antcontrib.cpptasks.compiler.CommandLineCompiler;\r
+import net.sf.antcontrib.cpptasks.compiler.LinkType;\r
+import net.sf.antcontrib.cpptasks.compiler.Linker;\r
+import net.sf.antcontrib.cpptasks.compiler.Processor;\r
+import net.sf.antcontrib.cpptasks.parser.CParser;\r
+import net.sf.antcontrib.cpptasks.parser.Parser;\r
+import net.sf.antcontrib.cpptasks.OptimizationEnum;\r
+\r
+import org.apache.tools.ant.types.Environment;\r
+/**\r
+ * Adapter for the Microsoft (r) Windows 32 Resource Compiler\r
+ * \r
+ * @author Curt Arnold\r
+ */\r
+public final class DevStudioResourceCompiler extends CommandLineCompiler {\r
+    private static final DevStudioResourceCompiler instance = new DevStudioResourceCompiler(\r
+            false, null);\r
+    public static DevStudioResourceCompiler getInstance() {\r
+        return instance;\r
+    }\r
+    private String identifier;\r
+    private DevStudioResourceCompiler(boolean newEnvironment, Environment env) {\r
+        super("rc", null, new String[]{".rc"}, new String[]{".h", ".hpp",\r
+                ".inl"}, ".res", false, null, newEnvironment, env);\r
+    }\r
+    protected void addImpliedArgs(final 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("/D_DEBUG");\r
+        } else {\r
+            args.addElement("/DNDEBUG");\r
+        }\r
+    }\r
+    protected void addWarningSwitch(Vector args, int level) {\r
+    }\r
+    public Processor changeEnvironment(boolean newEnvironment, Environment env) {\r
+        if (newEnvironment || env != null) {\r
+            return new DevStudioResourceCompiler(newEnvironment, env);\r
+        }\r
+        return this;\r
+    }\r
+    /**\r
+     * The include parser for C will work just fine, but we didn't want to\r
+     * inherit from CommandLineCCompiler\r
+     */\r
+    protected Parser createParser(File source) {\r
+        return new CParser();\r
+    }\r
+    protected int getArgumentCountPerInputFile() {\r
+        return 2;\r
+    }\r
+    protected void getDefineSwitch(StringBuffer buffer, String define,\r
+            String value) {\r
+        DevStudioProcessor.getDefineSwitch(buffer, define, value);\r
+    }\r
+    protected File[] getEnvironmentIncludePath() {\r
+        return CUtil.getPathFromEnvironment("INCLUDE", ";");\r
+    }\r
+    protected String getIncludeDirSwitch(String includeDir) {\r
+        return DevStudioProcessor.getIncludeDirSwitch(includeDir);\r
+    }\r
+    protected String getInputFileArgument(File outputDir, String filename,\r
+            int index) {\r
+        if (index == 0) {\r
+            String outputFileName = getOutputFileName(filename);\r
+            String fullOutputName = new File(outputDir, outputFileName)\r
+                    .toString();\r
+            return "/fo" + fullOutputName;\r
+        }\r
+        return filename;\r
+    }\r
+    public Linker getLinker(LinkType type) {\r
+        return DevStudioLinker.getInstance().getLinker(type);\r
+    }\r
+    public int getMaximumCommandLength() {\r
+        return 1024;\r
+    }\r
+    protected int getMaximumInputFilesPerCommand() {\r
+        return 1;\r
+    }\r
+    protected int getTotalArgumentLengthForInputFile(File outputDir,\r
+            String inputFile) {\r
+        String arg1 = getInputFileArgument(outputDir, inputFile, 0);\r
+        String arg2 = getInputFileArgument(outputDir, inputFile, 1);\r
+        return arg1.length() + arg2.length() + 2;\r
+    }\r
+    protected void getUndefineSwitch(StringBuffer buffer, String define) {\r
+        DevStudioProcessor.getUndefineSwitch(buffer, define);\r
+    }\r
+}\r