libgdx / Jamepad

A better way to use gamepads in Java
Apache License 2.0
19 stars 11 forks source link

jniGen Gradle task getSdl2StaticLibs replacement regex doesn't include _ (underscore) character #30

Open SonicGDX opened 3 months ago

SonicGDX commented 3 months ago

This line for Windows x32, Windows x64, Linux x32, Linux x64, Linux x32 ARM and Linux x64 ARM matches text that has one or more characters matching this regex [a-zA-Z0-9\\.\\-/] and ending with libSDL2.a and replaces it with libSDL2.a's absolute path.

e.g. libraries += getSdl2StaticLibs('./SDL/build-linux32/').replaceAll("[a-zA-Z0-9\\.\\-/]+libSDL2.a", file("SDL/build-linux32/build/.libs/libSDL2.a").absolutePath)

The problem is, the underscore character (_) isn't included in that regex, so if text has underscore characters at the beginning they won't be replaced.

Here's an example of a problematic replacement result which causes build errors due to being an incorrect path:

Pre Replacement: -L/__w/Jamepad/Jamepad/SDL/lib /__w/Jamepad/Jamepad/SDL/lib/libSDL2.a -lm -ldl -lpthread

Post Replacement: -L/__w/Jamepad/Jamepad/SDL/lib /__/__w/Jamepad/Jamepad/SDL/build-linux32/build/.libs/libSDL2.a -lm -ldl -lpthread

What it probably should be after replacement: -L/__w/Jamepad/Jamepad/SDL/lib /__w/Jamepad/Jamepad/SDL/build-linux32/build/.libs/libSDL2.a -lm -ldl -lpthread

The problem is "/__" at the start of the path isn't being matched and replaced.

This can be solved by adding the _ character to the regex.

Blocking #23

SonicGDX commented 2 months ago

Resolved in #23