Skip to content

Commit f49b254

Browse files
author
Marc-André Moreau
committed
Android build fixes
1 parent c9f78b2 commit f49b254

File tree

4 files changed

+36
-5
lines changed

4 files changed

+36
-5
lines changed

CMakeLists.txt

+32-3
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ option(BUILD_MANPAGES "Build man pages" ON)
3737
option(BUILD_SHARED_LIBS "Build a shared library" ON)
3838
option(BUILD_STATIC_LIBS "Build a static library" ON)
3939
option(BUILD_TOOLS "Build tool programs" ON)
40+
option(BUILD_TESTS "Build test programs" ON)
4041
option(FUZZ "Enable fuzzing instrumentation" OFF)
4142
option(LIBFUZZER "Build libfuzzer harnesses" OFF)
4243
option(USE_HIDAPI "Use hidapi as the HID backend" OFF)
@@ -70,6 +71,9 @@ if(NOT MSVC)
7071
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
7172
set(FIDO_CFLAGS "${FIDO_CFLAGS} -D_GNU_SOURCE")
7273
set(FIDO_CFLAGS "${FIDO_CFLAGS} -D_DEFAULT_SOURCE")
74+
elseif(CMAKE_SYSTEM_NAME STREQUAL "Android")
75+
set(FIDO_CFLAGS "${FIDO_CFLAGS} -D_GNU_SOURCE")
76+
set(FIDO_CFLAGS "${FIDO_CFLAGS} -D_DEFAULT_SOURCE")
7377
elseif(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" OR
7478
CMAKE_SYSTEM_NAME STREQUAL "MidnightBSD")
7579
set(FIDO_CFLAGS "${FIDO_CFLAGS} -D__BSD_VISIBLE=1")
@@ -110,6 +114,11 @@ check_symbol_exists(sysconf unistd.h HAVE_SYSCONF)
110114
check_symbol_exists(timespecsub sys/time.h HAVE_TIMESPECSUB)
111115
check_symbol_exists(timingsafe_bcmp string.h HAVE_TIMINGSAFE_BCMP)
112116

117+
if(CMAKE_SYSTEM_NAME STREQUAL "Android")
118+
set(HAVE_EXPLICIT_BZERO OFF)
119+
add_definitions(-DCRYPTO_EXPLICIT_BZERO)
120+
endif()
121+
113122
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
114123
try_compile(HAVE_POSIX_IOCTL
115124
"${CMAKE_CURRENT_BINARY_DIR}/posix_ioctl_check.o"
@@ -229,6 +238,23 @@ else()
229238
set(BASE_LIBRARIES ${BASE_LIBRARIES} rt)
230239
endif()
231240
endif()
241+
elseif(CMAKE_SYSTEM_NAME STREQUAL "Android")
242+
if(UDEV_ROOT_DIR)
243+
list(PREPEND CMAKE_FIND_ROOT_PATH ${UDEV_ROOT_DIR})
244+
endif()
245+
246+
find_path(UDEV_INCLUDE_DIR
247+
NAMES "libudev.h")
248+
249+
find_library(UDEV_LIBRARY
250+
NAMES libudev-zero.a libudev)
251+
252+
add_library(udev STATIC IMPORTED GLOBAL)
253+
set_target_properties(udev PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${UDEV_INCLUDE_DIR}")
254+
set_target_properties(udev PROPERTIES IMPORTED_LOCATION "${UDEV_LIBRARY}")
255+
256+
set(UDEV_INCLUDE_DIRS "${UDEV_INCLUDE_DIR}")
257+
set(UDEV_LIBRARIES "udev")
232258
else()
233259
set(NFC_LINUX OFF)
234260
endif()
@@ -436,10 +462,13 @@ else()
436462
message(FATAL_ERROR "Nothing to build (BUILD_*_LIBS=OFF)")
437463
endif()
438464

439-
enable_testing()
440-
441465
subdirs(src)
442-
subdirs(regress)
466+
467+
if(BUILD_TESTS)
468+
enable_testing()
469+
subdirs(regress)
470+
endif()
471+
443472
if(BUILD_EXAMPLES)
444473
subdirs(examples)
445474
endif()

openbsd-compat/explicit_bzero.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
#include "openbsd-compat.h"
99

10-
#if !defined(HAVE_EXPLICIT_BZERO) && !defined(_WIN32)
10+
#if !defined(HAVE_EXPLICIT_BZERO) && !defined(_WIN32) && !defined(CRYPTO_EXPLICIT_BZERO)
1111

1212
#include <string.h>
1313

openbsd-compat/openbsd-compat.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ char *strsep(char **, const char *);
6262
void *recallocarray(void *, size_t, size_t, size_t);
6363
#endif
6464

65-
#if !defined(HAVE_EXPLICIT_BZERO)
65+
#if !defined(HAVE_EXPLICIT_BZERO) || defined(CRYPTO_EXPLICIT_BZERO)
6666
void explicit_bzero(void *, size_t);
6767
#endif
6868

src/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ elseif(APPLE)
7171
list(APPEND FIDO_SOURCES hid_osx.c)
7272
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
7373
list(APPEND FIDO_SOURCES hid_linux.c hid_unix.c)
74+
elseif(CMAKE_SYSTEM_NAME STREQUAL "Android")
75+
list(APPEND FIDO_SOURCES hid_linux.c hid_unix.c)
7476
elseif(CMAKE_SYSTEM_NAME STREQUAL "NetBSD")
7577
list(APPEND FIDO_SOURCES hid_netbsd.c hid_unix.c)
7678
elseif(CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")

0 commit comments

Comments
 (0)