]> git.proxmox.com Git - mirror_edk2.git/blame - Tools/Java/Source/Cpptasks/net/sf/antcontrib/cpptasks/borland/BorlandResourceCompiler.java
remove unnecessary check for NULL pointer.
[mirror_edk2.git] / Tools / Java / Source / Cpptasks / net / sf / antcontrib / cpptasks / borland / BorlandResourceCompiler.java
CommitLineData
878ddf1f 1/*\r
2 * \r
3 * Copyright 2002-2004 The Ant-Contrib project\r
4 *\r
5 * Licensed under the Apache License, Version 2.0 (the "License");\r
6 * you may not use this file except in compliance with the License.\r
7 * You may obtain a copy of the License at\r
8 *\r
9 * http://www.apache.org/licenses/LICENSE-2.0\r
10 *\r
11 * Unless required by applicable law or agreed to in writing, software\r
12 * distributed under the License is distributed on an "AS IS" BASIS,\r
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
14 * See the License for the specific language governing permissions and\r
15 * limitations under the License.\r
16 */\r
17package net.sf.antcontrib.cpptasks.borland;\r
18import java.io.File;\r
19import java.util.Vector;\r
20import net.sf.antcontrib.cpptasks.CCTask;\r
21import net.sf.antcontrib.cpptasks.compiler.CommandLineCompiler;\r
22import net.sf.antcontrib.cpptasks.compiler.CommandLineCompilerConfiguration;\r
23import net.sf.antcontrib.cpptasks.compiler.LinkType;\r
24import net.sf.antcontrib.cpptasks.compiler.Linker;\r
25import net.sf.antcontrib.cpptasks.compiler.Processor;\r
26import net.sf.antcontrib.cpptasks.compiler.ProgressMonitor;\r
27import net.sf.antcontrib.cpptasks.parser.CParser;\r
28import net.sf.antcontrib.cpptasks.parser.Parser;\r
29import net.sf.antcontrib.cpptasks.OptimizationEnum;\r
30\r
31import org.apache.tools.ant.BuildException;\r
32import org.apache.tools.ant.types.Environment;\r
33/**\r
34 * Adapter for the Borland(r) brc32 Resource compiler.\r
35 * \r
36 * @author Curt Arnold\r
37 */\r
38public class BorlandResourceCompiler extends CommandLineCompiler {\r
39 private static final BorlandResourceCompiler instance = new BorlandResourceCompiler(\r
40 false, null);\r
41 public static BorlandResourceCompiler getInstance() {\r
42 return instance;\r
43 }\r
44 private BorlandResourceCompiler(boolean newEnvironment, Environment env) {\r
45 super("brc32", "c:\\__bogus\\__bogus.rc", new String[]{".rc"},\r
46 new String[]{".h", ".hpp", ".inl"}, ".res", false, null,\r
47 newEnvironment, env);\r
48 }\r
49 protected void addImpliedArgs(final Vector args, \r
50 final boolean debug,\r
51 final boolean multithreaded, \r
52 final boolean exceptions, \r
53 final LinkType linkType,\r
54 final Boolean rtti,\r
55 final OptimizationEnum optimization,\r
56 final Boolean defaultflag) {\r
57 //\r
58 // compile only\r
59 //\r
60 args.addElement("-r");\r
61 }\r
62 protected void addWarningSwitch(Vector args, int level) {\r
63 }\r
64 public Processor changeEnvironment(boolean newEnvironment, Environment env) {\r
65 if (newEnvironment || env != null) {\r
66 return new BorlandResourceCompiler(newEnvironment, env);\r
67 }\r
68 return this;\r
69 }\r
70 public void compile(CCTask task, File outputDir, String[] sourceFiles,\r
71 String[] args, String[] endArgs, boolean relentless,\r
72 CommandLineCompilerConfiguration config, ProgressMonitor monitor)\r
73 throws BuildException {\r
74 super.compile(task, outputDir, sourceFiles, args, endArgs, relentless,\r
75 config, monitor);\r
76 }\r
77 /**\r
78 * The include parser for C will work just fine, but we didn't want to\r
79 * inherit from CommandLineCCompiler\r
80 */\r
81 protected Parser createParser(File source) {\r
82 return new CParser();\r
83 }\r
84 protected int getArgumentCountPerInputFile() {\r
85 return 2;\r
86 }\r
87 protected void getDefineSwitch(StringBuffer buffer, String define,\r
88 String value) {\r
89 buffer.append("-d");\r
90 buffer.append(define);\r
91 if (value != null && value.length() > 0) {\r
92 buffer.append('=');\r
93 buffer.append(value);\r
94 }\r
95 }\r
96 protected File[] getEnvironmentIncludePath() {\r
97 return BorlandProcessor.getEnvironmentPath("brc32", 'i',\r
98 new String[]{"..\\include"});\r
99 }\r
100 protected String getIncludeDirSwitch(String includeDir) {\r
101 return BorlandProcessor.getIncludeDirSwitch("-i", includeDir);\r
102 }\r
103 protected String getInputFileArgument(File outputDir, String filename,\r
104 int index) {\r
105 if (index == 0) {\r
106 String outputFileName = getOutputFileName(filename);\r
107 String fullOutputName = new File(outputDir, outputFileName)\r
108 .toString();\r
109 return "-fo" + fullOutputName;\r
110 }\r
111 return filename;\r
112 }\r
113 public Linker getLinker(LinkType type) {\r
114 return BorlandLinker.getInstance().getLinker(type);\r
115 }\r
116 public int getMaximumCommandLength() {\r
117 return 1024;\r
118 }\r
119 protected int getMaximumInputFilesPerCommand() {\r
120 return 1;\r
121 }\r
122 protected int getTotalArgumentLengthForInputFile(File outputDir,\r
123 String inputFile) {\r
124 String arg1 = getInputFileArgument(outputDir, inputFile, 0);\r
125 String arg2 = getInputFileArgument(outputDir, inputFile, 1);\r
126 return arg1.length() + arg2.length() + 2;\r
127 }\r
128 protected void getUndefineSwitch(StringBuffer buffer, String define) {\r
129 }\r
130}\r