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