]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/devstudio/DevStudioMIDLCompiler.java
Initial import.
[mirror_edk2.git] / Tools / Source / Cpptasks / net / sf / antcontrib / cpptasks / devstudio / DevStudioMIDLCompiler.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.devstudio;
18 import java.io.File;
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;
29
30 /**
31 * Adapter for the Microsoft (r) MIDL Compiler
32 *
33 * @author Curt Arnold
34 */
35 public final class DevStudioMIDLCompiler extends CommandLineCompiler {
36 private static final DevStudioMIDLCompiler instance = new DevStudioMIDLCompiler(
37 false, null);
38 public static DevStudioMIDLCompiler getInstance() {
39 return instance;
40 }
41 private DevStudioMIDLCompiler(boolean newEnvironment, Environment env) {
42 super("midl", null, new String[]{".idl", ".odl"}, new String[]{},
43 ".tlb", false, null, newEnvironment, env);
44 }
45 protected void addImpliedArgs(final Vector args,
46 final boolean debug,
47 final boolean multithreaded,
48 final boolean exceptions,
49 final LinkType linkType,
50 final Boolean rtti,
51 final OptimizationEnum optimization,
52 final Boolean defaultflag) {
53 }
54 protected void addWarningSwitch(Vector args, int level) {
55 DevStudioProcessor.addWarningSwitch(args, level);
56 }
57 public Processor changeEnvironment(boolean newEnvironment, Environment env) {
58 if (newEnvironment || env != null) {
59 return new DevStudioMIDLCompiler(newEnvironment, env);
60 }
61 return this;
62 }
63 /**
64 * The include parser for C will work just fine, but we didn't want to
65 * inherit from CommandLineCCompiler
66 */
67 protected Parser createParser(File source) {
68 return new CParser();
69 }
70 protected int getArgumentCountPerInputFile() {
71 return 3;
72 }
73 protected void getDefineSwitch(StringBuffer buffer, String define,
74 String value) {
75 DevStudioProcessor.getDefineSwitch(buffer, define, value);
76 }
77 protected File[] getEnvironmentIncludePath() {
78 return CUtil.getPathFromEnvironment("INCLUDE", ";");
79 }
80 protected String getIncludeDirSwitch(String includeDir) {
81 return DevStudioProcessor.getIncludeDirSwitch(includeDir);
82 }
83 protected String getInputFileArgument(File outputDir, String filename,
84 int index) {
85 switch (index) {
86 case 0 :
87 return "/tlb";
88 case 1 :
89 return new File(outputDir, getOutputFileName(filename))
90 .getAbsolutePath();
91 }
92 return filename;
93 }
94 public Linker getLinker(LinkType type) {
95 return DevStudioLinker.getInstance().getLinker(type);
96 }
97 public int getMaximumCommandLength() {
98 return 1024;
99 }
100 protected int getMaximumInputFilesPerCommand() {
101 return 1;
102 }
103 protected int getTotalArgumentLengthForInputFile(File outputDir,
104 String inputFile) {
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;
109 }
110 protected void getUndefineSwitch(StringBuffer buffer, String define) {
111 DevStudioProcessor.getUndefineSwitch(buffer, define);
112 }
113 }