Skip to content

Commit e19242d

Browse files
authored
Merge pull request #521 from fastfetch-cli/dev
Fix the `<wordexp.h>` not found compiler error on Android
2 parents 0291f35 + 86dffe7 commit e19242d

File tree

3 files changed

+25
-7
lines changed

3 files changed

+25
-7
lines changed

CMakeLists.txt

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -630,11 +630,6 @@ if(WIN32)
630630
target_compile_definitions(libfastfetch PUBLIC WIN32_LEAN_AND_MEAN=1)
631631
endif()
632632

633-
CHECK_INCLUDE_FILE("utmpx.h" HAVE_UTMPX_H)
634-
if(HAVE_UTMPX_H)
635-
target_compile_definitions(libfastfetch PRIVATE FF_HAVE_UTMPX_H)
636-
endif()
637-
638633
if(HAVE_WCWIDTH)
639634
target_compile_definitions(libfastfetch PRIVATE FF_HAVE_WCWIDTH)
640635
endif()
@@ -829,6 +824,20 @@ elseif(BSD)
829824
target_link_libraries(libfastfetch
830825
PRIVATE "usbhid"
831826
)
827+
elseif(ANDROID)
828+
CHECK_LIBRARY_EXISTS(-l:libandroid-wordexp.a wordexp "" HAVE_LIBANDROID_WORDEXP_STATIC)
829+
if(HAVE_LIBANDROID_WORDEXP_STATIC)
830+
target_link_libraries(libfastfetch
831+
PRIVATE -l:libandroid-wordexp.a
832+
)
833+
else()
834+
CHECK_LIBRARY_EXISTS(android-wordexp wordexp "" HAVE_LIBANDROID_WORDEXP)
835+
if(HAVE_LIBANDROID_WORDEXP)
836+
target_link_libraries(libfastfetch
837+
PRIVATE android-wordexp
838+
)
839+
endif()
840+
endif()
832841
endif()
833842

834843
target_include_directories(libfastfetch

src/common/io/io_unix.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
#include "io.h"
22
#include "util/stringUtils.h"
3+
#include "util/unused.h"
34

45
#include <fcntl.h>
56
#include <sys/stat.h>
67
#include <termios.h>
78
#include <poll.h>
89
#include <dirent.h>
10+
11+
#if __has_include(<wordexp.h>)
912
#include <wordexp.h>
13+
#endif
1014

1115
static void createSubfolders(const char* fileName)
1216
{
@@ -108,9 +112,12 @@ bool ffPathExists(const char* path, FFPathType type)
108112
return false;
109113
}
110114

111-
bool ffPathExpandEnv(const char* in, FFstrbuf* out)
115+
bool ffPathExpandEnv(FF_MAYBE_UNUSED const char* in, FF_MAYBE_UNUSED FFstrbuf* out)
112116
{
113117
bool result = false;
118+
119+
#if __has_include(<wordexp.h>) // https://github.com/termux/termux-packages/pull/7056
120+
114121
wordexp_t exp;
115122
if(wordexp(in, &exp, WRDE_NOCMD) != 0)
116123
return false;
@@ -123,6 +130,8 @@ bool ffPathExpandEnv(const char* in, FFstrbuf* out)
123130

124131
wordfree(&exp);
125132

133+
#endif
134+
126135
return result;
127136
}
128137

src/detection/users/users_linux.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include "fastfetch.h"
22
#include "users.h"
33

4-
#if FF_HAVE_UTMPX_H
4+
#if __has_include(<utmpx.h>)
55
#include <utmpx.h>
66
#else
77
//for Android compatibility

0 commit comments

Comments
 (0)