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
;
20 import net
.sf
.antcontrib
.cpptasks
.CUtil
;
21 import net
.sf
.antcontrib
.cpptasks
.compiler
.CommandLineCompiler
;
22 import net
.sf
.antcontrib
.cpptasks
.compiler
.LinkType
;
23 import net
.sf
.antcontrib
.cpptasks
.compiler
.Linker
;
24 import net
.sf
.antcontrib
.cpptasks
.compiler
.Processor
;
25 import net
.sf
.antcontrib
.cpptasks
.parser
.CParser
;
26 import net
.sf
.antcontrib
.cpptasks
.parser
.Parser
;
27 import org
.apache
.tools
.ant
.types
.Environment
;
28 import net
.sf
.antcontrib
.cpptasks
.OptimizationEnum
;
31 * Adapter for the Microsoft (r) MIDL Compiler
35 public final class DevStudioMIDLCompiler
extends CommandLineCompiler
{
36 private static final DevStudioMIDLCompiler instance
= new DevStudioMIDLCompiler(
38 public static DevStudioMIDLCompiler
getInstance() {
41 private DevStudioMIDLCompiler(boolean newEnvironment
, Environment env
) {
42 super("midl", null, new String
[]{".idl", ".odl"}, new String
[]{},
43 ".tlb", false, null, newEnvironment
, env
);
45 protected void addImpliedArgs(final Vector args
,
47 final boolean multithreaded
,
48 final boolean exceptions
,
49 final LinkType linkType
,
51 final OptimizationEnum optimization
,
52 final Boolean defaultflag
) {
54 protected void addWarningSwitch(Vector args
, int level
) {
55 DevStudioProcessor
.addWarningSwitch(args
, level
);
57 public Processor
changeEnvironment(boolean newEnvironment
, Environment env
) {
58 if (newEnvironment
|| env
!= null) {
59 return new DevStudioMIDLCompiler(newEnvironment
, env
);
64 * The include parser for C will work just fine, but we didn't want to
65 * inherit from CommandLineCCompiler
67 protected Parser
createParser(File source
) {
70 protected int getArgumentCountPerInputFile() {
73 protected void getDefineSwitch(StringBuffer buffer
, String define
,
75 DevStudioProcessor
.getDefineSwitch(buffer
, define
, value
);
77 protected File
[] getEnvironmentIncludePath() {
78 return CUtil
.getPathFromEnvironment("INCLUDE", ";");
80 protected String
getIncludeDirSwitch(String includeDir
) {
81 return DevStudioProcessor
.getIncludeDirSwitch(includeDir
);
83 protected String
getInputFileArgument(File outputDir
, String filename
,
89 return new File(outputDir
, getOutputFileName(filename
))
94 public Linker
getLinker(LinkType type
) {
95 return DevStudioLinker
.getInstance().getLinker(type
);
97 public int getMaximumCommandLength() {
100 protected int getMaximumInputFilesPerCommand() {
103 protected int getTotalArgumentLengthForInputFile(File outputDir
,
105 String arg1
= getInputFileArgument(outputDir
, inputFile
, 0);
106 String arg2
= getInputFileArgument(outputDir
, inputFile
, 1);
107 String arg3
= getInputFileArgument(outputDir
, inputFile
, 2);
108 return arg1
.length() + arg2
.length() + arg3
.length() + 3;
110 protected void getUndefineSwitch(StringBuffer buffer
, String define
) {
111 DevStudioProcessor
.getUndefineSwitch(buffer
, define
);