1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package com.github.maven_nar.cpptasks.sun;
21
22 import java.io.File;
23 import java.util.Vector;
24
25 import org.apache.tools.ant.types.Environment;
26
27 import com.github.maven_nar.cpptasks.CUtil;
28 import com.github.maven_nar.cpptasks.OptimizationEnum;
29 import com.github.maven_nar.cpptasks.compiler.AbstractCompiler;
30 import com.github.maven_nar.cpptasks.compiler.CommandLineCCompiler;
31 import com.github.maven_nar.cpptasks.compiler.LinkType;
32 import com.github.maven_nar.cpptasks.compiler.Linker;
33 import com.github.maven_nar.cpptasks.compiler.Processor;
34
35
36
37
38
39
40 public class C89CCompiler extends CommandLineCCompiler {
41 private static final AbstractCompiler instance = new C89CCompiler(false, null);
42
43 public static AbstractCompiler getInstance() {
44 return instance;
45 }
46
47 private C89CCompiler(final boolean newEnvironment, final Environment env) {
48 super("c89", null, new String[] {
49 ".c", ".cc", ".cpp", ".cxx", ".c++"
50 }, new String[] {
51 ".h", ".hpp"
52 }, ".o", false, null, newEnvironment, env);
53 }
54
55 @Override
56 protected void addImpliedArgs(final Vector<String> args, final boolean debug, final boolean multithreaded,
57 final boolean exceptions, final LinkType linkType, final Boolean rtti, final OptimizationEnum optimization) {
58
59 args.addElement("-c");
60
61
62
63 if (debug) {
64 args.addElement("-g");
65 args.addElement("-D_DEBUG");
66
67
68
69
70
71 } else {
72 args.addElement("-DNDEBUG");
73
74
75
76
77
78 }
79 }
80
81 @Override
82 protected void addWarningSwitch(final Vector<String> args, final int level) {
83 C89Processor.addWarningSwitch(args, level);
84 }
85
86 @Override
87 public Processor changeEnvironment(final boolean newEnvironment, final Environment env) {
88 if (newEnvironment || env != null) {
89 return new C89CCompiler(newEnvironment, env);
90 }
91 return this;
92 }
93
94 @Override
95 protected void getDefineSwitch(final StringBuffer buf, final String define, final String value) {
96 C89Processor.getDefineSwitch(buf, define, value);
97 }
98
99 @Override
100 protected File[] getEnvironmentIncludePath() {
101 return CUtil.getPathFromEnvironment("INCLUDE", ":");
102 }
103
104 @Override
105 protected String getIncludeDirSwitch(final String includeDir) {
106 return C89Processor.getIncludeDirSwitch(includeDir);
107 }
108
109 @Override
110 public Linker getLinker(final LinkType type) {
111 return C89Linker.getInstance().getLinker(type);
112 }
113
114 @Override
115 public int getMaximumCommandLength() {
116 return Integer.MAX_VALUE;
117 }
118
119
120 @Override
121 protected int getMaximumInputFilesPerCommand() {
122 return 1;
123 }
124
125 @Override
126 protected void getUndefineSwitch(final StringBuffer buf, final String define) {
127 C89Processor.getUndefineSwitch(buf, define);
128 }
129 }