Jamepad icon indicating copy to clipboard operation
Jamepad copied to clipboard

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

Open SonicGDX opened this issue 1 year ago • 1 comments

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 avatar Jun 07 '24 13:06 SonicGDX

Resolved in #23

SonicGDX avatar Jun 10 '24 13:06 SonicGDX