]>
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 | \r | |
21 | import net.sf.antcontrib.cpptasks.CUtil;\r | |
22 | import net.sf.antcontrib.cpptasks.compiler.CommandLineCompiler;\r | |
23 | import net.sf.antcontrib.cpptasks.compiler.LinkType;\r | |
24 | import net.sf.antcontrib.cpptasks.compiler.Linker;\r | |
25 | import net.sf.antcontrib.cpptasks.compiler.Processor;\r | |
26 | import net.sf.antcontrib.cpptasks.parser.CParser;\r | |
27 | import net.sf.antcontrib.cpptasks.parser.Parser;\r | |
28 | import net.sf.antcontrib.cpptasks.OptimizationEnum;\r | |
29 | \r | |
30 | import org.apache.tools.ant.types.Environment;\r | |
31 | /**\r | |
32 | * Adapter for the Microsoft (r) Windows 32 Resource Compiler\r | |
33 | * \r | |
34 | * @author Curt Arnold\r | |
35 | */\r | |
36 | public final class DevStudioResourceCompiler extends CommandLineCompiler {\r | |
37 | private static final DevStudioResourceCompiler instance = new DevStudioResourceCompiler(\r | |
38 | false, null);\r | |
39 | public static DevStudioResourceCompiler getInstance() {\r | |
40 | return instance;\r | |
41 | }\r | |
42 | private String identifier;\r | |
43 | private DevStudioResourceCompiler(boolean newEnvironment, Environment env) {\r | |
44 | super("rc", null, new String[]{".rc"}, new String[]{".h", ".hpp",\r | |
45 | ".inl"}, ".res", false, null, newEnvironment, env);\r | |
46 | }\r | |
47 | protected void addImpliedArgs(final Vector args, \r | |
48 | final boolean debug,\r | |
49 | final boolean multithreaded, \r | |
50 | final boolean exceptions, \r | |
51 | final LinkType linkType,\r | |
52 | final Boolean rtti,\r | |
53 | final OptimizationEnum optimization,\r | |
54 | final Boolean defaultflag) {\r | |
55 | if (debug) {\r | |
56 | args.addElement("/D_DEBUG");\r | |
57 | } else {\r | |
58 | args.addElement("/DNDEBUG");\r | |
59 | }\r | |
60 | }\r | |
61 | protected void addWarningSwitch(Vector args, int level) {\r | |
62 | }\r | |
63 | public Processor changeEnvironment(boolean newEnvironment, Environment env) {\r | |
64 | if (newEnvironment || env != null) {\r | |
65 | return new DevStudioResourceCompiler(newEnvironment, env);\r | |
66 | }\r | |
67 | return this;\r | |
68 | }\r | |
69 | /**\r | |
70 | * The include parser for C will work just fine, but we didn't want to\r | |
71 | * inherit from CommandLineCCompiler\r | |
72 | */\r | |
73 | protected Parser createParser(File source) {\r | |
74 | return new CParser();\r | |
75 | }\r | |
76 | protected int getArgumentCountPerInputFile() {\r | |
77 | return 2;\r | |
78 | }\r | |
79 | protected void getDefineSwitch(StringBuffer buffer, String define,\r | |
80 | String value) {\r | |
81 | DevStudioProcessor.getDefineSwitch(buffer, define, value);\r | |
82 | }\r | |
83 | protected File[] getEnvironmentIncludePath() {\r | |
84 | return CUtil.getPathFromEnvironment("INCLUDE", ";");\r | |
85 | }\r | |
86 | protected String getIncludeDirSwitch(String includeDir) {\r | |
87 | return DevStudioProcessor.getIncludeDirSwitch(includeDir);\r | |
88 | }\r | |
89 | protected String getInputFileArgument(File outputDir, String filename,\r | |
90 | int index) {\r | |
91 | if (index == 0) {\r | |
92 | String outputFileName = getOutputFileName(filename);\r | |
93 | String fullOutputName = new File(outputDir, outputFileName)\r | |
94 | .toString();\r | |
95 | return "/fo" + fullOutputName;\r | |
96 | }\r | |
97 | return filename;\r | |
98 | }\r | |
99 | public Linker getLinker(LinkType type) {\r | |
100 | return DevStudioLinker.getInstance().getLinker(type);\r | |
101 | }\r | |
102 | public int getMaximumCommandLength() {\r | |
103 | return 1024;\r | |
104 | }\r | |
105 | protected int getMaximumInputFilesPerCommand() {\r | |
106 | return 1;\r | |
107 | }\r | |
108 | protected int getTotalArgumentLengthForInputFile(File outputDir,\r | |
109 | String inputFile) {\r | |
110 | String arg1 = getInputFileArgument(outputDir, inputFile, 0);\r | |
111 | String arg2 = getInputFileArgument(outputDir, inputFile, 1);\r | |
112 | return arg1.length() + arg2.length() + 2;\r | |
113 | }\r | |
114 | protected void getUndefineSwitch(StringBuffer buffer, String define) {\r | |
115 | DevStudioProcessor.getUndefineSwitch(buffer, define);\r | |
116 | }\r | |
117 | }\r |