diff --git a/CHANGELOG.md b/CHANGELOG.md index 609c5f1ae..3e03bbbd7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ Bugfixes: * Fixed the foot terminal font size not being parsed when written as `Font Name-size`, e.g. `Berkeley Mono-12`. (#2624, TerminalFont, Linux) * Fixed `/boot` being hidden by default on Haiku, where it is the system volume. (Disk, Haiku) * Improved Snapdragon X1/X2 model name detection on Linux. (#2625, CPU, Linux) +* Fixed the Android build failing with `GL/gl.h` not found, because the NDK ships the EGL headers that turned OpenGL detection on but not the desktop GL headers it includes. (OpenGL, Android) Logos: * Added filled Artix logo (#2631) diff --git a/CMakeLists.txt b/CMakeLists.txt index 75dda1e63..1c8c017da 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,6 +60,7 @@ endif() include(CheckIncludeFile) include(CheckFunctionExists) +include(CheckSymbolExists) if(LINUX) CHECK_INCLUDE_FILE("linux/version.h" HAVE_LINUX_VERSION_H) @@ -1736,9 +1737,18 @@ function(ff_lib_enable VARNAME PKGCONFIG_NAMES CMAKE_NAME) # [CMAKE_TARGET_NAME] endif() endif() else() - set(${VARNAME}_INCLUDE_DIRS ${${CMAKE_NAME}_INCLUDE_DIRS}) - set(${VARNAME}_LIBRARIES ${${CMAKE_NAME}_LIBRARIES}) - set(${VARNAME}_CFLAGS_OTHER ${${CMAKE_NAME}_CFLAGS_OTHER}) + # find_package modules disagree on how they name their result variables. Newer ones + # export _* (FindVulkan sets Vulkan_INCLUDE_DIRS), but older ones only + # set the upper-case form: FindFreetype sets FREETYPE_INCLUDE_DIRS and + # FREETYPE_LIBRARIES and has no Freetype_INCLUDE_DIRS at all. Assigning + # unconditionally would therefore wipe the include path the module had just + # provided, and the package would be "found" with nothing to compile against. + # Fill in only the gaps. + foreach(_FF_SUFFIX INCLUDE_DIRS LIBRARIES CFLAGS_OTHER) + if(NOT DEFINED ${VARNAME}_${_FF_SUFFIX} OR "${${VARNAME}_${_FF_SUFFIX}}" STREQUAL "") + set(${VARNAME}_${_FF_SUFFIX} ${${CMAKE_NAME}_${_FF_SUFFIX}}) + endif() + endforeach() endif() endif() endif() @@ -1857,9 +1867,11 @@ ff_lib_enable(OPENCL "OpenCL" "OpenCL" ) +# `Freetype` is the module CMake ships (Modules/FindFreetype.cmake); there is no FindFreeType2, so +# this name never resolved and only pkg-config could ever turn freetype on. ff_lib_enable(FREETYPE "freetype2" - "FreeType2" + "Freetype" ) ff_lib_enable(ELF "libelf" @@ -2158,7 +2170,17 @@ if(NOT WIN32) endif() endif() if(NOT ENABLE_WORDEXP) - message(STATUS "wordexp.h not found or disabled, glob used instead") + # wordexp.h is not the only thing that can be missing. bionic declares glob() and globfree() + # only from API 28, so an NDK build aimed at 24 has neither and a fallback that assumed glob + # would have nothing to call. The symbol is what has to be checked, not the header: + # is present at every level, it just declares nothing below 28. + check_symbol_exists("glob" "glob.h" HAVE_GLOB) + if(HAVE_GLOB) + target_compile_definitions(libfastfetch PUBLIC FF_HAVE_GLOB=1) + message(STATUS "wordexp.h not found or disabled, glob used instead") + else() + message(STATUS "neither wordexp.h nor glob.h is usable, config paths will not be expanded") + endif() endif() if(ENABLE_THREADS AND CMAKE_USE_PTHREADS_INIT) CHECK_INCLUDE_FILE("pthread_np.h" HAVE_PTHREAD_NP) diff --git a/src/common/android/dex.c b/src/common/android/dex.c index 199ea8f48..992217186 100644 --- a/src/common/android/dex.c +++ b/src/common/android/dex.c @@ -598,7 +598,7 @@ const char* ffDexStaticInts(const char* jarPath, const FFDexStaticIntRequest* re [[gnu::cleanup(wrapDexMapping)]] FFDexMapping mapping = {}; { - FF_AUTO_CLOSE_FD const int fd = open(jarPath, O_RDONLY | O_CLOEXEC); + FF_AUTO_CLOSE_FD int fd = open(jarPath, O_RDONLY | O_CLOEXEC); if (fd < 0) { FF_DEBUG("open(%s) failed: %s", jarPath, strerror(errno)); return "open(jar) failed"; diff --git a/src/common/impl/io_unix.c b/src/common/impl/io_unix.c index 36cbe53f0..2bd8abac2 100644 --- a/src/common/impl/io_unix.c +++ b/src/common/impl/io_unix.c @@ -17,7 +17,7 @@ #if FF_HAVE_WORDEXP #include -#else +#elif FF_HAVE_GLOB #include #endif @@ -112,7 +112,7 @@ bool ffPathExpandEnv(const char* in, FFstrbuf* out) { wordfree(&exp); -#else +#elif FF_HAVE_GLOB glob_t gb; if (glob(in, GLOB_NOSORT @@ -134,6 +134,10 @@ bool ffPathExpandEnv(const char* in, FFstrbuf* out) { globfree(&gb); +#else + + FF_UNUSED(in, out) + #endif return result; diff --git a/src/detection/opengl/opengl_linux.c b/src/detection/opengl/opengl_linux.c index f21a3b6e0..a8dd680d7 100644 --- a/src/detection/opengl/opengl_linux.c +++ b/src/detection/opengl/opengl_linux.c @@ -6,8 +6,11 @@ #include #if __ANDROID__ && !defined(FF_HAVE_EGL) - // On Android, installing OpenGL headers is enough (mesa-dev) - #if __has_include() + // On Android the EGL headers ship with the NDK, but the desktop GL ones only come from mesa-dev, + // which a plain NDK build does not have. The block below includes , so that is the + // header to probe: probing turns this on for every NDK build and then fails to + // compile. Termux installs mesa-dev, so it still gets the EGL path. + #if __has_include() && __has_include() #define FF_HAVE_EGL 1 #endif #endif