Skip to content

Commit

Permalink
Android - Support cross-compiling System.Native for Android (dotnet/c…
Browse files Browse the repository at this point in the history
…orefx#15912)

* Last batch of fixes to get compilation to run on Android
* Move the MNTOPT_RO definition inside HAVE_MNTINFO to avoid a unused identifier


Commit migrated from dotnet/corefx@b5b0a77
  • Loading branch information
qmfrederik authored and stephentoub committed Feb 7, 2017
1 parent 1f06be1 commit e0b0ffa
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/libraries/Native/Unix/System.Native/CMakeLists.txt
Expand Up @@ -42,7 +42,7 @@ add_library(System.Native-Static
SET_TARGET_PROPERTIES(System.Native-Static PROPERTIES PREFIX "")
SET_TARGET_PROPERTIES(System.Native-Static PROPERTIES OUTPUT_NAME System.Native CLEAN_DIRECT_OUTPUT 1)

if (CMAKE_SYSTEM_NAME STREQUAL Linux)
if (CMAKE_SYSTEM_NAME STREQUAL Linux AND NOT CLR_CMAKE_PLATFORM_ANDROID)
target_link_libraries(System.Native rt)
endif ()

Expand Down
5 changes: 5 additions & 0 deletions src/libraries/Native/Unix/System.Native/pal_mount.cpp
Expand Up @@ -16,6 +16,11 @@
#include <sys/statfs.h>
#include <mntent.h>
#define STRING_BUFFER_SIZE 8192

// Android does not define MNTOPT_RO
#ifndef MNTOPT_RO
#define MNTOPT_RO "r"
#endif
#endif

static int32_t GetMountInfo(MountPointFound onFound)
Expand Down
7 changes: 7 additions & 0 deletions src/libraries/Native/Unix/configure.cmake
Expand Up @@ -294,6 +294,10 @@ set(HAVE_THREAD_SAFE_GETHOSTBYNAME_AND_GETHOSTBYADDR 0)
if (CMAKE_SYSTEM_NAME STREQUAL Linux)
set(CMAKE_REQUIRED_LIBRARIES rt)
set(HAVE_SUPPORT_FOR_DUAL_MODE_IPV4_PACKET_INFO 1)

if (CLR_CMAKE_PLATFORM_ANDROID)
set(HAVE_THREAD_SAFE_GETHOSTBYNAME_AND_GETHOSTBYADDR 1)
endif()
elseif (CMAKE_SYSTEM_NAME STREQUAL Darwin)
set(HAVE_THREAD_SAFE_GETHOSTBYNAME_AND_GETHOSTBYADDR 1)
endif ()
Expand Down Expand Up @@ -463,8 +467,11 @@ check_cxx_source_compiles(
HAVE_TCP_VAR_H
)

# If sys/cdefs is not included on Android, this check will fail because
# __BEGIN_DECLS is not defined
check_cxx_source_compiles(
"
#include <sys/cdefs.h>
#include <netinet/tcp.h>
int main() { int x = TCP_ESTABLISHED; return x; }
"
Expand Down

0 comments on commit e0b0ffa

Please sign in to comment.