Global (Android): fixes building on old API level

This commit is contained in:
Carter Li
2026-10-07 00:58:45 +08:00
parent 04a5c2d9d3
commit 10ca4f171e
5 changed files with 40 additions and 10 deletions
+1
View File
@@ -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)
+27 -5
View File
@@ -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 <PackageName>_* (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: <glob.h>
# 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)
+1 -1
View File
@@ -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";
+6 -2
View File
@@ -17,7 +17,7 @@
#if FF_HAVE_WORDEXP
#include <wordexp.h>
#else
#elif FF_HAVE_GLOB
#include <glob.h>
#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;
+5 -2
View File
@@ -6,8 +6,11 @@
#include <string.h>
#if __ANDROID__ && !defined(FF_HAVE_EGL)
// On Android, installing OpenGL headers is enough (mesa-dev)
#if __has_include(<EGL/egl.h>)
// 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 <GL/gl.h>, so that is the
// header to probe: probing <EGL/egl.h> 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(<EGL/egl.h>) && __has_include(<GL/gl.h>)
#define FF_HAVE_EGL 1
#endif
#endif