mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
gnc-module - move most of scm tests to bindings/guile
This is a first rudimentary separation of gnc-module tests based on whether they require guile or not. Needs plenty of refinement which will be applied in followup commits.
This commit is contained in:
@@ -1,7 +1,4 @@
|
||||
|
||||
add_subdirectory(mod-foo)
|
||||
add_subdirectory(mod-bar)
|
||||
add_subdirectory(mod-baz)
|
||||
add_subdirectory(misc-mods)
|
||||
|
||||
set(GNC_MODULE_TEST_INCLUDE_DIRS
|
||||
@@ -21,6 +18,7 @@ set(GNC_MODULE_TEST_LIBS
|
||||
gncmod-agedver
|
||||
gncmod-futuremodsys
|
||||
gncmod-incompatdep
|
||||
gncmod-ordinarymod
|
||||
)
|
||||
|
||||
gnc_add_test_with_guile(test-load-c test-load-c.c GNC_MODULE_TEST_INCLUDE_DIRS GNC_MODULE_TEST_LIBS "GNC_MODULE_PATH=${LIBDIR_BUILD}/gnucash/test")
|
||||
@@ -45,46 +43,6 @@ gnc_add_test(test-dynload test-dynload.c
|
||||
LIBDIR=${_LIBDIR}
|
||||
)
|
||||
|
||||
set(test_gnc_module_SCHEME
|
||||
test-gnc-module-scm-init.scm
|
||||
test-gnc-module-load-scm.scm
|
||||
test-gnc-module-swigged-c.scm
|
||||
test-gnc-module-load-deps.scm
|
||||
test-gnc-module-scm-dynload.scm
|
||||
test-gnc-module-scm-module.scm
|
||||
test-gnc-module-scm-multi.scm
|
||||
)
|
||||
|
||||
set(CORE_GUILE_DEPENDS
|
||||
scm-gnc-module
|
||||
scm-test-core
|
||||
scm-mod-foo
|
||||
gncmod-bar
|
||||
scm-mod-baz
|
||||
gncmod-agedver
|
||||
gncmod-incompatdep
|
||||
gncmod-futuremodsys
|
||||
)
|
||||
|
||||
gnc_add_scheme_test_targets(test-gnc-modules-scm
|
||||
"${test_gnc_module_SCHEME}"
|
||||
"tests"
|
||||
"${CORE_GUILE_DEPENDS}"
|
||||
TRUE
|
||||
)
|
||||
|
||||
gnc_add_scheme_tests("${test_gnc_module_SCHEME}")
|
||||
if(NOT WIN32)
|
||||
# This little dance is needed because gnc_module_init will assert if
|
||||
# it finds libgncmod-futuremod.so outside of a test that expects it.
|
||||
get_guile_env()
|
||||
set(_GNC_MODULE_PATH "${LIBDIR_BUILD}:${LIBDIR_BUILD}/gnucash:${LIBDIR_BUILD}/gnucash/test")
|
||||
foreach(test_file ${test_gnc_module_SCHEME})
|
||||
get_filename_component(basename ${test_file} NAME_WE)
|
||||
set_tests_properties(${basename} PROPERTIES ENVIRONMENT "${GUILE_ENV};GNC_MODULE_PATH=${_GNC_MODULE_PATH}")
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
set(test_gnc_module_SOURCE_DIST
|
||||
test-agedver.c
|
||||
test-dynload.c
|
||||
@@ -95,7 +53,6 @@ set(test_gnc_module_SOURCE_DIST
|
||||
|
||||
set(test_gnc_module_EXTRA_DIST
|
||||
README
|
||||
${test_gnc_module_SCHEME}
|
||||
)
|
||||
|
||||
set_local_dist(test_gnc_module_DIST_local CMakeLists.txt README ${test_gnc_module_SOURCE_DIST} ${test_gnc_module_EXTRA_DIST})
|
||||
|
@@ -13,9 +13,12 @@ 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_target_properties(gncmod-agedver gncmod-futuremodsys gncmod-incompatdep PROPERTIES
|
||||
add_library(gncmod-ordinarymod EXCLUDE_FROM_ALL ordinarymod.c)
|
||||
target_link_libraries(gncmod-ordinarymod gnc-module ${GLIB2_LDFLAGS})
|
||||
|
||||
set_target_properties(gncmod-agedver gncmod-futuremodsys gncmod-incompatdep gncmod-ordinarymod PROPERTIES
|
||||
LIBRARY_OUTPUT_DIRECTORY ${LIBDIR_BUILD}/gnucash/test
|
||||
ARCHIVE_OUTPUT_DIRECTORY ${LIBDIR_BUILD}/gnucash/test
|
||||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
||||
|
||||
set_dist_list(misc_mods_DIST CMakeLists.txt agedver.c futuremodsys.c incompatdep.c)
|
||||
set_dist_list(misc_mods_DIST CMakeLists.txt agedver.c futuremodsys.c incompatdep.c ordinarymod.c)
|
||||
|
@@ -51,7 +51,7 @@ libgncmod_incompatdep_gnc_module_description(void)
|
||||
int
|
||||
libgncmod_incompatdep_gnc_module_init(int refcount)
|
||||
{
|
||||
if (gnc_module_load("gnucash/foo", 25))
|
||||
if (gnc_module_load("gnucash/ordinarymod", 25))
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/* libbaz. this library depends on foo */
|
||||
/* ordinarymod.c : ordinary module */
|
||||
/********************************************************************\
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
@@ -21,14 +21,39 @@
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <gmodule.h>
|
||||
|
||||
#include "baz.h"
|
||||
#include "foo.h"
|
||||
#include "gnc-module.h"
|
||||
#include "gnc-module-api.h"
|
||||
|
||||
int
|
||||
baz_hello(void)
|
||||
GNC_MODULE_API_DECL(libgncmod_ordinarymod)
|
||||
|
||||
int libgncmod_ordinarymod_gnc_module_system_interface = 0;
|
||||
|
||||
int libgncmod_ordinarymod_gnc_module_current = 0;
|
||||
int libgncmod_ordinarymod_gnc_module_age = 0;
|
||||
int libgncmod_ordinarymod_gnc_module_revision = 0;
|
||||
|
||||
char *
|
||||
libgncmod_ordinarymod_gnc_module_path(void)
|
||||
{
|
||||
foo_hello();
|
||||
return 1;
|
||||
return g_strdup("gnucash/ordinarymod");
|
||||
}
|
||||
|
||||
char *
|
||||
libgncmod_ordinarymod_gnc_module_description(void)
|
||||
{
|
||||
return g_strdup("this is a very ordinary module");
|
||||
}
|
||||
|
||||
int
|
||||
libgncmod_ordinarymod_gnc_module_init(int refcount)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int
|
||||
libgncmod_ordinarymod_gnc_module_end(int refcount)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
@@ -1,35 +0,0 @@
|
||||
|
||||
gnc_add_swig_guile_command (swig-bar-c
|
||||
SWIG_BAR_C swig-bar.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/bar.i "" bar.h
|
||||
)
|
||||
|
||||
add_library(bar EXCLUDE_FROM_ALL bar.c bar.h)
|
||||
add_library(gncmod-bar EXCLUDE_FROM_ALL gnc-mod-bar.c)
|
||||
set_source_files_properties (gnc-mod-bar.c PROPERTY OBJECT_DEPENDS ${SWIG_BAR_C})
|
||||
|
||||
target_link_libraries(gncmod-bar bar gnc-module)
|
||||
target_include_directories(gncmod-bar 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}
|
||||
)
|
||||
|
||||
gnc_add_scheme_test_targets(scm-mod-bar
|
||||
gnucash/bar.scm
|
||||
"tests/gnucash"
|
||||
gncmod-bar
|
||||
FALSE
|
||||
)
|
||||
|
||||
set_target_properties(bar gncmod-bar PROPERTIES
|
||||
LIBRARY_OUTPUT_DIRECTORY ${LIBDIR_BUILD}/gnucash/test
|
||||
ARCHIVE_OUTPUT_DIRECTORY ${LIBDIR_BUILD}/gnucash/test
|
||||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
|
||||
)
|
||||
|
||||
set_dist_list(mod_bar_DIST CMakeLists.txt bar.c gnucash/bar.scm bar.h bar.i gnc-mod-bar.c)
|
@@ -1,33 +0,0 @@
|
||||
/* 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;
|
||||
}
|
@@ -1,28 +0,0 @@
|
||||
/* 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
|
@@ -1,33 +0,0 @@
|
||||
/********************************************************************\
|
||||
* 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);
|
@@ -1,63 +0,0 @@
|
||||
/* 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(libgncmod_bar)
|
||||
|
||||
int libgncmod_bar_gnc_module_system_interface = 0;
|
||||
|
||||
int libgncmod_bar_gnc_module_current = 0;
|
||||
int libgncmod_bar_gnc_module_age = 0;
|
||||
int libgncmod_bar_gnc_module_revision = 0;
|
||||
|
||||
char *
|
||||
libgncmod_bar_gnc_module_path(void)
|
||||
{
|
||||
return g_strdup("gnucash/bar");
|
||||
}
|
||||
|
||||
char *
|
||||
libgncmod_bar_gnc_module_description(void)
|
||||
{
|
||||
return g_strdup("this is a bar module");
|
||||
}
|
||||
|
||||
int
|
||||
libgncmod_bar_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;
|
||||
}
|
@@ -1,31 +0,0 @@
|
||||
;; 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)
|
||||
|
||||
|
||||
|
@@ -1,40 +0,0 @@
|
||||
|
||||
gnc_add_swig_guile_command (swig-baz-c
|
||||
SWIG_BAZ_C swig-baz.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/baz.i "" baz.h
|
||||
)
|
||||
|
||||
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(gncmod-baz EXCLUDE_FROM_ALL gnc-mod-baz.c)
|
||||
set_source_files_properties (gnc-mod-baz.c PROPERTY OBJECT_DEPENDS ${SWIG_BAZ_C})
|
||||
|
||||
target_link_libraries(gncmod-baz baz gnc-module)
|
||||
target_include_directories(gncmod-baz 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}
|
||||
)
|
||||
|
||||
gnc_add_scheme_test_targets(scm-mod-baz
|
||||
gnucash/baz.scm
|
||||
"tests/gnucash"
|
||||
gncmod-baz
|
||||
FALSE
|
||||
)
|
||||
|
||||
set_target_properties(baz gncmod-baz PROPERTIES
|
||||
LIBRARY_OUTPUT_DIRECTORY ${LIBDIR_BUILD}/gnucash/test
|
||||
ARCHIVE_OUTPUT_DIRECTORY ${LIBDIR_BUILD}/gnucash/test
|
||||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
||||
|
||||
set_dist_list(mod_baz_DIST CMakeLists.txt baz.c gnucash/baz.scm baz.h baz.i gnc-mod-baz.c)
|
@@ -1,28 +0,0 @@
|
||||
/* 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
|
@@ -1,33 +0,0 @@
|
||||
/********************************************************************\
|
||||
* 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);
|
@@ -1,72 +0,0 @@
|
||||
/* 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(libgncmod_baz)
|
||||
|
||||
int libgncmod_baz_gnc_module_system_interface = 0;
|
||||
|
||||
int libgncmod_baz_gnc_module_current = 0;
|
||||
int libgncmod_baz_gnc_module_age = 0;
|
||||
int libgncmod_baz_gnc_module_revision = 0;
|
||||
|
||||
char *
|
||||
libgncmod_baz_gnc_module_path(void)
|
||||
{
|
||||
return g_strdup("gnucash/baz");
|
||||
}
|
||||
|
||||
char *
|
||||
libgncmod_baz_gnc_module_description(void)
|
||||
{
|
||||
return g_strdup("this is the baz module");
|
||||
}
|
||||
|
||||
int
|
||||
libgncmod_baz_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;
|
||||
}
|
||||
}
|
@@ -1,31 +0,0 @@
|
||||
;; 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)
|
||||
|
||||
|
||||
|
@@ -1,34 +0,0 @@
|
||||
|
||||
gnc_add_swig_guile_command (swig-foo-c
|
||||
SWIG_FOO_C swig-foo.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/foo.i "" foo.h
|
||||
)
|
||||
|
||||
add_library(foo EXCLUDE_FROM_ALL foo.c foo.h)
|
||||
add_library(gncmod-foo EXCLUDE_FROM_ALL gnc-mod-foo.c)
|
||||
set_source_files_properties (gnc-mod-foo.c PROPERTY OBJECT_DEPENDS ${SWIG_FOO_C})
|
||||
|
||||
target_link_libraries(gncmod-foo foo gnc-module)
|
||||
target_include_directories(gncmod-foo 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}
|
||||
)
|
||||
|
||||
gnc_add_scheme_test_targets(scm-mod-foo
|
||||
gnucash/foo.scm
|
||||
"tests/gnucash"
|
||||
gncmod-foo
|
||||
FALSE
|
||||
)
|
||||
|
||||
set_target_properties(foo gncmod-foo PROPERTIES
|
||||
LIBRARY_OUTPUT_DIRECTORY ${LIBDIR_BUILD}/gnucash/test
|
||||
ARCHIVE_OUTPUT_DIRECTORY ${LIBDIR_BUILD}/gnucash/test
|
||||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
||||
|
||||
set_dist_list(mod_foo_DIST CMakeLists.txt foo.i gnucash/foo.scm foo.c foo.h gnc-mod-foo.c)
|
@@ -1,33 +0,0 @@
|
||||
/* 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;
|
||||
}
|
@@ -1,28 +0,0 @@
|
||||
/* 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
|
@@ -1,33 +0,0 @@
|
||||
/********************************************************************\
|
||||
* 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);
|
@@ -1,63 +0,0 @@
|
||||
/* 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(libgncmod_foo)
|
||||
|
||||
int libgncmod_foo_gnc_module_system_interface = 0;
|
||||
|
||||
int libgncmod_foo_gnc_module_current = 0;
|
||||
int libgncmod_foo_gnc_module_age = 0;
|
||||
int libgncmod_foo_gnc_module_revision = 0;
|
||||
|
||||
char *
|
||||
libgncmod_foo_gnc_module_path(void)
|
||||
{
|
||||
return g_strdup("gnucash/foo");
|
||||
}
|
||||
|
||||
char *
|
||||
libgncmod_foo_gnc_module_description(void)
|
||||
{
|
||||
return g_strdup("this is a foo module");
|
||||
}
|
||||
|
||||
int
|
||||
libgncmod_foo_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;
|
||||
}
|
@@ -1,31 +0,0 @@
|
||||
;; 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)
|
||||
|
||||
|
||||
|
@@ -1,22 +0,0 @@
|
||||
(use-modules (tests unittest-support))
|
||||
(define log-domain "gnc.module")
|
||||
(define check (new-TestErrorStruct))
|
||||
(define log-level (G-LOG-LEVEL-WARNING))
|
||||
(define msg "Module '../../../libgnucash/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)
|
@@ -1,14 +0,0 @@
|
||||
(use-modules (tests unittest-support))
|
||||
(define log-domain "gnc.module")
|
||||
(define check (new-TestErrorStruct))
|
||||
(define log-level (G-LOG-LEVEL-WARNING))
|
||||
(define msg "Module '../../../libgnucash/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)
|
||||
(exit 0)
|
@@ -1,2 +0,0 @@
|
||||
(dynamic-link "libgnc-module")
|
||||
(exit 0)
|
@@ -1,15 +0,0 @@
|
||||
(use-modules (tests unittest-support))
|
||||
(define log-domain "gnc.module")
|
||||
(define check (new-TestErrorStruct))
|
||||
(define log-level (G-LOG-LEVEL-WARNING))
|
||||
(define msg "Module '../../../libgnucash/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)
|
||||
(exit 0)
|
@@ -1,14 +0,0 @@
|
||||
(use-modules (tests unittest-support))
|
||||
(define log-domain "gnc.module")
|
||||
(define check (new-TestErrorStruct))
|
||||
(define log-level (G-LOG-LEVEL-WARNING))
|
||||
(define msg "Module '../../../libgnucash/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)
|
@@ -1,23 +0,0 @@
|
||||
(use-modules (tests unittest-support))
|
||||
(define log-domain "gnc.module")
|
||||
(define check (new-TestErrorStruct))
|
||||
(define log-level (G-LOG-LEVEL-WARNING))
|
||||
(define msg "Module '../../../libgnucash/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)
|
||||
(exit 0)
|
@@ -1,14 +0,0 @@
|
||||
(use-modules (tests unittest-support))
|
||||
(define log-domain "gnc.module")
|
||||
(define check (new-TestErrorStruct))
|
||||
(define log-level (G-LOG-LEVEL-WARNING))
|
||||
(define msg "Module '../../../libgnucash/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)
|
@@ -29,7 +29,7 @@
|
||||
static void
|
||||
guile_main(void *closure, int argc, char ** argv)
|
||||
{
|
||||
GNCModule foo;
|
||||
GNCModule ordinarymod;
|
||||
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;
|
||||
@@ -41,17 +41,17 @@ guile_main(void *closure, int argc, char ** argv)
|
||||
|
||||
gnc_module_system_init();
|
||||
|
||||
foo = gnc_module_load("gnucash/foo", 0);
|
||||
ordinarymod = gnc_module_load("gnucash/ordinarymod", 0);
|
||||
|
||||
if (!foo)
|
||||
if (!ordinarymod)
|
||||
{
|
||||
g_test_message(" Failed to load foo\n");
|
||||
g_test_message(" Failed to load ordinarymod\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if (!gnc_module_unload(foo))
|
||||
if (!gnc_module_unload(ordinarymod))
|
||||
{
|
||||
g_test_message(" Failed to unload foo\n");
|
||||
g_test_message(" Failed to unload ordinarymod\n");
|
||||
exit(-1);
|
||||
}
|
||||
g_test_message(" successful.\n");
|
||||
|
Reference in New Issue
Block a user