Skip to content

Commit 6f33b48

Browse files
akshayaurorainclement
authored andcommitted
dynamically load libcrypto ans libel if they exist
1 parent 1a42ce1 commit 6f33b48

File tree

1 file changed

+32
-15
lines changed

1 file changed

+32
-15
lines changed

pythonforandroid/bootstraps/sdl2/build/src/org/kivy/android/PythonUtil.java

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,48 @@
33
import java.io.File;
44

55
import android.util.Log;
6-
6+
import java.util.ArrayList;
7+
import java.io.FilenameFilter;
78

89
public class PythonUtil {
910
private static final String TAG = "pythonutil";
1011

11-
protected static String[] getLibraries() {
12-
return new String[] {
13-
"SDL2",
14-
"SDL2_image",
15-
"SDL2_mixer",
16-
"SDL2_ttf",
17-
"crypto1.0.2h",
18-
"ssl1.0.2h",
19-
"python2.7",
20-
"python3.5m",
21-
"python3.6m",
22-
"main"
12+
protected static ArrayList<String> getLibraries(File filesDir) {
13+
14+
ArrayList<String> MyList = new ArrayList<String>();
15+
MyList.add("SDL2");
16+
MyList.add("SDL2_image");
17+
MyList.add("SDL2_mixer");
18+
MyList.add("SDL2_ttf");
19+
20+
String absPath = filesDir.getParentFile().getParentFile().getAbsolutePath() + "/lib/";
21+
filesDir = new File(absPath);
22+
File [] files = filesDir.listFiles(new FilenameFilter() {
23+
@Override
24+
public boolean accept(File dir, String name) {
25+
return name.matches(".*ssl.*") || name.matches(".*crypto.*");
26+
}
27+
});
28+
29+
for (int i = 0; i < files.length; ++i) {
30+
File mfl = files[i];
31+
String name = mfl.getName();
32+
name = name.substring(3, name.length() - 3);
33+
MyList.add(name);
2334
};
35+
36+
MyList.add("python2.7");
37+
MyList.add("python3.5m");
38+
MyList.add("main");
39+
return MyList;
2440
}
2541

26-
public static void loadLibraries(File filesDir) {
42+
public static void loadLibraries(File filesDir) {
2743

2844
String filesDirPath = filesDir.getAbsolutePath();
2945
boolean foundPython = false;
3046

31-
for (String lib : getLibraries()) {
47+
for (String lib : getLibraries(filesDir)) {
3248
Log.v(TAG, "Loading library: " + lib);
3349
try {
3450
System.loadLibrary(lib);
@@ -68,3 +84,4 @@ public static void loadLibraries(File filesDir) {
6884
Log.v(TAG, "Loaded everything!");
6985
}
7086
}
87+

0 commit comments

Comments
 (0)