|
14 | 14 |
|
15 | 15 | public class LinkerFlagsDetector { |
16 | 16 | public static final LinkerFlagsDetector INSTANCE = new LinkerFlagsDetector(); |
17 | | - private static final Pattern FILE_NAME = Pattern.compile("[A-Za-z_.][A-Za-z0-9_.]+"); |
18 | | - //-lSDL2 |
19 | | - private static final Pattern INCLUDE_SDL = Pattern.compile("#include\\s+[<\"]SDL.h[>\"]"); |
| 17 | + private static final Pattern FILE_NAME = Pattern.compile("[A-Za-z_.][A-Za-z0-9_.\\-]+"); |
| 18 | + |
| 19 | + |
20 | 20 | //-lGLESv1_CM |
21 | | - private static final Pattern INCLUDE_GLESV1_CM |
22 | | - = Pattern.compile("#include\\s+[<\"]GLES/(" + FILE_NAME.pattern() + ")[>\"]"); |
| 21 | + private static final Pattern INCLUDE_GLES_V1_CM |
| 22 | + = Pattern.compile("#include\\s+[<\"]" + |
| 23 | + "(GLES/gl\\.h|GLES/glext\\.h|GLES/glplatform\\.h|((\\S+)?gl[^2]+\\.h))" + |
| 24 | + "[>\"]"); |
| 25 | + //case: gl2.h, gl2ext.h, gl2platform.h, SDL_opengles2.h, .. |
| 26 | + private static final Pattern INCLUDE_GLES_V2 |
| 27 | + = Pattern.compile("#include\\s+[<\"]" + |
| 28 | + "(GLES2/gl2\\.h|GLES2/gl2ext\\.h|GLES2/gl2platform\\.h|((\\S+)?gl(\\S+)?2(\\S+)?\\.h))" + |
| 29 | + "[>\"]"); |
| 30 | + //-lOpenSLES |
| 31 | + private static final Pattern INCLUDE_OPEN_SLES |
| 32 | + = Pattern.compile("#include\\s+[<\"]SLES/(" + FILE_NAME.pattern() + ")[>\"]"); |
23 | 33 |
|
24 | 34 | //-landroid |
25 | 35 | private static final Pattern INCLUDE_ANDROID |
26 | 36 | = Pattern.compile("#include\\s+[<\"]android/(" + FILE_NAME.pattern() + ")[>\"]"); |
27 | 37 | //-llog |
28 | 38 | private static final Pattern INCLUDE_ANDROID_LOG |
29 | | - = Pattern.compile("#include\\s+[<\"]<android/log.h>[>\"]"); |
| 39 | + = Pattern.compile("#include\\s+[<\"]<android/log\\.h>[>\"]"); |
30 | 40 | //-lEGL |
31 | 41 | private static final Pattern INCLUDE_EGL |
32 | 42 | = Pattern.compile("#include\\s+[<\"]EGL/(" + FILE_NAME.pattern() + ")[>\"]"); |
33 | 43 | //-latomic |
34 | | - private static final Pattern INCLUDE_ATOMIC = Pattern.compile("#include\\s+[<\"]atomic.h[>\"]"); |
| 44 | + private static final Pattern INCLUDE_ATOMIC = Pattern.compile("#include\\s+[<\"]atomic\\.h[>\"]"); |
35 | 45 | //-latomic |
36 | | - private static final Pattern INCLUDE_MATH = Pattern.compile("#include\\s+[<\"]math.h[>\"]"); |
| 46 | + private static final Pattern INCLUDE_MATH = Pattern.compile("#include\\s+[<\"]math\\.h[>\"]"); |
| 47 | + private static final Pattern INCLUDE_ZLIB = Pattern.compile("#include\\s+[<\"]zlib\\.h[>\"]"); |
37 | 48 |
|
| 49 | + //-lSDL2 |
| 50 | + private static final Pattern INCLUDE_SDL = Pattern.compile("#include\\s+[<\"]SDL\\.h[>\"]"); |
| 51 | + //-lSDL2_ttf |
| 52 | + private static final Pattern INCLUDE_SDL_TTF = Pattern.compile("#include\\s+[<\"]SDL_ttf\\.h[>\"]"); |
| 53 | + //-lSDL2_image |
| 54 | + private static final Pattern INCLUDE_SDL_IMAGE = Pattern.compile("#include\\s+[<\"]SDL_image\\.h[>\"]"); |
| 55 | + private static final Pattern INCLUDE_SDL_MIXER = Pattern.compile("#include\\s+[<\"]SDL_mixer\\.h[>\"]"); |
| 56 | + private static final Pattern INCLUDE_SDL_NET = Pattern.compile("#include\\s+[<\"]SDL_net\\.h[>\"]"); |
38 | 57 |
|
39 | 58 | private static final ArrayList<Pair<Pattern, String>> PATTERNS; |
40 | 59 |
|
41 | 60 | static { |
42 | 61 | PATTERNS = new ArrayList<>(); |
43 | | - PATTERNS.add(new Pair<>(INCLUDE_SDL, "-lSDL2")); |
44 | 62 | PATTERNS.add(new Pair<>(INCLUDE_ANDROID, "-landroid")); |
45 | 63 | PATTERNS.add(new Pair<>(INCLUDE_ANDROID_LOG, "-llog")); |
46 | 64 | PATTERNS.add(new Pair<>(INCLUDE_EGL, "-lEGL")); |
47 | 65 | PATTERNS.add(new Pair<>(INCLUDE_MATH, "-lm")); |
48 | | - PATTERNS.add(new Pair<>(INCLUDE_GLESV1_CM, "-lGLESv1_CM")); |
| 66 | + PATTERNS.add(new Pair<>(INCLUDE_GLES_V1_CM, "-lGLESv1_CM")); |
49 | 67 | PATTERNS.add(new Pair<>(INCLUDE_ATOMIC, "-latomic")); |
| 68 | + PATTERNS.add(new Pair<>(INCLUDE_GLES_V1_CM, "-lGLESv1_CM")); |
| 69 | + PATTERNS.add(new Pair<>(INCLUDE_GLES_V2, "-lGLESv2")); |
| 70 | + PATTERNS.add(new Pair<>(INCLUDE_OPEN_SLES, "-lOpenSLES")); |
| 71 | + PATTERNS.add(new Pair<>(INCLUDE_ZLIB, "-lz")); |
| 72 | + |
| 73 | + PATTERNS.add(new Pair<>(INCLUDE_SDL, "-lSDL2")); |
| 74 | + PATTERNS.add(new Pair<>(INCLUDE_SDL_TTF, "-lSDL2_ttf")); |
| 75 | + PATTERNS.add(new Pair<>(INCLUDE_SDL_IMAGE, "-lSDL2_image")); |
| 76 | + PATTERNS.add(new Pair<>(INCLUDE_SDL_MIXER, "-lSDL2_mixer")); |
| 77 | + PATTERNS.add(new Pair<>(INCLUDE_SDL_NET, "-lSDL2_net")); |
50 | 78 |
|
51 | 79 | } |
52 | 80 |
|
|
0 commit comments