mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Restructure the src directory
It is split into - /libgnucash (for the non-gui bits) - /gnucash (for the gui) - /common (misc source files used by both) - /bindings (currently only holds python bindings) This is the first step in restructuring the code. It will need much more fine tuning later on.
This commit is contained in:
114
libgnucash/gnc-module/test/CMakeLists.txt
Normal file
114
libgnucash/gnc-module/test/CMakeLists.txt
Normal file
@@ -0,0 +1,114 @@
|
||||
|
||||
ADD_SUBDIRECTORY(mod-foo)
|
||||
ADD_SUBDIRECTORY(mod-bar)
|
||||
ADD_SUBDIRECTORY(mod-baz)
|
||||
ADD_SUBDIRECTORY(misc-mods)
|
||||
|
||||
SET(GNC_MODULE_TEST_INCLUDE_DIRS
|
||||
${CMAKE_BINARY_DIR}/common # for config.h
|
||||
${CMAKE_SOURCE_DIR}/libgnucash/gnc-module
|
||||
${CMAKE_SOURCE_DIR}/common/test-core
|
||||
${GLIB2_INCLUDE_DIRS}
|
||||
${GUILE_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
SET(GNC_MODULE_TEST_LIBS gnc-module test-core)
|
||||
|
||||
MACRO(ADD_GNC_MODULE_TEST _TARGET _SOURCE_FILES)
|
||||
GNC_ADD_TEST(${_TARGET} "${_SOURCE_FILES}" GNC_MODULE_TEST_INCLUDE_DIRS GNC_MODULE_TEST_LIBS)
|
||||
ENDMACRO()
|
||||
|
||||
FUNCTION(RUN_TEST_WITH_GUILE _TARGET _SOURCE_FILE)
|
||||
GET_GUILE_ENV()
|
||||
SET(CMAKE_COMMAND_TMP "")
|
||||
IF (${CMAKE_VERSION} VERSION_GREATER 3.1)
|
||||
SET(CMAKE_COMMAND_TMP ${CMAKE_COMMAND} -E env "${GUILE_ENV}")
|
||||
ENDIF()
|
||||
ADD_TEST(NAME ${_TARGET}
|
||||
COMMAND ${CMAKE_COMMAND_TMP}
|
||||
${GUILE_EXECUTABLE} -s ${_SOURCE_FILE}
|
||||
)
|
||||
|
||||
SET_TESTS_PROPERTIES(${_TARGET} PROPERTIES ENVIRONMENT "${GUILE_ENV};${ARGN}")
|
||||
ENDFUNCTION()
|
||||
|
||||
GNC_ADD_TEST_WITH_GUILE(test-load-c test-load-c.c GNC_MODULE_TEST_INCLUDE_DIRS GNC_MODULE_TEST_LIBS)
|
||||
|
||||
RUN_TEST_WITH_GUILE(test-load-scm ${CMAKE_CURRENT_SOURCE_DIR}/test-load-scm.in)
|
||||
|
||||
RUN_TEST_WITH_GUILE(test-load-deps ${CMAKE_CURRENT_SOURCE_DIR}/test-load-deps.in)
|
||||
|
||||
RUN_TEST_WITH_GUILE(test-scm-init ${CMAKE_CURRENT_SOURCE_DIR}/test-scm-init.in)
|
||||
|
||||
RUN_TEST_WITH_GUILE(test-scm-multi ${CMAKE_CURRENT_SOURCE_DIR}/test-scm-multi.in)
|
||||
|
||||
RUN_TEST_WITH_GUILE(test-scm-dynload ${CMAKE_CURRENT_SOURCE_DIR}/test-scm-dynload.in)
|
||||
|
||||
GNC_ADD_TEST_WITH_GUILE(test-modsysver test-modsysver.c
|
||||
GNC_MODULE_TEST_INCLUDE_DIRS GNC_MODULE_TEST_LIBS
|
||||
)
|
||||
GNC_ADD_TEST_WITH_GUILE(test-incompatdep test-incompatdep.c
|
||||
GNC_MODULE_TEST_INCLUDE_DIRS GNC_MODULE_TEST_LIBS
|
||||
)
|
||||
GNC_ADD_TEST_WITH_GUILE(test-agedver test-agedver.c
|
||||
GNC_MODULE_TEST_INCLUDE_DIRS GNC_MODULE_TEST_LIBS
|
||||
)
|
||||
|
||||
SET(_LIBDIR ${CMAKE_BINARY_DIR}/lib)
|
||||
IF (WIN32)
|
||||
SET(_LIBDIR ${CMAKE_BINARY_DIR}/bin)
|
||||
ENDIF()
|
||||
GNC_ADD_TEST(test-dynload test-dynload.c
|
||||
GNC_MODULE_TEST_INCLUDE_DIRS GNC_MODULE_TEST_LIBS
|
||||
LIBDIR=${_LIBDIR}
|
||||
)
|
||||
|
||||
SET(GUILE ${GUILE_EXECUTABLE})
|
||||
CONFIGURE_FILE(test-gwrapped-c.in test-gwrapped-c @ONLY)
|
||||
CONFIGURE_FILE(test-scm-module.in test-scm-module @ONLY)
|
||||
CONFIGURE_FILE(test-load-deps.in test-load-deps @ONLY)
|
||||
CONFIGURE_FILE(test-load-scm.in test-load-scm @ONLY)
|
||||
CONFIGURE_FILE(test-scm-dynload.in test-scm-dynload @ONLY)
|
||||
CONFIGURE_FILE(test-scm-init.in test-scm-init @ONLY)
|
||||
CONFIGURE_FILE(test-scm-multi.in test-scm-multi @ONLY)
|
||||
|
||||
FUNCTION(RUN_GUILE_SHELL_TEST _TARGET _SOURCE_FILE)
|
||||
GET_GUILE_ENV()
|
||||
SET(CMAKE_COMMAND_TMP "")
|
||||
IF (${CMAKE_VERSION} VERSION_GREATER 3.1)
|
||||
SET(CMAKE_COMMAND_TMP ${CMAKE_COMMAND} -E env "${GUILE_ENV}")
|
||||
ENDIF()
|
||||
ADD_TEST(NAME ${_TARGET}
|
||||
COMMAND ${CMAKE_COMMAND_TMP}
|
||||
${SHELL} ${_SOURCE_FILE}
|
||||
)
|
||||
SET_TESTS_PROPERTIES(${_TARGET} PROPERTIES ENVIRONMENT "${GUILE_ENV}")
|
||||
ENDFUNCTION()
|
||||
|
||||
RUN_GUILE_SHELL_TEST(test-gwrapped-c ${CMAKE_CURRENT_BINARY_DIR}/test-gwrapped-c)
|
||||
|
||||
RUN_GUILE_SHELL_TEST(test-scm-module ${CMAKE_CURRENT_BINARY_DIR}/test-scm-module)
|
||||
|
||||
SET(test_gnc_module_SOURCE_DIST
|
||||
test-agedver.c
|
||||
test-dynload.c
|
||||
test-incompatdep.c
|
||||
test-load-c.c
|
||||
test-modsysver.c
|
||||
)
|
||||
|
||||
SET(test_gnc_module_EXTRA_DIST
|
||||
README
|
||||
test-gwrapped-c.in
|
||||
test-load-deps.in
|
||||
test-load-scm.in
|
||||
test-scm-dynload.in
|
||||
test-scm-init.in
|
||||
test-scm-module.in
|
||||
test-scm-multi.in
|
||||
)
|
||||
|
||||
SET_LOCAL_DIST(test_gnc_module_DIST_local CMakeLists.txt Makefile.am README ${test_gnc_module_SOURCE_DIST} ${test_gnc_module_EXTRA_DIST})
|
||||
|
||||
SET(test_gnc_module_DIST ${test_gnc_module_DIST_local} ${misc_mods_DIST}
|
||||
${mod_bar_DIST} ${mod_baz_DIST} ${mod_foo_DIST} PARENT_SCOPE)
|
||||
72
libgnucash/gnc-module/test/Makefile.am
Normal file
72
libgnucash/gnc-module/test/Makefile.am
Normal file
@@ -0,0 +1,72 @@
|
||||
SUBDIRS = mod-foo mod-bar mod-baz misc-mods
|
||||
|
||||
LDADD = \
|
||||
${top_builddir}/common/test-core/libtest-core.la \
|
||||
../libgnc-module.la ${GLIB_LIBS} ${GUILE_LIBS}
|
||||
|
||||
AM_CPPFLAGS = \
|
||||
-I${top_srcdir}/common \
|
||||
-I${top_srcdir}/libgnucash/gnc-module \
|
||||
-I${top_srcdir}/common/test-core \
|
||||
-I${top_srcdir}/libgnucash/engine \
|
||||
${GUILE_CFLAGS} \
|
||||
${GLIB_CFLAGS}
|
||||
|
||||
TESTS = \
|
||||
test-load-c \
|
||||
test-load-scm \
|
||||
test-gwrapped-c \
|
||||
test-scm-module \
|
||||
test-scm-multi \
|
||||
test-load-deps \
|
||||
test-modsysver \
|
||||
test-incompatdep \
|
||||
test-agedver \
|
||||
test-dynload \
|
||||
test-scm-dynload \
|
||||
test-scm-init
|
||||
|
||||
GNC_TEST_DEPS = \
|
||||
--gnc-module-dir ${top_builddir}/libgnucash/gnc-module \
|
||||
--gnc-module-dir ${top_builddir}/libgnucash/gnc-module/test/mod-foo \
|
||||
--gnc-module-dir ${top_builddir}/libgnucash/gnc-module/test/mod-bar \
|
||||
--gnc-module-dir ${top_builddir}/libgnucash/gnc-module/test/mod-baz \
|
||||
--gnc-module-dir ${top_builddir}/libgnucash/gnc-module/test/misc-mods \
|
||||
--guile-load-dir ${top_builddir}/common/test-core \
|
||||
--guile-load-dir ${top_builddir}/libgnucash/gnc-module \
|
||||
--guile-load-dir ${top_srcdir}/libgnucash/gnc-module/test/mod-foo \
|
||||
--guile-load-dir ${top_srcdir}/libgnucash/gnc-module/test/mod-baz \
|
||||
--guile-load-dir ${top_srcdir}/libgnucash/gnc-module/test/mod-bar \
|
||||
--library-dir ${top_builddir}/libgnucash/core-utils \
|
||||
--library-dir ${top_builddir}/common/test-core \
|
||||
--library-dir ${top_builddir}/libgnucash/gnc-module \
|
||||
--library-dir ${top_builddir}/libgnucash/gnc-module/test/mod-foo \
|
||||
--library-dir ${top_builddir}/libgnucash/gnc-module/test/mod-bar \
|
||||
--library-dir ${top_builddir}/libgnucash/gnc-module/test/mod-baz
|
||||
|
||||
TESTS_ENVIRONMENT = \
|
||||
GUILE_WARN_DEPRECATED=no \
|
||||
GUILE="${GUILE}" \
|
||||
$(shell ${abs_top_srcdir}/common/gnc-test-env.pl --noexports ${GNC_TEST_DEPS})
|
||||
|
||||
check_PROGRAMS = \
|
||||
test-load-c \
|
||||
test-modsysver \
|
||||
test-incompatdep \
|
||||
test-agedver \
|
||||
test-dynload
|
||||
|
||||
test_dynload_LDFLAGS = ${GUILE_LIBS}
|
||||
|
||||
EXTRA_DIST = \
|
||||
test-gwrapped-c \
|
||||
test-load-deps \
|
||||
test-load-scm \
|
||||
test-scm-dynload \
|
||||
test-scm-init \
|
||||
test-scm-module \
|
||||
test-scm-multi \
|
||||
CMakeLists.txt
|
||||
|
||||
foo:
|
||||
${TESTS_ENVIRONMENT} strace -f -o xxx ./test-load-c
|
||||
13
libgnucash/gnc-module/test/README
Normal file
13
libgnucash/gnc-module/test/README
Normal file
@@ -0,0 +1,13 @@
|
||||
gnc-module tests:
|
||||
test-gwrapped-c.c: load a gnc-module from Scheme and test gwrapped fns
|
||||
test-load-c.c: load a gnc-module from C
|
||||
test-load-deps.{c,scm}: load a module that depends on another module
|
||||
test-load-scm.scm: basic module load test from Scheme
|
||||
test-scm-module.c: add a Scheme module load to the init fn and make sure
|
||||
the symbols are visible
|
||||
test-scm-multi.{c,scm}: load multiple gnc-modules from Scheme
|
||||
|
||||
|
||||
gnc-module support files:
|
||||
mod-{foo,bar,baz}/: sample modules for testing
|
||||
|
||||
16
libgnucash/gnc-module/test/misc-mods/CMakeLists.txt
Normal file
16
libgnucash/gnc-module/test/misc-mods/CMakeLists.txt
Normal file
@@ -0,0 +1,16 @@
|
||||
|
||||
INCLUDE_DIRECTORIES(
|
||||
${CMAKE_SOURCE_DIR}/libgnucash/gnc-module
|
||||
${GLIB2_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
ADD_LIBRARY(gncmod_agedver EXCLUDE_FROM_ALL agedver.c)
|
||||
TARGET_LINK_LIBRARIES(gncmod_agedver ${GLIB2_LDFLAGS})
|
||||
|
||||
ADD_LIBRARY(gncmod_futuremodsys EXCLUDE_FROM_ALL futuremodsys.c)
|
||||
TARGET_LINK_LIBRARIES(gncmod_futuremodsys ${GLIB2_LDFLAGS})
|
||||
|
||||
ADD_LIBRARY(gncmod_incompatdep EXCLUDE_FROM_ALL incompatdep.c)
|
||||
TARGET_LINK_LIBRARIES(gncmod_incompatdep gnc-module ${GLIB2_LDFLAGS})
|
||||
|
||||
SET_DIST_LIST(misc_mods_DIST CMakeLists.txt Makefile.am agedver.c futuremodsys.c incompatdep.c)
|
||||
30
libgnucash/gnc-module/test/misc-mods/Makefile.am
Normal file
30
libgnucash/gnc-module/test/misc-mods/Makefile.am
Normal file
@@ -0,0 +1,30 @@
|
||||
AM_CPPFLAGS = \
|
||||
-I${top_srcdir}/common \
|
||||
-I${top_srcdir}/libgnucash/gnc-module \
|
||||
${GLIB_CFLAGS} \
|
||||
${GUILE_CFLAGS}
|
||||
|
||||
LDADD = -L../.. -L../../.libs
|
||||
|
||||
PWD := $(shell pwd)
|
||||
check_LTLIBRARIES=libgncmod_futuremodsys.la libgncmod_incompatdep.la libgncmod_agedver.la
|
||||
|
||||
libgncmod_futuremodsys_la_SOURCES=futuremodsys.c
|
||||
libgncmod_futuremodsys_la_LDFLAGS=-rpath ${PWD} -avoid-version -module
|
||||
libgncmod_futuremodsys_la_LIBADD = \
|
||||
$(GLIB_LIBS)
|
||||
|
||||
libgncmod_incompatdep_la_SOURCES=incompatdep.c
|
||||
libgncmod_incompatdep_la_LDFLAGS=--rpath ${PWD} -avoid-version -module
|
||||
libgncmod_incompatdep_la_LIBADD = \
|
||||
../../libgnc-module.la \
|
||||
$(GLIB_LIBS)
|
||||
|
||||
libgncmod_agedver_la_SOURCES=agedver.c
|
||||
libgncmod_agedver_la_LDFLAGS=-rpath ${PWD} -avoid-version -module
|
||||
libgncmod_agedver_la_LIBADD = \
|
||||
$(GLIB_LIBS)
|
||||
|
||||
CLEANFILES = *.so* *.a
|
||||
|
||||
EXTRA_DIST = CMakeLists.txt
|
||||
59
libgnucash/gnc-module/test/misc-mods/agedver.c
Normal file
59
libgnucash/gnc-module/test/misc-mods/agedver.c
Normal file
@@ -0,0 +1,59 @@
|
||||
/* agedver.c : testing module age? */
|
||||
/********************************************************************\
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation; either version 2 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License*
|
||||
* along with this program; if not, contact: *
|
||||
* *
|
||||
* Free Software Foundation Voice: +1-617-542-5942 *
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org *
|
||||
* *
|
||||
\********************************************************************/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <gmodule.h>
|
||||
|
||||
#include "gnc-module.h"
|
||||
#include "gnc-module-api.h"
|
||||
|
||||
GNC_MODULE_API_DECL(libgncmod_agedver)
|
||||
|
||||
int libgncmod_agedver_gnc_module_system_interface = 0;
|
||||
|
||||
int libgncmod_agedver_gnc_module_current = 12;
|
||||
int libgncmod_agedver_gnc_module_age = 9;
|
||||
int libgncmod_agedver_gnc_module_revision = 0;
|
||||
|
||||
char *
|
||||
libgncmod_agedver_gnc_module_path(void)
|
||||
{
|
||||
return g_strdup("gnucash/agedver");
|
||||
}
|
||||
|
||||
char *
|
||||
libgncmod_agedver_gnc_module_description(void)
|
||||
{
|
||||
return g_strdup("this is a frequently extended module");
|
||||
}
|
||||
|
||||
int
|
||||
libgncmod_agedver_gnc_module_init(int refcount)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int
|
||||
libgncmod_agedver_gnc_module_end(int refcount)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
55
libgnucash/gnc-module/test/misc-mods/futuremodsys.c
Normal file
55
libgnucash/gnc-module/test/misc-mods/futuremodsys.c
Normal file
@@ -0,0 +1,55 @@
|
||||
/* futuremodsys.c : a gnucash module compiled with a future version of
|
||||
* the module system. gnucash should not be able to load it. but if
|
||||
* it doesn't notice that, the actual interface is compatible with
|
||||
* version 0 so it will load all the way before failing. */
|
||||
/********************************************************************\
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation; either version 2 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License*
|
||||
* along with this program; if not, contact: *
|
||||
* *
|
||||
* Free Software Foundation Voice: +1-617-542-5942 *
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org *
|
||||
* *
|
||||
\********************************************************************/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <gmodule.h>
|
||||
|
||||
#include "gnc-module-api.h"
|
||||
GNC_MODULE_API_DECL(libgncmod_futuremodsys)
|
||||
|
||||
int libgncmod_futuremodsys_gnc_module_system_interface = 123456;
|
||||
|
||||
int libgncmod_futuremodsys_gnc_module_current = 0;
|
||||
int libgncmod_futuremodsys_gnc_module_age = 0;
|
||||
int libgncmod_futuremodsys_gnc_module_revision = 0;
|
||||
|
||||
|
||||
char *
|
||||
libgncmod_futuremodsys_gnc_module_path(void)
|
||||
{
|
||||
return g_strdup("gnucash/futuremodsys");
|
||||
}
|
||||
|
||||
char *
|
||||
libgncmod_futuremodsys_gnc_module_description(void)
|
||||
{
|
||||
return g_strdup("this is a broken future module");
|
||||
}
|
||||
|
||||
int
|
||||
libgncmod_futuremodsys_gnc_module_init(int refcount)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
62
libgnucash/gnc-module/test/misc-mods/incompatdep.c
Normal file
62
libgnucash/gnc-module/test/misc-mods/incompatdep.c
Normal file
@@ -0,0 +1,62 @@
|
||||
/* incompatdep.c : a gnucash module that depends on an incompatible
|
||||
* version of another module. the initialization should fail. */
|
||||
/********************************************************************\
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation; either version 2 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License*
|
||||
* along with this program; if not, contact: *
|
||||
* *
|
||||
* Free Software Foundation Voice: +1-617-542-5942 *
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org *
|
||||
* *
|
||||
\********************************************************************/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <gmodule.h>
|
||||
|
||||
#include "gnc-module.h"
|
||||
#include "gnc-module-api.h"
|
||||
|
||||
GNC_MODULE_API_DECL(libgncmod_incompatdep)
|
||||
|
||||
int libgncmod_incompatdep_gnc_module_system_interface = 0;
|
||||
|
||||
int libgncmod_incompatdep_gnc_module_current = 0;
|
||||
int libgncmod_incompatdep_gnc_module_age = 0;
|
||||
int libgncmod_incompatdep_gnc_module_revision = 0;
|
||||
|
||||
|
||||
char *
|
||||
libgncmod_incompatdep_gnc_module_path(void)
|
||||
{
|
||||
return g_strdup("gnucash/incompatdep");
|
||||
}
|
||||
|
||||
char *
|
||||
libgncmod_incompatdep_gnc_module_description(void)
|
||||
{
|
||||
return g_strdup("this is a broken module");
|
||||
}
|
||||
|
||||
int
|
||||
libgncmod_incompatdep_gnc_module_init(int refcount)
|
||||
{
|
||||
if (gnc_module_load("gnucash/foo", 25))
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
24
libgnucash/gnc-module/test/mod-bar/CMakeLists.txt
Normal file
24
libgnucash/gnc-module/test/mod-bar/CMakeLists.txt
Normal file
@@ -0,0 +1,24 @@
|
||||
|
||||
IF (BUILDING_FROM_VCS)
|
||||
SET (SWIG_BAR_C ${CMAKE_CURRENT_BINARY_DIR}/swig-bar.c)
|
||||
GNC_ADD_SWIG_COMMAND (swig-bar-c ${SWIG_BAR_C} ${CMAKE_CURRENT_SOURCE_DIR}/bar.i bar.h)
|
||||
ELSE()
|
||||
SET (SWIG_BAR_C ${CMAKE_CURRENT_SOURCE_DIR}/swig-bar.c)
|
||||
ENDIF()
|
||||
|
||||
ADD_LIBRARY(bar EXCLUDE_FROM_ALL bar.c bar.h)
|
||||
ADD_LIBRARY(gncmodbar EXCLUDE_FROM_ALL gnc-mod-bar.c)
|
||||
SET_SOURCE_FILES_PROPERTIES (gnc-mod-bar.c PROPERTY OBJECT_DEPENDS ${SWIG_BAR_C})
|
||||
|
||||
TARGET_LINK_LIBRARIES(gncmodbar bar gnc-module)
|
||||
TARGET_INCLUDE_DIRECTORIES(gncmodbar PRIVATE
|
||||
${CMAKE_BINARY_DIR}/common
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${CMAKE_SOURCE_DIR}/common
|
||||
${CMAKE_SOURCE_DIR}/libgnucash/gnc-module
|
||||
${GLIB2_INCLUDE_DIRS}
|
||||
${GUILE_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
SET_DIST_LIST(mod_bar_DIST CMakeLists.txt Makefile.am bar.c gnucash/bar.scm bar.h bar.i gnc-mod-bar.c)
|
||||
43
libgnucash/gnc-module/test/mod-bar/Makefile.am
Normal file
43
libgnucash/gnc-module/test/mod-bar/Makefile.am
Normal file
@@ -0,0 +1,43 @@
|
||||
AM_CPPFLAGS = \
|
||||
-I${top_srcdir}/common \
|
||||
-I${top_srcdir}/libgnucash/gnc-module \
|
||||
${GUILE_CFLAGS} \
|
||||
${GLIB_CFLAGS}
|
||||
|
||||
PWD := $(shell pwd)
|
||||
check_LTLIBRARIES = libbar.la libgncmodbar.la
|
||||
|
||||
libbar_la_SOURCES = bar.c
|
||||
libbar_la_LDFLAGS = -rpath ${PWD}
|
||||
|
||||
# Make swig-bar.c for dist. It is an automatic dependency
|
||||
# of gnc-mod-bar.c
|
||||
noinst_HEADERS = \
|
||||
bar.h \
|
||||
swig-bar.c
|
||||
|
||||
libgncmodbar_la_SOURCES=gnc-mod-bar.c
|
||||
libgncmodbar_la_LDFLAGS=-rpath ${PWD} -avoid-version
|
||||
libgncmodbar_la_LIBADD=libbar.la \
|
||||
$(GUILE_LIBS) \
|
||||
$(GLIB_LIBS)
|
||||
|
||||
if BUILDING_FROM_VCS
|
||||
swig-bar.c: bar.i
|
||||
$(SWIG) -guile $(SWIG_ARGS) -Linkage module -o $@ $<
|
||||
if ! OS_WIN32
|
||||
if ! SWIG_DIST_FAIL
|
||||
if ! `grep "define scm_from_utf8_string" $@ > /dev/null 2>&1`; then \
|
||||
patch $@ $(top_srcdir)/common/swig-utf8.patch; \
|
||||
fi
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
EXTRA_DIST = \
|
||||
bar.i \
|
||||
gnucash/bar.scm \
|
||||
CMakeLists.txt
|
||||
|
||||
BUILT_SOURCES = swig-bar.c
|
||||
MAINTAINERCLEANFILES = swig-bar.c
|
||||
33
libgnucash/gnc-module/test/mod-bar/bar.c
Normal file
33
libgnucash/gnc-module/test/mod-bar/bar.c
Normal file
@@ -0,0 +1,33 @@
|
||||
/* libfoo. this is a dependency-free client library, equivalent to
|
||||
* the engine or some other core component that's ignorant of guile
|
||||
* and the module system */
|
||||
/********************************************************************\
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation; either version 2 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License*
|
||||
* along with this program; if not, contact: *
|
||||
* *
|
||||
* Free Software Foundation Voice: +1-617-542-5942 *
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org *
|
||||
* *
|
||||
\********************************************************************/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "bar.h"
|
||||
|
||||
int
|
||||
bar_hello(void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
28
libgnucash/gnc-module/test/mod-bar/bar.h
Normal file
28
libgnucash/gnc-module/test/mod-bar/bar.h
Normal file
@@ -0,0 +1,28 @@
|
||||
/* bar.h: header for a dependency-free, guile-free client lib */
|
||||
/********************************************************************\
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation; either version 2 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License*
|
||||
* along with this program; if not, contact: *
|
||||
* *
|
||||
* Free Software Foundation Voice: +1-617-542-5942 *
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org *
|
||||
* *
|
||||
\********************************************************************/
|
||||
|
||||
|
||||
#ifndef BAR_H
|
||||
#define BAR_H
|
||||
|
||||
int bar_hello(void);
|
||||
|
||||
#endif
|
||||
33
libgnucash/gnc-module/test/mod-bar/bar.i
Normal file
33
libgnucash/gnc-module/test/mod-bar/bar.i
Normal file
@@ -0,0 +1,33 @@
|
||||
/********************************************************************\
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation; either version 2 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License*
|
||||
* along with this program; if not, contact: *
|
||||
* *
|
||||
* Free Software Foundation Voice: +1-617-542-5942 *
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org *
|
||||
* *
|
||||
\********************************************************************/
|
||||
|
||||
%module sw_bar
|
||||
%{
|
||||
#include <bar.h>
|
||||
%}
|
||||
#if defined(SWIGGUILE)
|
||||
%{
|
||||
#include "guile-mappings.h"
|
||||
|
||||
SCM scm_init_sw_bar_module (void);
|
||||
%}
|
||||
#endif
|
||||
|
||||
int bar_hello(void);
|
||||
63
libgnucash/gnc-module/test/mod-bar/gnc-mod-bar.c
Normal file
63
libgnucash/gnc-module/test/mod-bar/gnc-mod-bar.c
Normal file
@@ -0,0 +1,63 @@
|
||||
/* gnc-mod-bar.c : the Gnucash plugin that wraps the library
|
||||
* 'libbar.so'. it does this by being linked against libbar.so */
|
||||
/********************************************************************\
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation; either version 2 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License*
|
||||
* along with this program; if not, contact: *
|
||||
* *
|
||||
* Free Software Foundation Voice: +1-617-542-5942 *
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org *
|
||||
* *
|
||||
\********************************************************************/
|
||||
|
||||
|
||||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
#include <gmodule.h>
|
||||
#include <libguile.h>
|
||||
|
||||
#include "gnc-module-api.h"
|
||||
#include "swig-bar.c"
|
||||
|
||||
GNC_MODULE_API_DECL(libgncmodbar)
|
||||
|
||||
int libgncmodbar_gnc_module_system_interface = 0;
|
||||
|
||||
int libgncmodbar_gnc_module_current = 0;
|
||||
int libgncmodbar_gnc_module_age = 0;
|
||||
int libgncmodbar_gnc_module_revision = 0;
|
||||
|
||||
char *
|
||||
libgncmodbar_gnc_module_path(void)
|
||||
{
|
||||
return g_strdup("gnucash/bar");
|
||||
}
|
||||
|
||||
char *
|
||||
libgncmodbar_gnc_module_description(void)
|
||||
{
|
||||
return g_strdup("this is a bar module");
|
||||
}
|
||||
|
||||
int
|
||||
libgncmodbar_gnc_module_init(int refcount)
|
||||
{
|
||||
/* publish the wrapped Scheme bindings for libbar */
|
||||
scm_init_sw_bar_module();
|
||||
scm_c_eval_string("(use-modules (sw_bar))");
|
||||
|
||||
/* use the Scheme "bar" module */
|
||||
scm_c_eval_string("(use-modules (gnucash bar))");
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
31
libgnucash/gnc-module/test/mod-bar/gnucash/bar.scm
Normal file
31
libgnucash/gnc-module/test/mod-bar/gnucash/bar.scm
Normal file
@@ -0,0 +1,31 @@
|
||||
;; test of a Scheme module called gnc-mod-bar, which should get
|
||||
;; loaded by the Gnucash module "bar"
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; This program is free software; you can redistribute it and/or
|
||||
;; modify it under the terms of the GNU General Public License as
|
||||
;; published by the Free Software Foundation; either version 2 of
|
||||
;; the License, or (at your option) any later version.
|
||||
;;
|
||||
;; This program is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
;;
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with this program; if not, contact:
|
||||
;;
|
||||
;; Free Software Foundation Voice: +1-617-542-5942
|
||||
;; 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
|
||||
;; Boston, MA 02110-1301, USA gnu@gnu.org
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
|
||||
(define-module (gnucash bar))
|
||||
|
||||
(export bar:scheme-hello)
|
||||
|
||||
(define (bar:scheme-hello)
|
||||
#t)
|
||||
|
||||
|
||||
|
||||
30
libgnucash/gnc-module/test/mod-baz/CMakeLists.txt
Normal file
30
libgnucash/gnc-module/test/mod-baz/CMakeLists.txt
Normal file
@@ -0,0 +1,30 @@
|
||||
|
||||
IF (BUILDING_FROM_VCS)
|
||||
SET (SWIG_BAZ_C ${CMAKE_CURRENT_BINARY_DIR}/swig-baz.c)
|
||||
GNC_ADD_SWIG_COMMAND (swig-baz-c ${SWIG_BAZ_C} ${CMAKE_CURRENT_SOURCE_DIR}/baz.i baz.h)
|
||||
ELSE()
|
||||
SET (SWIG_BAZ_C ${CMAKE_CURRENT_SOURCE_DIR}/swig-baz.c)
|
||||
ENDIF()
|
||||
|
||||
ADD_LIBRARY(baz EXCLUDE_FROM_ALL baz.c baz.h)
|
||||
TARGET_INCLUDE_DIRECTORIES(baz PRIVATE
|
||||
${CMAKE_SOURCE_DIR}/libgnucash/gnc-module/test/mod-foo
|
||||
)
|
||||
TARGET_LINK_LIBRARIES(baz foo)
|
||||
|
||||
|
||||
ADD_LIBRARY(gncmodbaz EXCLUDE_FROM_ALL gnc-mod-baz.c)
|
||||
SET_SOURCE_FILES_PROPERTIES (gnc-mod-baz.c PROPERTY OBJECT_DEPENDS ${SWIG_BAZ_C})
|
||||
|
||||
TARGET_LINK_LIBRARIES(gncmodbaz baz gnc-module)
|
||||
TARGET_INCLUDE_DIRECTORIES(gncmodbaz PRIVATE
|
||||
${CMAKE_BINARY_DIR}/common
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${CMAKE_SOURCE_DIR}/common
|
||||
${CMAKE_SOURCE_DIR}/libgnucash/gnc-module
|
||||
${GLIB2_INCLUDE_DIRS}
|
||||
${GUILE_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
SET_DIST_LIST(mod_baz_DIST CMakeLists.txt Makefile.am baz.c gnucash/baz.scm baz.h baz.i gnc-mod-baz.c)
|
||||
47
libgnucash/gnc-module/test/mod-baz/Makefile.am
Normal file
47
libgnucash/gnc-module/test/mod-baz/Makefile.am
Normal file
@@ -0,0 +1,47 @@
|
||||
AM_CPPFLAGS = \
|
||||
-I${top_srcdir}/common \
|
||||
-I${top_srcdir}/libgnucash/gnc-module \
|
||||
-I${top_srcdir}/libgnucash/gnc-module/test/mod-foo \
|
||||
${GLIB_CFLAGS} \
|
||||
${GUILE_CFLAGS}
|
||||
|
||||
PWD := $(shell pwd)
|
||||
check_LTLIBRARIES = libbaz.la libgncmodbaz.la
|
||||
|
||||
libbaz_la_SOURCES = baz.c
|
||||
libbaz_la_LDFLAGS = -rpath ${PWD}
|
||||
libbaz_la_LIBADD = ../mod-foo/libfoo.la
|
||||
|
||||
# Make swig-baz.c for dist. It is an automatic dependency
|
||||
# of gnc-mod-baz.c
|
||||
noinst_HEADERS = \
|
||||
baz.h \
|
||||
swig-baz.c
|
||||
|
||||
libgncmodbaz_la_SOURCES = gnc-mod-baz.c
|
||||
libgncmodbaz_la_LDFLAGS = -rpath ${PWD} -avoid-version
|
||||
libgncmodbaz_la_LIBADD = \
|
||||
libbaz.la \
|
||||
../../libgnc-module.la \
|
||||
$(GUILE_LIBS) \
|
||||
$(GLIB_LIBS)
|
||||
|
||||
if BUILDING_FROM_VCS
|
||||
swig-baz.c: baz.i
|
||||
$(SWIG) -guile $(SWIG_ARGS) -Linkage module -o $@ $<
|
||||
if ! OS_WIN32
|
||||
if ! SWIG_DIST_FAIL
|
||||
if ! `grep "define scm_from_utf8_string" $@ > /dev/null 2>&1`; then \
|
||||
patch $@ $(top_srcdir)/common/swig-utf8.patch; \
|
||||
fi
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
EXTRA_DIST = \
|
||||
baz.i \
|
||||
gnucash/baz.scm \
|
||||
CMakeLists.txt
|
||||
|
||||
BUILT_SOURCES = swig-baz.c
|
||||
MAINTAINERCLEANFILES = swig-baz.c
|
||||
34
libgnucash/gnc-module/test/mod-baz/baz.c
Normal file
34
libgnucash/gnc-module/test/mod-baz/baz.c
Normal file
@@ -0,0 +1,34 @@
|
||||
/* libbaz. this library depends on foo */
|
||||
/********************************************************************\
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation; either version 2 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License*
|
||||
* along with this program; if not, contact: *
|
||||
* *
|
||||
* Free Software Foundation Voice: +1-617-542-5942 *
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org *
|
||||
* *
|
||||
\********************************************************************/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "baz.h"
|
||||
#include "foo.h"
|
||||
|
||||
int
|
||||
baz_hello(void)
|
||||
{
|
||||
foo_hello();
|
||||
return 1;
|
||||
}
|
||||
|
||||
28
libgnucash/gnc-module/test/mod-baz/baz.h
Normal file
28
libgnucash/gnc-module/test/mod-baz/baz.h
Normal file
@@ -0,0 +1,28 @@
|
||||
/* baz.h: header for a dependency-free, guile-free client lib */
|
||||
/********************************************************************\
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation; either version 2 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License*
|
||||
* along with this program; if not, contact: *
|
||||
* *
|
||||
* Free Software Foundation Voice: +1-617-542-5942 *
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org *
|
||||
* *
|
||||
\********************************************************************/
|
||||
|
||||
|
||||
#ifndef BAZ_H
|
||||
#define BAZ_H
|
||||
|
||||
int baz_hello(void);
|
||||
|
||||
#endif
|
||||
33
libgnucash/gnc-module/test/mod-baz/baz.i
Normal file
33
libgnucash/gnc-module/test/mod-baz/baz.i
Normal file
@@ -0,0 +1,33 @@
|
||||
/********************************************************************\
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation; either version 2 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License*
|
||||
* along with this program; if not, contact: *
|
||||
* *
|
||||
* Free Software Foundation Voice: +1-617-542-5942 *
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org *
|
||||
* *
|
||||
\********************************************************************/
|
||||
|
||||
%module sw_baz
|
||||
%{
|
||||
#include <baz.h>
|
||||
%}
|
||||
#if defined(SWIGGUILE)
|
||||
%{
|
||||
#include "guile-mappings.h"
|
||||
|
||||
SCM scm_init_sw_baz_module (void);
|
||||
%}
|
||||
#endif
|
||||
|
||||
int baz_hello(void);
|
||||
72
libgnucash/gnc-module/test/mod-baz/gnc-mod-baz.c
Normal file
72
libgnucash/gnc-module/test/mod-baz/gnc-mod-baz.c
Normal file
@@ -0,0 +1,72 @@
|
||||
/* gnc-mod-baz.c : the Gnucash plugin that wraps the library
|
||||
* 'libbaz.so'. it does this by being linked against libbaz.so */
|
||||
/********************************************************************\
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation; either version 2 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License*
|
||||
* along with this program; if not, contact: *
|
||||
* *
|
||||
* Free Software Foundation Voice: +1-617-542-5942 *
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org *
|
||||
* *
|
||||
\********************************************************************/
|
||||
|
||||
|
||||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
#include <gmodule.h>
|
||||
#include <libguile.h>
|
||||
|
||||
#include "gnc-module.h"
|
||||
#include "gnc-module-api.h"
|
||||
#include "swig-baz.c"
|
||||
|
||||
GNC_MODULE_API_DECL(libgncmodbaz)
|
||||
|
||||
int libgncmodbaz_gnc_module_system_interface = 0;
|
||||
|
||||
int libgncmodbaz_gnc_module_current = 0;
|
||||
int libgncmodbaz_gnc_module_age = 0;
|
||||
int libgncmodbaz_gnc_module_revision = 0;
|
||||
|
||||
char *
|
||||
libgncmodbaz_gnc_module_path(void)
|
||||
{
|
||||
return g_strdup("gnucash/baz");
|
||||
}
|
||||
|
||||
char *
|
||||
libgncmodbaz_gnc_module_description(void)
|
||||
{
|
||||
return g_strdup("this is the baz module");
|
||||
}
|
||||
|
||||
int
|
||||
libgncmodbaz_gnc_module_init(int refcount)
|
||||
{
|
||||
/* load libfoo */
|
||||
if (gnc_module_load("gnucash/foo", 0))
|
||||
{
|
||||
/* publish the wrapped Scheme bindings for libbaz */
|
||||
scm_init_sw_baz_module();
|
||||
scm_c_eval_string("(use-modules (sw_baz))");
|
||||
|
||||
/* use the Scheme "baz" module */
|
||||
scm_c_eval_string("(use-modules (gnucash baz))");
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
31
libgnucash/gnc-module/test/mod-baz/gnucash/baz.scm
Normal file
31
libgnucash/gnc-module/test/mod-baz/gnucash/baz.scm
Normal file
@@ -0,0 +1,31 @@
|
||||
;; test of a Scheme module called gnc-mod-baz, which should get
|
||||
;; loaded by the Gnucash module "baz"
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; This program is free software; you can redistribute it and/or
|
||||
;; modify it under the terms of the GNU General Public License as
|
||||
;; published by the Free Software Foundation; either version 2 of
|
||||
;; the License, or (at your option) any later version.
|
||||
;;
|
||||
;; This program is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
;;
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with this program; if not, contact:
|
||||
;;
|
||||
;; Free Software Foundation Voice: +1-617-542-5942
|
||||
;; 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
|
||||
;; Boston, MA 02110-1301, USA gnu@gnu.org
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
|
||||
(define-module (gnucash baz))
|
||||
|
||||
(export baz:scheme-hello)
|
||||
|
||||
(define (baz:scheme-hello)
|
||||
#t)
|
||||
|
||||
|
||||
|
||||
24
libgnucash/gnc-module/test/mod-foo/CMakeLists.txt
Normal file
24
libgnucash/gnc-module/test/mod-foo/CMakeLists.txt
Normal file
@@ -0,0 +1,24 @@
|
||||
|
||||
IF (BUILDING_FROM_VCS)
|
||||
SET (SWIG_FOO_C ${CMAKE_CURRENT_BINARY_DIR}/swig-foo.c)
|
||||
GNC_ADD_SWIG_COMMAND (swig-foo-c ${SWIG_FOO_C} ${CMAKE_CURRENT_SOURCE_DIR}/foo.i foo.h)
|
||||
ELSE()
|
||||
SET (SWIG_FOO_C ${CMAKE_CURRENT_SOURCE_DIR}/swig-foo.c)
|
||||
ENDIF()
|
||||
|
||||
ADD_LIBRARY(foo EXCLUDE_FROM_ALL foo.c foo.h)
|
||||
ADD_LIBRARY(gncmodfoo EXCLUDE_FROM_ALL gnc-mod-foo.c)
|
||||
SET_SOURCE_FILES_PROPERTIES (gnc-mod-foo.c PROPERTY OBJECT_DEPENDS ${SWIG_FOO_C})
|
||||
|
||||
TARGET_LINK_LIBRARIES(gncmodfoo foo gnc-module)
|
||||
TARGET_INCLUDE_DIRECTORIES(gncmodfoo PRIVATE
|
||||
${CMAKE_BINARY_DIR}/common
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${CMAKE_SOURCE_DIR}/common
|
||||
${CMAKE_SOURCE_DIR}/libgnucash/gnc-module
|
||||
${GLIB2_INCLUDE_DIRS}
|
||||
${GUILE_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
SET_DIST_LIST(mod_foo_DIST CMakeLists.txt Makefile.am foo.i gnucash/foo.scm foo.c foo.h gnc-mod-foo.c)
|
||||
44
libgnucash/gnc-module/test/mod-foo/Makefile.am
Normal file
44
libgnucash/gnc-module/test/mod-foo/Makefile.am
Normal file
@@ -0,0 +1,44 @@
|
||||
AM_CPPFLAGS=\
|
||||
-I${top_srcdir}/common \
|
||||
-I${top_srcdir}/libgnucash/gnc-module \
|
||||
${GUILE_CFLAGS} \
|
||||
${GLIB_CFLAGS}
|
||||
|
||||
PWD := $(shell pwd)
|
||||
check_LTLIBRARIES=libfoo.la libgncmodfoo.la
|
||||
|
||||
libfoo_la_SOURCES = foo.c
|
||||
libfoo_la_LDFLAGS = -rpath ${PWD}
|
||||
|
||||
# Make swig-foo.c for dist. It is an automatic dependency
|
||||
# of gnc-mod-foo.c
|
||||
noinst_HEADERS = \
|
||||
foo.h \
|
||||
swig-foo.c
|
||||
|
||||
libgncmodfoo_la_SOURCES = gnc-mod-foo.c
|
||||
libgncmodfoo_la_LDFLAGS = -rpath ${PWD} -avoid-version
|
||||
libgncmodfoo_la_LIBADD = \
|
||||
libfoo.la \
|
||||
$(GUILE_LIBS) \
|
||||
$(GLIB_LIBS)
|
||||
|
||||
EXTRA_DIST = \
|
||||
foo.i \
|
||||
gnucash/foo.scm \
|
||||
CMakeLists.txt
|
||||
|
||||
if BUILDING_FROM_VCS
|
||||
swig-foo.c: foo.i
|
||||
$(SWIG) -guile $(SWIG_ARGS) -Linkage module -o $@ $<
|
||||
if ! OS_WIN32
|
||||
if ! SWIG_DIST_FAIL
|
||||
if ! `grep "define scm_from_utf8_string" $@ > /dev/null 2>&1`; then \
|
||||
patch $@ $(top_srcdir)/common/swig-utf8.patch; \
|
||||
fi
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
BUILT_SOURCES = swig-foo.c
|
||||
MAINTAINERCLEANFILES = swig-foo.c
|
||||
33
libgnucash/gnc-module/test/mod-foo/foo.c
Normal file
33
libgnucash/gnc-module/test/mod-foo/foo.c
Normal file
@@ -0,0 +1,33 @@
|
||||
/* libfoo. this is a dependency-free client library, equivalent to
|
||||
* the engine or some other core component that's ignorant of guile
|
||||
* and the module system */
|
||||
/********************************************************************\
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation; either version 2 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License*
|
||||
* along with this program; if not, contact: *
|
||||
* *
|
||||
* Free Software Foundation Voice: +1-617-542-5942 *
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org *
|
||||
* *
|
||||
\********************************************************************/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "foo.h"
|
||||
|
||||
int
|
||||
foo_hello(void)
|
||||
{
|
||||
return 10;
|
||||
}
|
||||
28
libgnucash/gnc-module/test/mod-foo/foo.h
Normal file
28
libgnucash/gnc-module/test/mod-foo/foo.h
Normal file
@@ -0,0 +1,28 @@
|
||||
/* foo.h: header for a dependency-free, guile-free client lib */
|
||||
/********************************************************************\
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation; either version 2 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License*
|
||||
* along with this program; if not, contact: *
|
||||
* *
|
||||
* Free Software Foundation Voice: +1-617-542-5942 *
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org *
|
||||
* *
|
||||
\********************************************************************/
|
||||
|
||||
|
||||
#ifndef FOO_H
|
||||
#define FOO_H
|
||||
|
||||
int foo_hello(void);
|
||||
|
||||
#endif
|
||||
33
libgnucash/gnc-module/test/mod-foo/foo.i
Normal file
33
libgnucash/gnc-module/test/mod-foo/foo.i
Normal file
@@ -0,0 +1,33 @@
|
||||
/********************************************************************\
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation; either version 2 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License*
|
||||
* along with this program; if not, contact: *
|
||||
* *
|
||||
* Free Software Foundation Voice: +1-617-542-5942 *
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org *
|
||||
* *
|
||||
\********************************************************************/
|
||||
|
||||
%module sw_foo
|
||||
%{
|
||||
#include <foo.h>
|
||||
%}
|
||||
#if defined(SWIGGUILE)
|
||||
%{
|
||||
#include "guile-mappings.h"
|
||||
|
||||
SCM scm_init_sw_foo_module (void);
|
||||
%}
|
||||
#endif
|
||||
|
||||
int foo_hello(void);
|
||||
63
libgnucash/gnc-module/test/mod-foo/gnc-mod-foo.c
Normal file
63
libgnucash/gnc-module/test/mod-foo/gnc-mod-foo.c
Normal file
@@ -0,0 +1,63 @@
|
||||
/* gnc-mod-foo.c : the Gnucash plugin that wraps the library
|
||||
* 'libfoo.so'. it does this by being linked against libfoo.so */
|
||||
/********************************************************************\
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation; either version 2 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License*
|
||||
* along with this program; if not, contact: *
|
||||
* *
|
||||
* Free Software Foundation Voice: +1-617-542-5942 *
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org *
|
||||
* *
|
||||
\********************************************************************/
|
||||
|
||||
|
||||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
#include <gmodule.h>
|
||||
#include <libguile.h>
|
||||
|
||||
#include "gnc-module-api.h"
|
||||
#include "swig-foo.c"
|
||||
|
||||
GNC_MODULE_API_DECL(libgncmodfoo)
|
||||
|
||||
int libgncmodfoo_gnc_module_system_interface = 0;
|
||||
|
||||
int libgncmodfoo_gnc_module_current = 0;
|
||||
int libgncmodfoo_gnc_module_age = 0;
|
||||
int libgncmodfoo_gnc_module_revision = 0;
|
||||
|
||||
char *
|
||||
libgncmodfoo_gnc_module_path(void)
|
||||
{
|
||||
return g_strdup("gnucash/foo");
|
||||
}
|
||||
|
||||
char *
|
||||
libgncmodfoo_gnc_module_description(void)
|
||||
{
|
||||
return g_strdup("this is a foo module");
|
||||
}
|
||||
|
||||
int
|
||||
libgncmodfoo_gnc_module_init(int refcount)
|
||||
{
|
||||
/* publish the wrapped Scheme bindings for libfoo */
|
||||
scm_init_sw_foo_module();
|
||||
scm_c_eval_string("(use-modules (sw_foo))");
|
||||
|
||||
/* use the Scheme "foo" module */
|
||||
scm_c_eval_string("(use-modules (gnucash foo))");
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
31
libgnucash/gnc-module/test/mod-foo/gnucash/foo.scm
Normal file
31
libgnucash/gnc-module/test/mod-foo/gnucash/foo.scm
Normal file
@@ -0,0 +1,31 @@
|
||||
;; test of a Scheme module called gnc-mod-foo, which should get
|
||||
;; loaded by the Gnucash module "foo"
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; This program is free software; you can redistribute it and/or
|
||||
;; modify it under the terms of the GNU General Public License as
|
||||
;; published by the Free Software Foundation; either version 2 of
|
||||
;; the License, or (at your option) any later version.
|
||||
;;
|
||||
;; This program is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
;;
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with this program; if not, contact:
|
||||
;;
|
||||
;; Free Software Foundation Voice: +1-617-542-5942
|
||||
;; 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
|
||||
;; Boston, MA 02110-1301, USA gnu@gnu.org
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
|
||||
(define-module (gnucash foo))
|
||||
|
||||
(export foo:scheme-hello)
|
||||
|
||||
(define (foo:scheme-hello)
|
||||
#t)
|
||||
|
||||
|
||||
|
||||
62
libgnucash/gnc-module/test/test-agedver.c
Normal file
62
libgnucash/gnc-module/test/test-agedver.c
Normal file
@@ -0,0 +1,62 @@
|
||||
/********************************************************************\
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation; either version 2 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License*
|
||||
* along with this program; if not, contact: *
|
||||
* *
|
||||
* Free Software Foundation Voice: +1-617-542-5942 *
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org *
|
||||
* *
|
||||
\********************************************************************/
|
||||
|
||||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <libguile.h>
|
||||
|
||||
#include "gnc-module.h"
|
||||
#include <unittest-support.h>
|
||||
|
||||
static void
|
||||
guile_main(void *closure, int argc, char ** argv)
|
||||
{
|
||||
GNCModule foo;
|
||||
gchar *msg = "Module '../../../libgnucash/gnc-module/test/misc-mods/.libs/libgncmod_futuremodsys.so' requires newer module system\n";
|
||||
gchar *logdomain = "gnc.module";
|
||||
guint loglevel = G_LOG_LEVEL_WARNING;
|
||||
TestErrorStruct check = { loglevel, logdomain, msg };
|
||||
g_log_set_handler (logdomain, loglevel,
|
||||
(GLogFunc)test_checked_handler, &check);
|
||||
g_test_message(" test-agedver.c: asking for an old but supported interface ...");
|
||||
|
||||
gnc_module_system_init();
|
||||
|
||||
foo = gnc_module_load("gnucash/agedver", 5);
|
||||
|
||||
if (foo)
|
||||
{
|
||||
printf(" ok\n");
|
||||
exit(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf(" failed\n");
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char ** argv)
|
||||
{
|
||||
scm_boot_guile(argc, argv, guile_main, NULL);
|
||||
return 0;
|
||||
}
|
||||
112
libgnucash/gnc-module/test/test-dynload.c
Normal file
112
libgnucash/gnc-module/test/test-dynload.c
Normal file
@@ -0,0 +1,112 @@
|
||||
/*********************************************************************
|
||||
* test-dynload.c
|
||||
* test the ability to dlopen the gnc_module library and initialize
|
||||
* it via dlsym
|
||||
*********************************************************************/
|
||||
/********************************************************************\
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation; either version 2 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License*
|
||||
* along with this program; if not, contact: *
|
||||
* *
|
||||
* Free Software Foundation Voice: +1-617-542-5942 *
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org *
|
||||
* *
|
||||
\********************************************************************/
|
||||
|
||||
|
||||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
#include <gmodule.h>
|
||||
#include <libguile.h>
|
||||
#include <unittest-support.h>
|
||||
|
||||
#include "gnc-module.h"
|
||||
|
||||
static void
|
||||
guile_main(void *closure, int argc, char ** argv)
|
||||
{
|
||||
GModule *gmodule;
|
||||
gchar *msg = "Module '../../../libgnucash/gnc-module/test/misc-mods/.libs/libgncmod_futuremodsys.so' requires newer module system\n";
|
||||
gchar *logdomain = "gnc.module";
|
||||
gchar *modpath;
|
||||
guint loglevel = G_LOG_LEVEL_WARNING;
|
||||
const char *libdir = g_getenv("LIBDIR");
|
||||
TestErrorStruct check = { loglevel, logdomain, msg };
|
||||
g_log_set_handler (logdomain, loglevel,
|
||||
(GLogFunc)test_checked_handler, &check);
|
||||
|
||||
if (libdir == NULL)
|
||||
{
|
||||
libdir = "../.libs";
|
||||
}
|
||||
|
||||
g_test_message(" test-dynload.c: testing dynamic linking of libgnc-module ...");
|
||||
#ifdef G_OS_WIN32
|
||||
/* MinGW builds libgnc-module-0.dll */
|
||||
if (libdir == NULL)
|
||||
{
|
||||
modpath = g_module_build_path ("../.libs", "gnc-module-0");
|
||||
}
|
||||
else
|
||||
{
|
||||
modpath = g_module_build_path (libdir, "gnc-module");
|
||||
}
|
||||
#elif defined(GNC_PLATFORM_OSX)
|
||||
/* We build libgnc-module as a shared library for testing, and on OSX
|
||||
* that means that g_module_build_path (), which uses ".so", doesn't
|
||||
* build the right path name.
|
||||
*/
|
||||
if (libdir == NULL)
|
||||
{
|
||||
modpath = g_build_filename ("..", ".libs", "libgnc-module.dylib", NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
modpath = g_build_filename (libdir, "libgnc-module.dylib", NULL);
|
||||
}
|
||||
#else /* Regular Unix */
|
||||
modpath = g_module_build_path (libdir, "gnc-module");
|
||||
#endif
|
||||
gmodule = g_module_open(modpath, 0);
|
||||
|
||||
if (gmodule)
|
||||
{
|
||||
gpointer ptr;
|
||||
if (g_module_symbol(gmodule, "gnc_module_system_init", &ptr))
|
||||
{
|
||||
void (* fn)(void) = ptr;
|
||||
fn();
|
||||
printf(" OK\n");
|
||||
exit(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf(" failed to find gnc_module_system_init\n");
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
printf(" failed to open library.\n");
|
||||
printf("%s\n", g_module_error());
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char ** argv)
|
||||
{
|
||||
scm_boot_guile(argc, argv, guile_main, NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
15
libgnucash/gnc-module/test/test-gwrapped-c.in
Executable file
15
libgnucash/gnc-module/test/test-gwrapped-c.in
Executable file
@@ -0,0 +1,15 @@
|
||||
#! @SHELL@
|
||||
${GUILE} -c "(use-modules (gnucash unittest-support))
|
||||
(define log-domain \"gnc.module\")
|
||||
(define check (new-TestErrorStruct))
|
||||
(define log-level (G-LOG-LEVEL-WARNING))
|
||||
(define msg \"Module '../../../src/gnc-module/test/misc-mods/.libs/libgncmod_futuremodsys.so' requires newer module system\n\")
|
||||
(TestErrorStruct-log-domain-set check log-domain)
|
||||
(TestErrorStruct-log-level-set check log-level)
|
||||
(TestErrorStruct-msg-set check msg)
|
||||
(define handler (test-set-checked-handler log-domain log-level check))
|
||||
(use-modules (gnucash gnc-module))
|
||||
(gnc:module-system-init)
|
||||
(gnc:module-load \"gnucash/foo\" 0)
|
||||
(exit (eq? 10 (foo-hello)))
|
||||
(g-log-remove-handler log-domain handler)"
|
||||
67
libgnucash/gnc-module/test/test-incompatdep.c
Normal file
67
libgnucash/gnc-module/test/test-incompatdep.c
Normal file
@@ -0,0 +1,67 @@
|
||||
/********************************************************************\
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation; either version 2 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License*
|
||||
* along with this program; if not, contact: *
|
||||
* *
|
||||
* Free Software Foundation Voice: +1-617-542-5942 *
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org *
|
||||
* *
|
||||
\********************************************************************/
|
||||
|
||||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <libguile.h>
|
||||
#include <unittest-support.h>
|
||||
|
||||
#include "gnc-module.h"
|
||||
|
||||
static void
|
||||
guile_main(void *closure, int argc, char ** argv)
|
||||
{
|
||||
GNCModule foo;
|
||||
gchar *msg1 = "Module '../../../libgnucash/gnc-module/test/misc-mods/.libs/libgncmod_futuremodsys.so' requires newer module system\n";
|
||||
gchar *msg2 = "Could not locate module gnucash/incompatdep interface v.0";
|
||||
gchar *logdomain = "gnc.module";
|
||||
guint loglevel = G_LOG_LEVEL_WARNING;
|
||||
TestErrorStruct check1 = { loglevel, logdomain, msg1 };
|
||||
TestErrorStruct check2 = { loglevel, logdomain, msg2 };
|
||||
test_add_error (&check1);
|
||||
test_add_error (&check2);
|
||||
g_log_set_handler (logdomain, loglevel,
|
||||
(GLogFunc)test_list_handler, NULL);
|
||||
|
||||
g_test_message(" test-incompatdep.c: loading a module with bad deps ...\n");
|
||||
|
||||
gnc_module_system_init();
|
||||
|
||||
foo = gnc_module_load("gnucash/incompatdep", 0);
|
||||
|
||||
if (!foo)
|
||||
{
|
||||
printf(" ok\n");
|
||||
exit(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf(" oops! loaded incompatible module\n");
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char ** argv)
|
||||
{
|
||||
scm_boot_guile(argc, argv, guile_main, NULL);
|
||||
return 0;
|
||||
}
|
||||
67
libgnucash/gnc-module/test/test-load-c.c
Normal file
67
libgnucash/gnc-module/test/test-load-c.c
Normal file
@@ -0,0 +1,67 @@
|
||||
/********************************************************************\
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation; either version 2 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License*
|
||||
* along with this program; if not, contact: *
|
||||
* *
|
||||
* Free Software Foundation Voice: +1-617-542-5942 *
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org *
|
||||
* *
|
||||
\********************************************************************/
|
||||
|
||||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <libguile.h>
|
||||
#include <unittest-support.h>
|
||||
|
||||
#include "gnc-module.h"
|
||||
|
||||
static void
|
||||
guile_main(void *closure, int argc, char ** argv)
|
||||
{
|
||||
GNCModule foo;
|
||||
gchar *msg = "Module '../../../libgnucash/gnc-module/test/misc-mods/.libs/libgncmod_futuremodsys.so' requires newer module system\n";
|
||||
gchar *logdomain = "gnc.module";
|
||||
guint loglevel = G_LOG_LEVEL_WARNING;
|
||||
TestErrorStruct check = { loglevel, logdomain, msg };
|
||||
g_log_set_handler (logdomain, loglevel,
|
||||
(GLogFunc)test_checked_handler, &check);
|
||||
|
||||
g_test_message(" test-load-c.c: testing module load/unload from C ... ");
|
||||
|
||||
gnc_module_system_init();
|
||||
|
||||
foo = gnc_module_load("gnucash/foo", 0);
|
||||
|
||||
if (!foo)
|
||||
{
|
||||
g_test_message(" Failed to load foo\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if (!gnc_module_unload(foo))
|
||||
{
|
||||
g_test_message(" Failed to unload foo\n");
|
||||
exit(-1);
|
||||
}
|
||||
g_test_message(" successful.\n");
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char ** argv)
|
||||
{
|
||||
scm_boot_guile(argc, argv, guile_main, NULL);
|
||||
return 0;
|
||||
}
|
||||
31
libgnucash/gnc-module/test/test-load-deps.in
Executable file
31
libgnucash/gnc-module/test/test-load-deps.in
Executable file
@@ -0,0 +1,31 @@
|
||||
#! @SHELL@
|
||||
exec ${GUILE} -s $0 "$@"
|
||||
!#
|
||||
;; test-load-deps.scm : load gnc-mod-baz, which depends on gnc-mod-foo
|
||||
|
||||
(use-modules (gnucash unittest-support))
|
||||
(define log-domain "gnc.module")
|
||||
(define check (new-TestErrorStruct))
|
||||
(define log-level (G-LOG-LEVEL-WARNING))
|
||||
(define msg "Module '../../../src/gnc-module/test/misc-mods/.libs/libgncmod_futuremodsys.so' requires newer module system\n")
|
||||
(TestErrorStruct-log-domain-set check log-domain)
|
||||
(TestErrorStruct-log-level-set check log-level)
|
||||
(TestErrorStruct-msg-set check msg)
|
||||
(define handler (test-set-checked-handler log-domain log-level check))
|
||||
(use-modules (gnucash gnc-module))
|
||||
|
||||
(gnc:module-system-init)
|
||||
(gnc:module-load "gnucash/baz" 0)
|
||||
|
||||
(baz-hello)
|
||||
(foo-hello)
|
||||
(baz:scheme-hello)
|
||||
(foo:scheme-hello)
|
||||
|
||||
(g-log-remove-handler log-domain handler)
|
||||
|
||||
(exit 0)
|
||||
|
||||
;; Local Variables:
|
||||
;; mode: scheme
|
||||
;; End:
|
||||
20
libgnucash/gnc-module/test/test-load-scm.in
Executable file
20
libgnucash/gnc-module/test/test-load-scm.in
Executable file
@@ -0,0 +1,20 @@
|
||||
#! @SHELL@
|
||||
exec ${GUILE} -s $0 "$@"
|
||||
!#
|
||||
|
||||
(use-modules (gnucash unittest-support))
|
||||
(define log-domain "gnc.module")
|
||||
(define check (new-TestErrorStruct))
|
||||
(define log-level (G-LOG-LEVEL-WARNING))
|
||||
(define msg "Module '../../../src/gnc-module/test/misc-mods/.libs/libgncmod_futuremodsys.so' requires newer module system\n")
|
||||
(TestErrorStruct-log-domain-set check log-domain)
|
||||
(TestErrorStruct-log-level-set check log-level)
|
||||
(TestErrorStruct-msg-set check msg)
|
||||
(define handler (test-set-checked-handler log-domain log-level check))
|
||||
(use-modules (gnucash gnc-module))
|
||||
(gnc:module-system-init)
|
||||
(gnc:module-load "gnucash/foo" 0)
|
||||
(g-log-remove-handler log-domain handler)
|
||||
;; Local Variables:
|
||||
;; mode: scheme
|
||||
;; End:
|
||||
68
libgnucash/gnc-module/test/test-modsysver.c
Normal file
68
libgnucash/gnc-module/test/test-modsysver.c
Normal file
@@ -0,0 +1,68 @@
|
||||
/********************************************************************\
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation; either version 2 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License*
|
||||
* along with this program; if not, contact: *
|
||||
* *
|
||||
* Free Software Foundation Voice: +1-617-542-5942 *
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org *
|
||||
* *
|
||||
\********************************************************************/
|
||||
|
||||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <libguile.h>
|
||||
#include <unittest-support.h>
|
||||
|
||||
#include "gnc-module.h"
|
||||
|
||||
static void
|
||||
guile_main(void *closure, int argc, char ** argv)
|
||||
{
|
||||
GNCModule foo;
|
||||
gchar *msg1 = "Module '../../../libgnucash/gnc-module/test/misc-mods/.libs/libgncmod_futuremodsys.so' requires newer module system\n";
|
||||
gchar *msg2 = "Could not locate module gnucash/futuremodsys interface v.0";
|
||||
gchar *logdomain = "gnc.module";
|
||||
guint loglevel = G_LOG_LEVEL_WARNING;
|
||||
TestErrorStruct check1 = { loglevel, logdomain, msg1 };
|
||||
TestErrorStruct check2 = { loglevel, logdomain, msg2 };
|
||||
test_add_error (&check1);
|
||||
test_add_error (&check2);
|
||||
g_log_set_handler (logdomain, loglevel,
|
||||
(GLogFunc)test_list_handler, NULL);
|
||||
|
||||
g_test_message(" test-modsysver.c: checking for a module we shouldn't find ...\n");
|
||||
|
||||
gnc_module_system_init();
|
||||
|
||||
foo = gnc_module_load("gnucash/futuremodsys", 0);
|
||||
|
||||
if (!foo)
|
||||
{
|
||||
printf(" ok\n");
|
||||
exit(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf(" oops! loaded incompatible module\n");
|
||||
exit(-1);
|
||||
}
|
||||
test_clear_error_list ();
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char ** argv)
|
||||
{
|
||||
scm_boot_guile(argc, argv, guile_main, NULL);
|
||||
return 0;
|
||||
}
|
||||
15
libgnucash/gnc-module/test/test-scm-dynload.in
Executable file
15
libgnucash/gnc-module/test/test-scm-dynload.in
Executable file
@@ -0,0 +1,15 @@
|
||||
#! @SHELL@
|
||||
echo " test-scm-dynload: testing dynamic-link of libgnc-module from Scheme.";
|
||||
exec ${GUILE} -s $0 "$@"
|
||||
!#
|
||||
|
||||
(if (or (string=? (version) "1.3")
|
||||
(string=? (version) "1.3.4"))
|
||||
(dynamic-link "libgnc-module.so")
|
||||
(dynamic-link "libgnc-module"))
|
||||
|
||||
;; LocalVariables:
|
||||
;; mode: scheme
|
||||
;; End:
|
||||
|
||||
|
||||
23
libgnucash/gnc-module/test/test-scm-init.in
Executable file
23
libgnucash/gnc-module/test/test-scm-init.in
Executable file
@@ -0,0 +1,23 @@
|
||||
#! @SHELL@
|
||||
echo " test-scm-init: testing Scheme-only module system init. ";
|
||||
exec ${GUILE} -s $0 "$@"
|
||||
!#
|
||||
|
||||
(use-modules (gnucash unittest-support))
|
||||
(define log-domain "gnc.module")
|
||||
(define check (new-TestErrorStruct))
|
||||
(define log-level (G-LOG-LEVEL-WARNING))
|
||||
(define msg "Module '../../../src/gnc-module/test/misc-mods/.libs/libgncmod_futuremodsys.so' requires newer module system\n")
|
||||
(TestErrorStruct-log-domain-set check log-domain)
|
||||
(TestErrorStruct-log-level-set check log-level)
|
||||
(TestErrorStruct-msg-set check msg)
|
||||
(define handler (test-set-checked-handler log-domain log-level check))
|
||||
|
||||
(use-modules (gnucash gnc-module))
|
||||
(gnc:module-system-init)
|
||||
|
||||
(g-log-remove-handler log-domain handler)
|
||||
|
||||
;; LocalVariables:
|
||||
;; mode: scheme
|
||||
;; End:
|
||||
15
libgnucash/gnc-module/test/test-scm-module.in
Executable file
15
libgnucash/gnc-module/test/test-scm-module.in
Executable file
@@ -0,0 +1,15 @@
|
||||
#! @SHELL@
|
||||
${GUILE} -c "(use-modules (gnucash unittest-support))
|
||||
(define log-domain \"gnc.module\")
|
||||
(define check (new-TestErrorStruct))
|
||||
(define log-level (G-LOG-LEVEL-WARNING))
|
||||
(define msg \"Module '../../../src/gnc-module/test/misc-mods/.libs/libgncmod_futuremodsys.so' requires newer module system\n\")
|
||||
(TestErrorStruct-log-domain-set check log-domain)
|
||||
(TestErrorStruct-log-level-set check log-level)
|
||||
(TestErrorStruct-msg-set check msg)
|
||||
(define handler (test-set-checked-handler log-domain log-level check))
|
||||
(use-modules (gnucash gnc-module))
|
||||
(gnc:module-system-init)
|
||||
(if (not (gnc:module-load \"gnucash/foo\" 0)) (exit -1))
|
||||
(exit (foo:scheme-hello))
|
||||
(g-log-remove-handler log-domain handler)"
|
||||
29
libgnucash/gnc-module/test/test-scm-multi.in
Executable file
29
libgnucash/gnc-module/test/test-scm-multi.in
Executable file
@@ -0,0 +1,29 @@
|
||||
#! @SHELL@
|
||||
exec ${GUILE} -s $0 "$@"
|
||||
!#
|
||||
(use-modules (gnucash unittest-support))
|
||||
(define log-domain "gnc.module")
|
||||
(define check (new-TestErrorStruct))
|
||||
(define log-level (G-LOG-LEVEL-WARNING))
|
||||
(define msg "Module '../../../src/gnc-module/test/misc-mods/.libs/libgncmod_futuremodsys.so' requires newer module system\n")
|
||||
(TestErrorStruct-log-domain-set check log-domain)
|
||||
(TestErrorStruct-log-level-set check log-level)
|
||||
(TestErrorStruct-msg-set check msg)
|
||||
(define handler (test-set-checked-handler log-domain log-level check))
|
||||
|
||||
(use-modules (gnucash gnc-module))
|
||||
(gnc:module-system-init)
|
||||
(gnc:module-load "gnucash/foo" 0)
|
||||
(foo-hello)
|
||||
(foo:scheme-hello)
|
||||
(gnc:module-load "gnucash/bar" 0)
|
||||
(foo-hello)
|
||||
(foo:scheme-hello)
|
||||
(bar-hello)
|
||||
(bar:scheme-hello)
|
||||
|
||||
(g-log-remove-handler log-domain handler)
|
||||
|
||||
;; Local Variables:
|
||||
;; mode: scheme
|
||||
;; End:
|
||||
Reference in New Issue
Block a user