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.ibm;
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.OptimizationEnum;
28 import com.github.maven_nar.cpptasks.compiler.LinkType;
29 import com.github.maven_nar.cpptasks.compiler.Linker;
30 import com.github.maven_nar.cpptasks.gcc.GccCompatibleCCompiler;
31
32
33
34
35
36
37 public final class VisualAgeCCompiler extends GccCompatibleCCompiler {
38 private final static String[] headerExtensions = new String[] {
39 ".h", ".hpp", ".inl"
40 };
41 private final static String[] sourceExtensions = new String[] {
42 ".c", ".cc", ".cxx", ".cpp", ".i", ".s"
43 };
44
45 private static final VisualAgeCCompiler instance = new VisualAgeCCompiler("xlC", sourceExtensions, headerExtensions,
46 false, null);
47
48
49
50
51 public static VisualAgeCCompiler getInstance() {
52 return instance;
53 }
54
55 private String identifier;
56 private File[] includePath;
57
58
59
60
61
62 private VisualAgeCCompiler(final String command, final String[] sourceExtensions, final String[] headerExtensions,
63 final boolean newEnvironment, final Environment env) {
64 super(command, "-help", sourceExtensions, headerExtensions, false, null, newEnvironment, env);
65 }
66
67 @Override
68 public void addImpliedArgs(final Vector<String> args, final boolean debug, final boolean multithreaded,
69 final boolean exceptions, final LinkType linkType, final Boolean rtti, final OptimizationEnum optimization) {
70 args.addElement("-c");
71 if (debug) {
72 args.addElement("-g");
73 }
74 if (linkType.isSharedLibrary()) {
75 args.addElement("-fpic");
76 }
77 if (rtti != null) {
78 if (rtti.booleanValue()) {
79 args.addElement("-qrtti=all");
80 } else {
81 args.addElement("-qnortti");
82 }
83 }
84 }
85
86 @Override
87 public void addWarningSwitch(final Vector<String> args, final int level) {
88 switch (level) {
89 case 0:
90 args.addElement("-w");
91 break;
92 case 1:
93 args.addElement("-qflag=s:s");
94 break;
95 case 2:
96 args.addElement("-qflag=e:e");
97 break;
98 case 3:
99 args.addElement("-qflag=w:w");
100 break;
101 case 4:
102 args.addElement("-qflag=i:i");
103 break;
104 case 5:
105 args.addElement("-qhalt=w:w");
106 break;
107 }
108 }
109
110
111
112
113
114
115
116 @Override
117 public String getIdentifier() {
118 return "VisualAge compiler - unidentified version";
119 }
120
121 @Override
122 public Linker getLinker(final LinkType linkType) {
123 return VisualAgeLinker.getInstance().getLinker(linkType);
124 }
125
126 @Override
127 public int getMaximumCommandLength() {
128 return Integer.MAX_VALUE;
129 }
130
131 }