include/LibreOfficeKit/LibreOfficeKit.h | 89 +++++++++++- libreofficekit/CppunitTest_libreofficekit_tiledrendering.mk | 4 libreofficekit/Library_libreofficekitgtk.mk | 4 libreofficekit/Module_libreofficekit.mk | 7 libreofficekit/StaticLibrary_libreofficekit.mk | 16 -- libreofficekit/source/shim.c | 82 ----------- smoketest/Executable_libtest.mk | 4 7 files changed, 91 insertions(+), 115 deletions(-)
New commits: commit 3bf863a1935d1eaba0b074434d0a32e849034e68 Author: Andrzej Hunt <andrzej.h...@collabora.com> Date: Mon Jul 28 09:02:25 2014 +0200 DO NOT MERGE: reenable LOK tiled rendering test (BRANCH ONLY). Change-Id: Ica4e570cafa25f4c642016608d8d510e668ed701 diff --git a/libreofficekit/Module_libreofficekit.mk b/libreofficekit/Module_libreofficekit.mk index 075cbdd..256068d 100644 --- a/libreofficekit/Module_libreofficekit.mk +++ b/libreofficekit/Module_libreofficekit.mk @@ -15,9 +15,9 @@ $(eval $(call gb_Module_add_targets,libreofficekit,\ Executable_lokconf_init \ )) -# $(eval $(call gb_Module_add_check_targets,libreofficekit,\ -# CppunitTest_libreofficekit_tiledrendering \ -# )) +$(eval $(call gb_Module_add_check_targets,libreofficekit,\ + CppunitTest_libreofficekit_tiledrendering \ +)) ifneq ($(ENABLE_GTK),) $(eval $(call gb_Module_add_targets,libreofficekit,\ commit 45dd1ce04b5a684ea36f47111bc16cc3f2bbd7e6 Author: Andrzej Hunt <andrzej.h...@collabora.com> Date: Mon Jul 28 09:01:59 2014 +0200 Kill the libreofficekit static library / shim.c. It looks like the cleanest method of getting lok_init into the LibreOfficeKit.h header (in a c89 compatible way) is to have it as a static function. Unfortunately this provokes unused function warnings where lok_init doesn't get used. (inline is only available in C99 or later -- this is actually available on Linux which is the only place that we can actually use lok_init anyways currently, however given we have to keep c89 for the C code (for MSVC) compatibility, selectively enabling c99 would likely be more messy.) Change-Id: I0493e7a68ed5397479220bb6ba8c3db870b6dd32 diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h index 675eabc..7d88528 100644 --- a/include/LibreOfficeKit/LibreOfficeKit.h +++ b/include/LibreOfficeKit/LibreOfficeKit.h @@ -105,7 +105,94 @@ struct _LibreOfficeKitDocumentClass #endif // LOK_USE_UNSTABLE_API }; -LibreOfficeKit* lok_init (const char* pInstallPath); +#ifdef LINUX + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include <dlfcn.h> +#ifdef AIX +# include <sys/ldr.h> +#endif + +#define TARGET_LIB "lib" "sofficeapp" ".so" +#define TARGET_MERGED_LIB "lib" "mergedlo" ".so" + +typedef LibreOfficeKit *(HookFunction)( const char *install_path); + + +#if defined(__GNUC__) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wunused-function" +#endif + +#if defined(__clang__) +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wunused-function" +#endif + +static LibreOfficeKit *lok_init( const char *install_path ) +{ + char *imp_lib; + size_t partial_length; + void *dlhandle; + HookFunction *pSym; + + if (!install_path) + return NULL; + + // allocate large enough buffer + partial_length = strlen(install_path); + imp_lib = (char *) malloc(partial_length + sizeof(TARGET_LIB) + sizeof(TARGET_MERGED_LIB) + 2); + if (!imp_lib) + { + fprintf( stderr, "failed to open library : not enough memory\n"); + return NULL; + } + + strcpy(imp_lib, install_path); + + imp_lib[partial_length++] = '/'; + strcpy(imp_lib + partial_length, TARGET_LIB); + + dlhandle = dlopen(imp_lib, RTLD_LAZY); + if (!dlhandle) + { + strcpy(imp_lib + partial_length, TARGET_MERGED_LIB); + + dlhandle = dlopen(imp_lib, RTLD_LAZY); + if (!dlhandle) + { + fprintf(stderr, "failed to open library '%s' or '%s' in '%s/'\n", + TARGET_LIB, TARGET_MERGED_LIB, install_path); + free(imp_lib); + return NULL; + } + } + + pSym = (HookFunction *) dlsym( dlhandle, "libreofficekit_hook" ); + if (!pSym) + { + fprintf( stderr, "failed to find hook in library '%s'\n", imp_lib ); + dlclose( dlhandle ); + free( imp_lib ); + return NULL; + } + + free( imp_lib ); + return pSym( install_path ); +} + +#if defined(__GNUC__) +# pragma GCC diagnostic pop +#endif + +#if defined(__clang__) +# pragma clang diagnostic pop +#endif + +#endif // not LINUX => port me ! #ifdef __cplusplus } diff --git a/libreofficekit/CppunitTest_libreofficekit_tiledrendering.mk b/libreofficekit/CppunitTest_libreofficekit_tiledrendering.mk index 9159a24..acc708f 100644 --- a/libreofficekit/CppunitTest_libreofficekit_tiledrendering.mk +++ b/libreofficekit/CppunitTest_libreofficekit_tiledrendering.mk @@ -41,10 +41,6 @@ endif $(eval $(call gb_CppunitTest_use_sdk_api,libreofficekit_tiledrendering)) -$(eval $(call gb_CppunitTest_use_static_libraries,libreofficekit_tiledrendering,\ - libreofficekit \ -)) - $(eval $(call gb_CppunitTest_use_ure,libreofficekit_tiledrendering)) #$(eval $(call gb_CppunitTest_use_vcl,libreofficekit_tiledrendering)) diff --git a/libreofficekit/Library_libreofficekitgtk.mk b/libreofficekit/Library_libreofficekitgtk.mk index be485cd..bcf1a5b 100644 --- a/libreofficekit/Library_libreofficekitgtk.mk +++ b/libreofficekit/Library_libreofficekitgtk.mk @@ -14,10 +14,6 @@ $(eval $(call gb_Library_use_externals,libreofficekitgtk,\ gtk \ )) -$(eval $(call gb_Library_use_static_libraries,libreofficekitgtk,\ - libreofficekit \ -)) - $(eval $(call gb_Library_add_cobjects,libreofficekitgtk,\ libreofficekit/source/gtk/lokdocview \ )) diff --git a/libreofficekit/Module_libreofficekit.mk b/libreofficekit/Module_libreofficekit.mk index 8523b1a..075cbdd 100644 --- a/libreofficekit/Module_libreofficekit.mk +++ b/libreofficekit/Module_libreofficekit.mk @@ -12,7 +12,6 @@ $(eval $(call gb_Module_Module,libreofficekit)) ifeq ($(OS),LINUX) $(eval $(call gb_Module_add_targets,libreofficekit,\ - StaticLibrary_libreofficekit \ Executable_lokconf_init \ )) diff --git a/libreofficekit/StaticLibrary_libreofficekit.mk b/libreofficekit/StaticLibrary_libreofficekit.mk deleted file mode 100644 index 7a82670..0000000 --- a/libreofficekit/StaticLibrary_libreofficekit.mk +++ /dev/null @@ -1,16 +0,0 @@ -# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- -# -# This file is part of the LibreOffice project. -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# - -$(eval $(call gb_StaticLibrary_StaticLibrary,libreofficekit)) - -$(eval $(call gb_StaticLibrary_add_cobjects,libreofficekit,\ - libreofficekit/source/shim \ -)) - -# vim: set noet sw=4 ts=4: diff --git a/libreofficekit/source/shim.c b/libreofficekit/source/shim.c deleted file mode 100644 index b533a61..0000000 --- a/libreofficekit/source/shim.c +++ /dev/null @@ -1,82 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ - -#ifdef LINUX - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include <sal/types.h> -#include <LibreOfficeKit/LibreOfficeKit.h> - -#include <dlfcn.h> -#ifdef AIX -# include <sys/ldr.h> -#endif - -#define TARGET_LIB "lib" "sofficeapp" ".so" -#define TARGET_MERGED_LIB "lib" "mergedlo" ".so" - -typedef LibreOfficeKit *(HookFunction)( const char *install_path); - -SAL_DLLPUBLIC_EXPORT LibreOfficeKit *lok_init( const char *install_path ) -{ - char *imp_lib; - size_t partial_length; - void *dlhandle; - HookFunction *pSym; - - if (!install_path) - return NULL; - - // allocate large enough buffer - partial_length = strlen(install_path); - imp_lib = (char *) malloc(partial_length + sizeof(TARGET_LIB) + sizeof(TARGET_MERGED_LIB) + 2); - if (!imp_lib) - { - fprintf( stderr, "failed to open library : not enough memory\n"); - return NULL; - } - - strcpy(imp_lib, install_path); - - imp_lib[partial_length++] = '/'; - strcpy(imp_lib + partial_length, TARGET_LIB); - - dlhandle = dlopen(imp_lib, RTLD_LAZY); - if (!dlhandle) - { - strcpy(imp_lib + partial_length, TARGET_MERGED_LIB); - - dlhandle = dlopen(imp_lib, RTLD_LAZY); - if (!dlhandle) - { - fprintf(stderr, "failed to open library '%s' or '%s' in '%s/'\n", TARGET_LIB, TARGET_MERGED_LIB, install_path); - free(imp_lib); - return NULL; - } - } - - pSym = (HookFunction *) dlsym( dlhandle, "libreofficekit_hook" ); - if (!pSym) - { - fprintf( stderr, "failed to find hook in library '%s'\n", imp_lib ); - dlclose( dlhandle ); - free( imp_lib ); - return NULL; - } - - free( imp_lib ); - return pSym( install_path ); -} - -#endif // not LINUX => port me ! - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/smoketest/Executable_libtest.mk b/smoketest/Executable_libtest.mk index 881e604..3b3bd16 100644 --- a/smoketest/Executable_libtest.mk +++ b/smoketest/Executable_libtest.mk @@ -17,10 +17,6 @@ $(eval $(call gb_Executable_use_libraries,libtest,\ $(gb_UWINAPI) \ )) -$(eval $(call gb_Executable_use_static_libraries,libtest,\ - libreofficekit \ -)) - $(eval $(call gb_Executable_add_libs,libtest,\ -ldl \ -pthread \ _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits