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