4
4
import java .io .InputStreamReader ;
5
5
import java .io .PrintWriter ;
6
6
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 ;
8
10
9
11
10
12
/**
@@ -161,6 +163,27 @@ public void reportCFlags() {
161
163
out .println (flags .toString ());
162
164
}
163
165
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
+
164
187
public void run () throws IOException {
165
188
if (args .length ==0 ) {
166
189
usage ();
@@ -183,6 +206,7 @@ public void run() throws IOException {
183
206
else if (flag .equals ("endian" )) reportProp ("sun.cpu.endian" );
184
207
else if (flag .equals ("language" )) reportProp ("user.language" );
185
208
else if (flag .equals ("cflags" )) reportCFlags ();
209
+ else if (flag .equals ("ldflags" )) reportLDFlags ();
186
210
}
187
211
188
212
out .flush ();
0 commit comments