1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package com.github.maven_nar.cpptasks.borland;
21
22 import java.io.File;
23 import java.util.Vector;
24
25 import org.apache.tools.ant.BuildException;
26 import org.apache.tools.ant.types.Environment;
27
28 import com.github.maven_nar.cpptasks.CCTask;
29 import com.github.maven_nar.cpptasks.OptimizationEnum;
30 import com.github.maven_nar.cpptasks.compiler.CommandLineCompiler;
31 import com.github.maven_nar.cpptasks.compiler.CommandLineCompilerConfiguration;
32 import com.github.maven_nar.cpptasks.compiler.LinkType;
33 import com.github.maven_nar.cpptasks.compiler.Linker;
34 import com.github.maven_nar.cpptasks.compiler.Processor;
35 import com.github.maven_nar.cpptasks.compiler.ProgressMonitor;
36 import com.github.maven_nar.cpptasks.parser.CParser;
37 import com.github.maven_nar.cpptasks.parser.Parser;
38
39
40
41
42
43
44 public class BorlandResourceCompiler extends CommandLineCompiler {
45 private static final BorlandResourceCompiler instance = new BorlandResourceCompiler(false, null);
46
47 public static BorlandResourceCompiler getInstance() {
48 return instance;
49 }
50
51 private BorlandResourceCompiler(final boolean newEnvironment, final Environment env) {
52 super("brc32", "c:\\__bogus\\__bogus.rc", new String[] {
53 ".rc"
54 }, new String[] {
55 ".h", ".hpp", ".inl"
56 }, ".res", false, null, newEnvironment, env);
57 }
58
59 @Override
60 protected void addImpliedArgs(final Vector<String> args, final boolean debug, final boolean multithreaded,
61 final boolean exceptions, final LinkType linkType, final Boolean rtti, final OptimizationEnum optimization) {
62
63
64
65 args.addElement("-r");
66 }
67
68 @Override
69 protected void addWarningSwitch(final Vector<String> args, final int level) {
70 }
71
72 @Override
73 public Processor changeEnvironment(final boolean newEnvironment, final Environment env) {
74 if (newEnvironment || env != null) {
75 return new BorlandResourceCompiler(newEnvironment, env);
76 }
77 return this;
78 }
79
80 @Override
81 public void compile(final CCTask task, final File outputDir, final String[] sourceFiles, final String[] args,
82 final String[] endArgs, final boolean relentless, final CommandLineCompilerConfiguration config,
83 final ProgressMonitor monitor) throws BuildException {
84 super.compile(task, outputDir, sourceFiles, args, endArgs, relentless, config, monitor);
85 }
86
87
88
89
90
91 @Override
92 protected Parser createParser(final File source) {
93 return new CParser();
94 }
95
96 @Override
97 protected int getArgumentCountPerInputFile() {
98 return 2;
99 }
100
101 @Override
102 protected void getDefineSwitch(final StringBuffer buffer, final String define, final String value) {
103 buffer.append("-d");
104 buffer.append(define);
105 if (value != null && value.length() > 0) {
106 buffer.append('=');
107 buffer.append(value);
108 }
109 }
110
111 @Override
112 protected File[] getEnvironmentIncludePath() {
113 return BorlandProcessor.getEnvironmentPath("brc32", 'i', new String[] {
114 "..\\include"
115 });
116 }
117
118 @Override
119 protected String getIncludeDirSwitch(final String includeDir) {
120 return BorlandProcessor.getIncludeDirSwitch("-i", includeDir);
121 }
122
123 @Override
124 protected String getInputFileArgument(final File outputDir, final String filename, final int index) {
125 if (index == 0) {
126 final String[] outputFileNames = getOutputFileNames(filename, null);
127 final String fullOutputName = new File(outputDir, outputFileNames[0]).toString();
128 return "-fo" + fullOutputName;
129 }
130 return filename;
131 }
132
133 @Override
134 public Linker getLinker(final LinkType type) {
135 return BorlandLinker.getInstance().getLinker(type);
136 }
137
138 @Override
139 public int getMaximumCommandLength() {
140 return 1024;
141 }
142
143 @Override
144 protected int getMaximumInputFilesPerCommand() {
145 return 1;
146 }
147
148 @Override
149 protected void getUndefineSwitch(final StringBuffer buffer, final String define) {
150 }
151 }