Skip to content

Commit 59c6363

Browse files
Add ldflags
1 parent e4f72be commit 59c6363

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

java-config.jar

3.49 KB
Binary file not shown.

src/JavaConfig.java

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
import java.io.InputStreamReader;
55
import java.io.PrintWriter;
66
import java.io.StringWriter;
7-
import java.io.UnsupportedEncodingException;
7+
import java.util.HashSet;
8+
import java.util.Set;
9+
import java.util.regex.Pattern;
810

911

1012
/**
@@ -161,6 +163,27 @@ public void reportCFlags() {
161163
out.println(flags.toString());
162164
}
163165

166+
public void reportLDFlags() throws IOException {
167+
String prop=System.getProperty("java.library.path");
168+
if (prop==null) error("Could not find java.library.path");
169+
String[] paths=prop.split(Pattern.quote(String.valueOf(File.pathSeparatorChar)));
170+
StringBuilder buffer=new StringBuilder();
171+
172+
Set<String> found=new HashSet<String>();
173+
for (String path: paths) {
174+
File abspath=new File(path).getAbsoluteFile();
175+
if (!abspath.isDirectory()) continue;
176+
177+
String canpath=abspath.getCanonicalPath();
178+
if (!found.add(canpath)) continue;
179+
180+
if (buffer.length()>0) buffer.append(' ');
181+
buffer.append("-L").append(canpath);
182+
}
183+
184+
out.println(buffer.toString());
185+
}
186+
164187
public void run() throws IOException {
165188
if (args.length==0) {
166189
usage();
@@ -183,6 +206,7 @@ public void run() throws IOException {
183206
else if (flag.equals("endian")) reportProp("sun.cpu.endian");
184207
else if (flag.equals("language")) reportProp("user.language");
185208
else if (flag.equals("cflags")) reportCFlags();
209+
else if (flag.equals("ldflags")) reportLDFlags();
186210
}
187211

188212
out.flush();

0 commit comments

Comments
 (0)