]>
Commit | Line | Data |
---|---|---|
878ddf1f | 1 | /*\r |
2 | * \r | |
3 | * Copyright 2002-2004 The Ant-Contrib project\r | |
4 | *\r | |
5 | * Licensed under the Apache License, Version 2.0 (the "License");\r | |
6 | * you may not use this file except in compliance with the License.\r | |
7 | * You may obtain a copy of the License at\r | |
8 | *\r | |
9 | * http://www.apache.org/licenses/LICENSE-2.0\r | |
10 | *\r | |
11 | * Unless required by applicable law or agreed to in writing, software\r | |
12 | * distributed under the License is distributed on an "AS IS" BASIS,\r | |
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r | |
14 | * See the License for the specific language governing permissions and\r | |
15 | * limitations under the License.\r | |
16 | */\r | |
17 | package net.sf.antcontrib.cpptasks.devstudio;\r | |
18 | import java.io.File;\r | |
19 | import java.util.Vector;\r | |
20 | import net.sf.antcontrib.cpptasks.CUtil;\r | |
21 | import net.sf.antcontrib.cpptasks.compiler.CommandLineCompiler;\r | |
22 | import net.sf.antcontrib.cpptasks.compiler.LinkType;\r | |
23 | import net.sf.antcontrib.cpptasks.compiler.Linker;\r | |
24 | import net.sf.antcontrib.cpptasks.compiler.Processor;\r | |
25 | import net.sf.antcontrib.cpptasks.parser.CParser;\r | |
26 | import net.sf.antcontrib.cpptasks.parser.Parser;\r | |
27 | import org.apache.tools.ant.types.Environment;\r | |
28 | import net.sf.antcontrib.cpptasks.OptimizationEnum;\r | |
29 | \r | |
30 | /**\r | |
31 | * Adapter for the Microsoft (r) MIDL Compiler\r | |
32 | * \r | |
33 | * @author Curt Arnold\r | |
34 | */\r | |
35 | public final class DevStudioMIDLCompiler extends CommandLineCompiler {\r | |
36 | private static final DevStudioMIDLCompiler instance = new DevStudioMIDLCompiler(\r | |
37 | false, null);\r | |
38 | public static DevStudioMIDLCompiler getInstance() {\r | |
39 | return instance;\r | |
40 | }\r | |
41 | private DevStudioMIDLCompiler(boolean newEnvironment, Environment env) {\r | |
42 | super("midl", null, new String[]{".idl", ".odl"}, new String[]{},\r | |
43 | ".tlb", false, null, newEnvironment, env);\r | |
44 | }\r | |
45 | protected void addImpliedArgs(final Vector args, \r | |
46 | final boolean debug,\r | |
47 | final boolean multithreaded, \r | |
48 | final boolean exceptions, \r | |
49 | final LinkType linkType,\r | |
50 | final Boolean rtti,\r | |
51 | final OptimizationEnum optimization,\r | |
52 | final Boolean defaultflag) {\r | |
53 | }\r | |
54 | protected void addWarningSwitch(Vector args, int level) {\r | |
55 | DevStudioProcessor.addWarningSwitch(args, level);\r | |
56 | }\r | |
57 | public Processor changeEnvironment(boolean newEnvironment, Environment env) {\r | |
58 | if (newEnvironment || env != null) {\r | |
59 | return new DevStudioMIDLCompiler(newEnvironment, env);\r | |
60 | }\r | |
61 | return this;\r | |
62 | }\r | |
63 | /**\r | |
64 | * The include parser for C will work just fine, but we didn't want to\r | |
65 | * inherit from CommandLineCCompiler\r | |
66 | */\r | |
67 | protected Parser createParser(File source) {\r | |
68 | return new CParser();\r | |
69 | }\r | |
70 | protected int getArgumentCountPerInputFile() {\r | |
71 | return 3;\r | |
72 | }\r | |
73 | protected void getDefineSwitch(StringBuffer buffer, String define,\r | |
74 | String value) {\r | |
75 | DevStudioProcessor.getDefineSwitch(buffer, define, value);\r | |
76 | }\r | |
77 | protected File[] getEnvironmentIncludePath() {\r | |
78 | return CUtil.getPathFromEnvironment("INCLUDE", ";");\r | |
79 | }\r | |
80 | protected String getIncludeDirSwitch(String includeDir) {\r | |
81 | return DevStudioProcessor.getIncludeDirSwitch(includeDir);\r | |
82 | }\r | |
83 | protected String getInputFileArgument(File outputDir, String filename,\r | |
84 | int index) {\r | |
85 | switch (index) {\r | |
86 | case 0 :\r | |
87 | return "/tlb";\r | |
88 | case 1 :\r | |
89 | return new File(outputDir, getOutputFileName(filename))\r | |
90 | .getAbsolutePath();\r | |
91 | }\r | |
92 | return filename;\r | |
93 | }\r | |
94 | public Linker getLinker(LinkType type) {\r | |
95 | return DevStudioLinker.getInstance().getLinker(type);\r | |
96 | }\r | |
97 | public int getMaximumCommandLength() {\r | |
98 | return 1024;\r | |
99 | }\r | |
100 | protected int getMaximumInputFilesPerCommand() {\r | |
101 | return 1;\r | |
102 | }\r | |
103 | protected int getTotalArgumentLengthForInputFile(File outputDir,\r | |
104 | String inputFile) {\r | |
105 | String arg1 = getInputFileArgument(outputDir, inputFile, 0);\r | |
106 | String arg2 = getInputFileArgument(outputDir, inputFile, 1);\r | |
107 | String arg3 = getInputFileArgument(outputDir, inputFile, 2);\r | |
108 | return arg1.length() + arg2.length() + arg3.length() + 3;\r | |
109 | }\r | |
110 | protected void getUndefineSwitch(StringBuffer buffer, String define) {\r | |
111 | DevStudioProcessor.getUndefineSwitch(buffer, define);\r | |
112 | }\r | |
113 | }\r |