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.os400;
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 IccCompiler extends CommandLineCCompiler {
41 private static final AbstractCompiler instance = new IccCompiler(false, null);
42
43 public static AbstractCompiler getInstance() {
44 return instance;
45 }
46
47 private IccCompiler(final boolean newEnvironment, final Environment env) {
48 super("icc", null, new String[] {
49 ".c", ".cc", ".cpp", ".cxx", ".c++", ".s"
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
60 args.addElement("-c");
61
62
63
64 if (debug) {
65 args.addElement("-g");
66
67
68
69
70
71
72 } else {
73
74
75
76
77
78
79 }
80 }
81
82 @Override
83 protected void addWarningSwitch(final Vector<String> args, final int level) {
84 IccProcessor.addWarningSwitch(args, level);
85 }
86
87 @Override
88 public Processor changeEnvironment(final boolean newEnvironment, final Environment env) {
89 if (newEnvironment || env != null) {
90 return new IccCompiler(newEnvironment, env);
91 }
92 return this;
93 }
94
95 @Override
96 protected void getDefineSwitch(final StringBuffer buffer, final String define, final String value) {
97 buffer.append("-q");
98 buffer.append(define);
99 if (value != null && value.length() > 0) {
100 buffer.append('=');
101 buffer.append(value);
102 }
103 }
104
105 @Override
106 protected File[] getEnvironmentIncludePath() {
107 return CUtil.getPathFromEnvironment("INCLUDE", ":");
108 }
109
110 @Override
111 protected String getIncludeDirSwitch(final String includeDir) {
112 return IccProcessor.getIncludeDirSwitch(includeDir);
113 }
114
115 @Override
116 public Linker getLinker(final LinkType type) {
117 return IccLinker.getInstance().getLinker(type);
118 }
119
120 @Override
121 public int getMaximumCommandLength() {
122 return Integer.MAX_VALUE;
123 }
124
125
126 @Override
127 protected int getMaximumInputFilesPerCommand() {
128 return 1;
129
130 }
131
132 @Override
133 protected void getUndefineSwitch(final StringBuffer buffer, final String define) {
134
135
136
137 }
138 }