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.hp;
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.LinkType;
30 import com.github.maven_nar.cpptasks.compiler.Linker;
31 import com.github.maven_nar.cpptasks.gcc.GccCompatibleCCompiler;
32
33
34
35
36
37
38 public final class aCCCompiler extends GccCompatibleCCompiler {
39 private final static String[] headerExtensions = new String[] {
40 ".h", ".hpp", ".inl"
41 };
42 private final static String[] sourceExtensions = new String[] {
43 ".c", ".cc", ".cxx", ".cpp", ".c++", ".i", ".s"
44 };
45
46 private static final aCCCompiler instance = new aCCCompiler("aCC", sourceExtensions, headerExtensions, false, null);
47
48
49
50
51 public static aCCCompiler getInstance() {
52 return instance;
53 }
54
55 private String identifier;
56 private File[] includePath;
57
58
59
60
61
62 private aCCCompiler(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
75
76
77
78
79
80
81 if (linkType.isSharedLibrary() && !args.contains("+Z")) {
82 args.addElement("+z");
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 case 2:
94 args.addElement("+w");
95 break;
96
97
98
99 }
100 }
101
102 @Override
103 public File[] getEnvironmentIncludePath() {
104 if (this.includePath == null) {
105 final File ccLoc = CUtil.getExecutableLocation("aCC");
106 if (ccLoc != null) {
107 final File compilerIncludeDir = new File(new File(ccLoc, "../include").getAbsolutePath());
108 if (compilerIncludeDir.exists()) {
109 this.includePath = new File[2];
110 this.includePath[0] = compilerIncludeDir;
111 }
112 }
113 if (this.includePath == null) {
114 this.includePath = new File[1];
115 }
116 this.includePath[this.includePath.length - 1] = new File("/usr/include");
117 }
118 return this.includePath;
119 }
120
121 @Override
122 public Linker getLinker(final LinkType linkType) {
123 return aCCLinker.getInstance().getLinker(linkType);
124 }
125
126 @Override
127 public int getMaximumCommandLength() {
128 return Integer.MAX_VALUE;
129 }
130 }