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 com.github.maven_nar.cpptasks.CUtil;
26 import com.github.maven_nar.cpptasks.compiler.LinkType;
27 import com.github.maven_nar.cpptasks.compiler.Linker;
28 import com.github.maven_nar.cpptasks.gcc.AbstractLdLinker;
29
30
31
32
33
34
35 public final class aCCLinker extends AbstractLdLinker {
36 private static final String[] discardFiles = new String[0];
37 private static final String[] objFiles = new String[] {
38 ".o", ".a", ".lib", ".dll", ".so", ".sl"
39 };
40 private static final aCCLinker arLinker = new aCCLinker("aCC", objFiles, discardFiles, "", ".a");
41 private static final aCCLinker dllLinker = new aCCLinker("aCC", objFiles, discardFiles, "lib", ".sl");
42 private static final aCCLinker instance = new aCCLinker("aCC", objFiles, discardFiles, "", "");
43
44 public static aCCLinker getInstance() {
45 return instance;
46 }
47
48 private File[] libDirs;
49
50 private aCCLinker(final String command, final String[] extensions, final String[] ignoredExtensions,
51 final String outputPrefix, final String outputSuffix) {
52 super(command, "-help", extensions, ignoredExtensions, outputPrefix, outputSuffix, false, null);
53 }
54
55 public void addImpliedArgs(final boolean debug, final LinkType linkType, final Vector<String> args) {
56 if (debug) {
57 args.addElement("-g");
58 }
59
60
61
62 if (linkType.isSharedLibrary()) {
63 args.addElement("-b");
64 }
65
66
67
68 }
69
70 public void addIncremental(final boolean incremental, final Vector<String> args) {
71
72
73
74
75 }
76
77
78
79
80
81 @Override
82 public File[] getLibraryPath() {
83 if (this.libDirs == null) {
84 final File CCloc = CUtil.getExecutableLocation("aCC");
85 if (CCloc != null) {
86 final File compilerLib = new File(new File(CCloc, "../lib").getAbsolutePath());
87 if (compilerLib.exists()) {
88 this.libDirs = new File[2];
89 this.libDirs[0] = compilerLib;
90 }
91 }
92 if (this.libDirs == null) {
93 this.libDirs = new File[1];
94 }
95 }
96 this.libDirs[this.libDirs.length - 1] = new File("/usr/lib");
97 return this.libDirs;
98 }
99
100 @Override
101 public Linker getLinker(final LinkType type) {
102 if (type.isStaticLibrary()) {
103 return arLinker;
104 }
105 if (type.isSharedLibrary()) {
106 return dllLinker;
107 }
108 return instance;
109 }
110 }