3 * Copyright 2002-2004 The Ant-Contrib project
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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package net
.sf
.antcontrib
.cpptasks
.devstudio
;
19 import java
.util
.Vector
;
21 import net
.sf
.antcontrib
.cpptasks
.CUtil
;
22 import net
.sf
.antcontrib
.cpptasks
.compiler
.CommandLineCompiler
;
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
.parser
.CParser
;
27 import net
.sf
.antcontrib
.cpptasks
.parser
.Parser
;
28 import net
.sf
.antcontrib
.cpptasks
.OptimizationEnum
;
30 import org
.apache
.tools
.ant
.types
.Environment
;
32 * Adapter for the Microsoft (r) Windows 32 Resource Compiler
36 public final class DevStudioResourceCompiler
extends CommandLineCompiler
{
37 private static final DevStudioResourceCompiler instance
= new DevStudioResourceCompiler(
39 public static DevStudioResourceCompiler
getInstance() {
42 private String identifier
;
43 private DevStudioResourceCompiler(boolean newEnvironment
, Environment env
) {
44 super("rc", null, new String
[]{".rc"}, new String
[]{".h", ".hpp",
45 ".inl"}, ".res", false, null, newEnvironment
, env
);
47 protected void addImpliedArgs(final Vector args
,
49 final boolean multithreaded
,
50 final boolean exceptions
,
51 final LinkType linkType
,
53 final OptimizationEnum optimization
,
54 final Boolean defaultflag
) {
56 args
.addElement("/D_DEBUG");
58 args
.addElement("/DNDEBUG");
61 protected void addWarningSwitch(Vector args
, int level
) {
63 public Processor
changeEnvironment(boolean newEnvironment
, Environment env
) {
64 if (newEnvironment
|| env
!= null) {
65 return new DevStudioResourceCompiler(newEnvironment
, env
);
70 * The include parser for C will work just fine, but we didn't want to
71 * inherit from CommandLineCCompiler
73 protected Parser
createParser(File source
) {
76 protected int getArgumentCountPerInputFile() {
79 protected void getDefineSwitch(StringBuffer buffer
, String define
,
81 DevStudioProcessor
.getDefineSwitch(buffer
, define
, value
);
83 protected File
[] getEnvironmentIncludePath() {
84 return CUtil
.getPathFromEnvironment("INCLUDE", ";");
86 protected String
getIncludeDirSwitch(String includeDir
) {
87 return DevStudioProcessor
.getIncludeDirSwitch(includeDir
);
89 protected String
getInputFileArgument(File outputDir
, String filename
,
92 String outputFileName
= getOutputFileName(filename
);
93 String fullOutputName
= new File(outputDir
, outputFileName
)
95 return "/fo" + fullOutputName
;
99 public Linker
getLinker(LinkType type
) {
100 return DevStudioLinker
.getInstance().getLinker(type
);
102 public int getMaximumCommandLength() {
105 protected int getMaximumInputFilesPerCommand() {
108 protected int getTotalArgumentLengthForInputFile(File outputDir
,
110 String arg1
= getInputFileArgument(outputDir
, inputFile
, 0);
111 String arg2
= getInputFileArgument(outputDir
, inputFile
, 1);
112 return arg1
.length() + arg2
.length() + 2;
114 protected void getUndefineSwitch(StringBuffer buffer
, String define
) {
115 DevStudioProcessor
.getUndefineSwitch(buffer
, define
);