You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@celix.apache.org by pn...@apache.org on 2019/04/27 09:33:18 UTC

[celix] branch develop updated: CELIX-426: Updates usage of custom fmemopen/open_memstream.

This is an automated email from the ASF dual-hosted git repository.

pnoltes pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/celix.git


The following commit(s) were added to refs/heads/develop by this push:
     new 73d22a0  CELIX-426: Updates usage of custom fmemopen/open_memstream.
73d22a0 is described below

commit 73d22a07daafd9a4dc2bd40cbb29925f4e435741
Author: Pepijn Noltes <pe...@gmail.com>
AuthorDate: Sat Apr 27 11:30:58 2019 +0200

    CELIX-426: Updates usage of custom fmemopen/open_memstream.
    
    Later version of OSX now do have the fmemopen and open_memstream functions as part of stdio.h.
    As result the check whether to use the custom fmemopen/open_memstream based on operating system does not work anymore.
    This has been replaced with a cmake check_function_exists call.
---
 .travis.yml                           |  2 +-
 libs/dfi/src/dyn_common.c             |  2 +-
 libs/dfi/test/dyn_interface_tests.cpp |  2 +-
 libs/dfi/test/dyn_message_tests.cpp   |  2 +-
 libs/utils/CMakeLists.txt             | 13 ++++++++++---
 5 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 7af9b80..9975aba 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -25,7 +25,7 @@ matrix:
          dist: trusty
          compiler: clang
        - os: osx
-         osx_image: xcode9.4
+         osx_image: xcode10.2
          compiler: clang
        - os: linux
          dist: trusty
diff --git a/libs/dfi/src/dyn_common.c b/libs/dfi/src/dyn_common.c
index ea8f425..45c6828 100644
--- a/libs/dfi/src/dyn_common.c
+++ b/libs/dfi/src/dyn_common.c
@@ -23,7 +23,7 @@
 #include <ctype.h>
 #include <stdbool.h>
 
-#if defined(BSD) || defined(__APPLE__)  || defined(ANDROID)
+#if NO_MEMSTREAM_AVAILABLE
 #include "open_memstream.h"
 #include "fmemopen.h"
 #endif
diff --git a/libs/dfi/test/dyn_interface_tests.cpp b/libs/dfi/test/dyn_interface_tests.cpp
index df9752f..5220d51 100644
--- a/libs/dfi/test/dyn_interface_tests.cpp
+++ b/libs/dfi/test/dyn_interface_tests.cpp
@@ -30,7 +30,7 @@ extern "C" {
 #include "dyn_common.h"
 #include "dyn_interface.h"
 
-#if defined(BSD) || defined(__APPLE__) 
+#if NO_MEMSTREAM_AVAILABLE
 #include "open_memstream.h"
 #include "fmemopen.h"
 #endif
diff --git a/libs/dfi/test/dyn_message_tests.cpp b/libs/dfi/test/dyn_message_tests.cpp
index e310537..35c7f1d 100644
--- a/libs/dfi/test/dyn_message_tests.cpp
+++ b/libs/dfi/test/dyn_message_tests.cpp
@@ -31,7 +31,7 @@ extern "C" {
 #include "dyn_common.h"
 #include "dyn_message.h"
 
-#if defined(BSD) || defined(__APPLE__) 
+#if NO_MEMSTREAM_AVAILABLE
 #include "open_memstream.h"
 #include "fmemopen.h"
 #endif
diff --git a/libs/utils/CMakeLists.txt b/libs/utils/CMakeLists.txt
index a7e00ba..9784a34 100644
--- a/libs/utils/CMakeLists.txt
+++ b/libs/utils/CMakeLists.txt
@@ -17,9 +17,12 @@
 
 set(MEMSTREAM_SOURCES )
 set(MEMSTREAM_INCLUDES )
-if (APPLE OR ANDROID)
-    set(MEMSTREAM_SOURCES src/memstream/open_memstream.c  src/memstream/fmemopen.c)
-    set(MEMSTREAM_INCLUDE_DIR ${CMAKE_CURRENT_LIST_DIR}/include/memstream)
+include(CheckFunctionExists)
+#check_function_exists(fmemopen FMEMOPEN_EXISTS)
+check_function_exists(open_memstream OPEN_MEMSTREAM_EXISTS)
+if (NOT OPEN_MEMSTREAM_EXISTS)
+    set(MEMSTREAM_SOURCES src/memstream/open_memstream.c  src/memstream/fmemopen.c ${MEMSTREAM_SOURCES})
+    set(MEMSTREAM_INCLUDE_DIR ${CMAKE_CURRENT_LIST_DIR}/include/memstream ${MEMSTREAM_INCLUDE_DIR})
     install(DIRECTORY include/memstream/ DESTINATION include/celix/memstream COMPONENT framework)
 endif()
 
@@ -39,6 +42,10 @@ add_library(utils SHARED
 )
 set_target_properties(utils PROPERTIES OUTPUT_NAME "celix_utils")
 
+if (NOT OPEN_MEMSTREAM_EXISTS)
+    target_compile_definitions(utils PUBLIC -DNO_MEMSTREAM_AVAILABLE)
+endif ()
+
 if (ANDROID)
     target_compile_definitions(utils PRIVATE -DUSE_FILE32API)
 endif ()