From e389e34c7e66b1cf070a3d2aff955a2cff7e95b1 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Wed, 1 Feb 2017 12:17:19 +0100 Subject: [PATCH] Fix build of C++ wrapper on Windows. --- coreapi/chat.c | 1 + coreapi/vcard.cc | 2 +- include/linphone/core.h | 2 +- include/linphone/core_utils.h | 4 ++-- include/linphone/friend.h | 2 +- include/linphone/friendlist.h | 4 ++-- wrappers/cpp/CMakeLists.txt | 2 +- wrappers/cpp/LinphoneCxxConfig.cmake.in | 17 +++++++++-------- wrappers/cpp/c_make_lists.mustache.in | 10 +++++++++- wrappers/cpp/class_header.mustache | 24 ++++++++++++++++++------ wrappers/cpp/genapixml.py | 1 - wrappers/cpp/genwrapper.py | 5 ++++- wrappers/cpp/object.hh | 18 +++++++++++++++--- 13 files changed, 64 insertions(+), 28 deletions(-) delete mode 120000 wrappers/cpp/genapixml.py diff --git a/coreapi/chat.c b/coreapi/chat.c index c5f1a729e..f35b74f53 100644 --- a/coreapi/chat.c +++ b/coreapi/chat.c @@ -27,6 +27,7 @@ #include "linphone/lpconfig.h" #include "belle-sip/belle-sip.h" #include "ortp/b64.h" +#include "linphone/wrapper_utils.h" #include #include diff --git a/coreapi/vcard.cc b/coreapi/vcard.cc index 2a30440ae..b56f89886 100644 --- a/coreapi/vcard.cc +++ b/coreapi/vcard.cc @@ -22,8 +22,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "belcard/belcard_parser.hpp" #include "sal/sal.h" #include -#include "linphone/core.h" #include "private.h" +#include "linphone/wrapper_utils.h" #define VCARD_MD5_HASH_SIZE 16 diff --git a/include/linphone/core.h b/include/linphone/core.h index 3218a01b8..6d336faf6 100644 --- a/include/linphone/core.h +++ b/include/linphone/core.h @@ -2167,7 +2167,7 @@ LINPHONE_PUBLIC void linphone_core_set_sip_transport_timeout(LinphoneCore *lc, i * @return The SIP transport timeout in milliseconds. * @ingroup media_parameters */ -int linphone_core_get_sip_transport_timeout(LinphoneCore *lc); +LINPHONE_PUBLIC int linphone_core_get_sip_transport_timeout(LinphoneCore *lc); /** * Enable or disable DNS SRV resolution. diff --git a/include/linphone/core_utils.h b/include/linphone/core_utils.h index fb669930a..09ed34c8a 100644 --- a/include/linphone/core_utils.h +++ b/include/linphone/core_utils.h @@ -83,12 +83,12 @@ LINPHONE_PUBLIC int linphone_core_stop_echo_tester(LinphoneCore *lc); * @ingroup IOS * Special function to warm up dtmf feeback stream. #linphone_core_stop_dtmf_stream must() be called before entering FG mode */ -void linphone_core_start_dtmf_stream(LinphoneCore* lc); +LINPHONE_PUBLIC void linphone_core_start_dtmf_stream(LinphoneCore* lc); /** * @ingroup IOS * Special function to stop dtmf feed back function. Must be called before entering BG mode */ -void linphone_core_stop_dtmf_stream(LinphoneCore* lc); +LINPHONE_PUBLIC void linphone_core_stop_dtmf_stream(LinphoneCore* lc); typedef bool_t (*LinphoneCoreIterateHook)(void *data); diff --git a/include/linphone/friend.h b/include/linphone/friend.h index 2e48ca96e..cead195f8 100644 --- a/include/linphone/friend.h +++ b/include/linphone/friend.h @@ -549,7 +549,7 @@ LINPHONE_PUBLIC void linphone_core_migrate_friends_from_rc_to_db(LinphoneCore *l * @param fr the linphone friend to save * @param lc the linphone core */ -void linphone_friend_save(LinphoneFriend *fr, LinphoneCore *lc); +LINPHONE_PUBLIC void linphone_friend_save(LinphoneFriend *fr, LinphoneCore *lc); /** * @} diff --git a/include/linphone/friendlist.h b/include/linphone/friendlist.h index 0e4ebb790..2989fcc95 100644 --- a/include/linphone/friendlist.h +++ b/include/linphone/friendlist.h @@ -252,7 +252,7 @@ LINPHONE_PUBLIC void linphone_friend_list_set_uri(LinphoneFriendList *list, cons * @param[in] list LinphoneFriendList object. * @param[in] rev The revision */ -void linphone_friend_list_update_revision(LinphoneFriendList *list, int rev); +LINPHONE_PUBLIC void linphone_friend_list_update_revision(LinphoneFriendList *list, int rev); /** * An object to handle the callbacks for LinphoneFriend synchronization. @@ -389,7 +389,7 @@ LINPHONE_PUBLIC void linphone_friend_list_synchronize_friends_from_server(Linpho * Goes through all the LinphoneFriend that are dirty and does a CardDAV PUT to update the server. * @param[in] list LinphoneFriendList object. */ -void linphone_friend_list_update_dirty_friends(LinphoneFriendList *list); +LINPHONE_PUBLIC void linphone_friend_list_update_dirty_friends(LinphoneFriendList *list); /** * Returns the LinphoneCore object attached to this LinphoneFriendList. diff --git a/wrappers/cpp/CMakeLists.txt b/wrappers/cpp/CMakeLists.txt index ad394876b..f1fbf2949 100644 --- a/wrappers/cpp/CMakeLists.txt +++ b/wrappers/cpp/CMakeLists.txt @@ -5,7 +5,7 @@ configure_file(LinphoneCxxConfig.cmake.in LinphoneCxxConfig.cmake @ONLY) add_custom_command(OUTPUT CMakeLists.txt include/linphone.hh COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/genwrapper.py" "${PROJECT_BINARY_DIR}/coreapi/help/doc/xml" - DEPENDS *.py *.mustache linphone-doc + DEPENDS abstractapi.py genwrapper.py class_header.mustache class_impl.mustache enums_header.mustache main_header.mustache linphone-doc "${PROJECT_BINARY_DIR}/coreapi/help/doc/xml/index.xml" "${CMAKE_CURRENT_BINARY_DIR}/c_make_lists.mustache" ) diff --git a/wrappers/cpp/LinphoneCxxConfig.cmake.in b/wrappers/cpp/LinphoneCxxConfig.cmake.in index b63749207..107edc651 100644 --- a/wrappers/cpp/LinphoneCxxConfig.cmake.in +++ b/wrappers/cpp/LinphoneCxxConfig.cmake.in @@ -25,15 +25,16 @@ # # It defines the following variables: # -# LINPHONE_CXX_FOUND - system has linphone++ -# LINPHONE_CXX_INCLUDE_DIRS - the linphone++ include directory -# LINPHONE_CXX_LIBRARIES - The libraries needed to use linphone++ -# LINPHONE_CXX_LDFLAGS - The linking flags needed to use linphone++ +# LINPHONECXX_FOUND - system has linphone++ +# LINPHONECXX_INCLUDE_DIRS - the linphone++ include directory +# LINPHONECXX_LIBRARIES - The libraries needed to use linphone++ +# LINPHONECXX_LDFLAGS - The linking flags needed to use linphone++ find_package(BelleSIP) +find_package(Linphone) include("${CMAKE_CURRENT_LIST_DIR}/LinphoneCxxTargets.cmake") -get_filename_component(LINPHONE_CXX_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) -set(LINPHONE_CXX_INCLUDE_DIRS "${LINPHONE_CXX_CMAKE_DIR}/../../../include") -set(LINPHONE_CXX_LDFLAGS "") -set(LINPHONE_CXX_LIBRARIES linphone++ ${BELLESIP_LIBRARIES}) +get_filename_component(LINPHONECXX_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) +set(LINPHONECXX_INCLUDE_DIRS "${LINPHONECXX_CMAKE_DIR}/../../../include" "${BELLESIP_INCLUDE_DIRS}" "${LINPHONE_INCLUDE_DIRS}") +set(LINPHONECXX_LDFLAGS "") +set(LINPHONECXX_LIBRARIES linphone++ ${BELLESIP_LIBRARIES} ${LINPHONE_LIBRARIES}) diff --git a/wrappers/cpp/c_make_lists.mustache.in b/wrappers/cpp/c_make_lists.mustache.in index 606621038..26d69e5d2 100644 --- a/wrappers/cpp/c_make_lists.mustache.in +++ b/wrappers/cpp/c_make_lists.mustache.in @@ -4,6 +4,8 @@ project(LinphoneCxx VERSION @LINPHONE_VERSION@) include(GNUInstallDirs) +find_package(BelleSIP REQUIRED) + set(CMAKE_CXX_STANDARD 11) set(GENERATED_SOURCES @@ -30,8 +32,13 @@ set(HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/include/object.hh ) +add_definitions("-DLINPHONECXX_EXPORTS") add_library(linphone++ SHARED ${SOURCES}) -target_link_libraries(linphone++ PRIVATE @PROJECT_BINARY_DIR@/coreapi/liblinphone.so.@LINPHONE_SO_VERSION@) +if(WIN32) + target_link_libraries(linphone++ PRIVATE @PROJECT_BINARY_DIR@/coreapi/${CMAKE_BUILD_TYPE}/linphone.lib ${BELLESIP_LIBRARIES}) +else() + target_link_libraries(linphone++ PRIVATE @PROJECT_BINARY_DIR@/coreapi/liblinphone.so.@LINPHONE_SO_VERSION@) +endif() target_include_directories(linphone++ PUBLIC include PRIVATE @PROJECT_SOURCE_DIR@/include @@ -42,6 +49,7 @@ set_target_properties(linphone++ ) install(TARGETS linphone++ EXPORT LinphoneCxxTargets + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ) install(FILES ${HEADERS} diff --git a/wrappers/cpp/class_header.mustache b/wrappers/cpp/class_header.mustache index 0e958924b..1ed4112ff 100644 --- a/wrappers/cpp/class_header.mustache +++ b/wrappers/cpp/class_header.mustache @@ -40,6 +40,18 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "linphone/linphonecore_utils.h" #include "linphone/wrapper_utils.h" +#ifndef LINPHONECXX_PUBLIC +#if defined(_MSC_VER) +#ifdef LINPHONECXX_EXPORTS +#define LINPHONECXX_PUBLIC __declspec(dllexport) +#else +#define LINPHONECXX_PUBLIC __declspec(dllimport) +#endif +#else +#define LINPHONECXX_PUBLIC +#endif +#endif + namespace linphone { {{#priorDeclarations}} @@ -58,21 +70,21 @@ namespace linphone { {{/isNotListener}} {{#ismonolistenable}} - LINPHONE_PUBLIC void setListener(const std::shared_ptr<{{{listenerClassName}}}> &listener); + LINPHONECXX_PUBLIC void setListener(const std::shared_ptr<{{{listenerClassName}}}> &listener); {{/ismonolistenable}} {{#ismultilistenable}} - LINPHONE_PUBLIC void addListener(std::shared_ptr<{{{listenerClassName}}}> &listener); - LINPHONE_PUBLIC void removeListener(std::shared_ptr<{{{listenerClassName}}}> &listener); + LINPHONECXX_PUBLIC void addListener(std::shared_ptr<{{{listenerClassName}}}> &listener); + LINPHONECXX_PUBLIC void removeListener(std::shared_ptr<{{{listenerClassName}}}> &listener); {{/ismultilistenable}} public: {{#isfactory}} - LINPHONE_PUBLIC std::shared_ptr createCore(const std::shared_ptr & cbs, const std::string & configPath, const std::string & factoryConfigPath) const; - LINPHONE_PUBLIC std::shared_ptr createCoreWithConfig(const std::shared_ptr & cbs, const std::shared_ptr & config) const; + LINPHONECXX_PUBLIC std::shared_ptr createCore(const std::shared_ptr & cbs, const std::string & configPath, const std::string & factoryConfigPath) const; + LINPHONECXX_PUBLIC std::shared_ptr createCoreWithConfig(const std::shared_ptr & cbs, const std::shared_ptr & config) const; {{/isfactory}} {{#isVcard}} - LINPHONE_PUBLIC std::shared_ptr &getVcard(); + LINPHONECXX_PUBLIC std::shared_ptr &getVcard(); {{/isVcard}} {{#methods}} diff --git a/wrappers/cpp/genapixml.py b/wrappers/cpp/genapixml.py deleted file mode 120000 index fbd079a11..000000000 --- a/wrappers/cpp/genapixml.py +++ /dev/null @@ -1 +0,0 @@ -../../tools/genapixml.py \ No newline at end of file diff --git a/wrappers/cpp/genwrapper.py b/wrappers/cpp/genwrapper.py index e1ea6b230..fd549f2af 100755 --- a/wrappers/cpp/genwrapper.py +++ b/wrappers/cpp/genwrapper.py @@ -21,6 +21,9 @@ import pystache import re import argparse import os +import sys +sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..', 'tools')) +print(sys.path) import genapixml as CApi import abstractapi as AbsApi @@ -215,7 +218,7 @@ class CppTranslator(object): methodElems['deprecated'] = 'LINPHONE_DEPRECATED ' if method.deprecated else '' methodDict = {} - methodDict['prototype'] = 'LINPHONE_PUBLIC {deprecated}{methodType}{return} {name}({params}){const}{semicolon}'.format(**methodElems) + methodDict['prototype'] = 'LINPHONECXX_PUBLIC {deprecated}{methodType}{return} {name}({params}){const}{semicolon}'.format(**methodElems) if genImpl: if not CppTranslator.is_ambigous_type(self, method.returnType): diff --git a/wrappers/cpp/object.hh b/wrappers/cpp/object.hh index b827bb631..0c7baa236 100644 --- a/wrappers/cpp/object.hh +++ b/wrappers/cpp/object.hh @@ -26,6 +26,18 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include #include +#ifndef LINPHONECXX_PUBLIC +#if defined(_MSC_VER) +#ifdef LINPHONECXX_EXPORTS +#define LINPHONECXX_PUBLIC __declspec(dllexport) +#else +#define LINPHONECXX_PUBLIC __declspec(dllimport) +#endif +#else +#define LINPHONECXX_PUBLIC +#endif +#endif + namespace linphone { class Object; @@ -79,8 +91,8 @@ namespace linphone { return *(T *)ptr; } } - void unsetData(const std::string &key); - bool dataExists(const std::string &key); + LINPHONECXX_PUBLIC void unsetData(const std::string &key); + LINPHONECXX_PUBLIC bool dataExists(const std::string &key); public: template @@ -117,7 +129,7 @@ namespace linphone { static std::list cStringArrayToCppList(const char **cArray); private: - std::map &getUserData() const; + LINPHONECXX_PUBLIC std::map &getUserData() const; template static void deleteSharedPtr(std::shared_ptr *ptr) {if (ptr != NULL) delete ptr;} static void deleteString(std::string *str) {if (str != NULL) delete str;}