bindings/guile - remove gnc-module wrapper

Emit appropriate deprecation warnings in case code tries to invoke the removed functions.
Only for gnc:module-load a more elaborate compat function has
been written which should allow code using this obsolete function
to continue to function. The emitted deprecation warning will
guide the user to update his/her code for future compatibility.
This commit is contained in:
Geert Janssens 2019-11-27 16:18:56 +01:00
parent e8451ae1db
commit 88706e5657
36 changed files with 81 additions and 881 deletions

View File

@ -6,6 +6,5 @@ set_local_dist(bindings_DIST_local
business-core.i
core-utils.i
engine.i
engine-common.i
gnc-module.i)
engine-common.i)
set(bindings_DIST ${bindings_DIST_local} ${guile_DIST} ${python_bindings_DIST} PARENT_SCOPE)

View File

@ -1,39 +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_gnc_module
%{
#include <gnc-module.h>
%}
#if defined(SWIGGUILE)
%{
#include "guile-mappings.h"
SCM scm_init_sw_gnc_module_module (void);
%}
#endif
%import "base-typemaps.i"
void gnc_module_system_init(void);
void gnc_module_system_refresh(void);
GNCModule gnc_module_load(gchar * module_name, gint interface);
GNCModule gnc_module_load_optional(gchar * module_name, gint interface);
int gnc_module_unload(GNCModule mod);

View File

@ -20,15 +20,6 @@ gnc_add_swig_guile_command (swig-engine-c
${CMAKE_SOURCE_DIR}/bindings/engine-common.i
)
# Command to generate the swig-gnc-module.c wrapper file
gnc_swig_extract_header_files (gnc-module GNC_MODULE_HEADERS)
gnc_add_swig_guile_command (swig-gnc-module-c
SWIG_GNC_MODULE_C swig-gnc-module.c
${CMAKE_SOURCE_DIR}/bindings/gnc-module.i
"${CMAKE_CURRENT_SOURCE_DIR};${CMAKE_SOURCE_DIR}/libgnucash/gnc-module"
${GNC_MODULE_HEADERS}
)
set(guile_HEADERS
glib-guile.h
gnc-engine-guile.h
@ -46,8 +37,7 @@ add_library(gnucash-guile SHARED
${guile_SOURCES}
${guile_HEADERS}
${SWIG_CORE_UTILS_GUILE_C}
${SWIG_ENGINE_C}
${SWIG_GNC_MODULE_C})
${SWIG_ENGINE_C})
add_dependencies(gnucash-guile
swig-runtime-h)
@ -67,7 +57,6 @@ target_link_libraries(gnucash-guile
PRIVATE
gnc-core-utils
gnc-engine
gnc-module
${GLIB2_LDFLAGS})
install(TARGETS gnucash-guile
@ -139,7 +128,6 @@ gnc_add_scheme_targets(scm-engine-2
add_custom_target(scm-engine ALL DEPENDS scm-engine-2 scm-engine-1 scm-engine-0)
set(scm_gnc_module_DEPENDS
gnc-module
gnucash-guile)
gnc_add_scheme_targets(scm-gnc-module

View File

@ -34,7 +34,6 @@ static int is_initialized = 0;
extern SCM scm_init_sw_core_utils_module (void);
extern SCM scm_init_sw_engine_module (void);
extern SCM scm_init_sw_gnc_module_module (void);
void
gnc_guile_bindings_init(void)
@ -44,7 +43,6 @@ gnc_guile_bindings_init(void)
/* Do what's necessary to initialize the bindings */
scm_init_sw_core_utils_module();
scm_init_sw_engine_module();
scm_init_sw_gnc_module_module();
is_initialized = 1;
}

View File

@ -27,23 +27,50 @@
(define-module (gnucash gnc-module))
;; Guile 2 needs to find the symbols from the extension at compile time already
(eval-when
(compile load eval expand)
(load-extension "libgnucash-guile" "gnc_guile_bindings_init"))
(use-modules (sw_gnc_module))
(define (no-op-deprecation-warning)
(issue-deprecation-warning "* WARNING * Guile wrappers for the gnc module system have been deprecated.")
(issue-deprecation-warning "This particular function call is now a no-op. Please use equivalent (use-modules ...) calls instead."))
; Export the swig-wrapped symbols in the public interface of this module
(let ((i (module-public-interface (current-module))))
(module-use! i (resolve-interface '(sw_gnc_module))))
(define-public gnc:module-system-init gnc-module-system-init)
(define-public gnc:module-system-refresh gnc-module-system-refresh)
(define-public gnc:module-load gnc-module-load)
(define-public gnc:module-load-optional gnc-module-load-optional)
(define-public gnc:module-unload gnc-module-unload)
;; Guile 2 needs to load external modules at compile time
(define-syntax-rule (gnc:module-begin-syntax form ...)
(eval-when (load compile eval expand) (begin form ...)))
(export gnc:module-begin-syntax)
(define-public (gnc:module-system-init)
(no-op-deprecation-warning))
(define-public (gnc:module-system-refresh)
(no-op-deprecation-warning))
(define-public (gnc:module-load-optional)
(no-op-deprecation-warning))
(define-public (gnc:module-unload)
(no-op-deprecation-warning))
(define-public (gnc:module-load gnc-mod-name mod-sys-version)
(let* ((mod-name-split (string-split gnc-mod-name #\/))
(mod-name-str (string-join mod-name-split " "))
(scm-mod-name (map string->symbol mod-name-split)))
(cond
((string=? gnc-mod-name "gnucash/app-utils")
(issue-deprecation-warning "* WARNING * 'gnc:module-load (\"gnucash/app-utils\" 0)' has been deprecated and will be removed in gnucash 5.0.")
(issue-deprecation-warning "Use '(use-modules (gnucash engine)(gnucash app-utils))' instead.")
(issue-deprecation-warning "Use of the '(gnucash engine)' guile module is optional and depends on whether or not you use functions from this module in your code or not.")
(use-modules (gnucash engine)(gnucash app-utils)))
((or
(string=? gnc-mod-name "gnucash/tax/de_DE")
(string=? gnc-mod-name "gnucash/tax/us"))
(set! scm-mod-name (list 'gnucash 'locale (list-ref scm-mod-name 2) 'tax))
(set! mod-name-str (string-join (map symbol->string scm-mod-name) " "))
(issue-deprecation-warning (string-concatenate (list "* WARNING * '(gnc:module-load \"" gnc-mod-name "\" 0)' has been deprecated.")))
(issue-deprecation-warning (string-concatenate (list "Use '(use-modules (" mod-name-str "))' instead.")))
(module-use! (current-module) (resolve-interface scm-mod-name)))
((or
(string=? gnc-mod-name "gnucash/gnome-utils")
(string=? gnc-mod-name "gnucash/html")
(string=? gnc-mod-name "gnucash/report/report-system"))
(when (string=? gnc-mod-name"gnucash/report/report-system")
(set! mod-name-str "gnucash report"))
(set! scm-mod-name (list 'gnucash 'report))
(issue-deprecation-warning (string-concatenate (list "* WARNING * '(gnc:module-load \"" gnc-mod-name "\" 0)' has been deprecated.")))
(issue-deprecation-warning (string-concatenate (list "Use '(use-modules (gnucash engine)(gnucash app-utils)(" mod-name-str "))' instead.")))
(issue-deprecation-warning "Use of the '(gnucash engine)' or '(gnucash app-utils)' guile modules is optional and depends on whether or not you use functions from this module in your code or not.")
(use-modules (gnucash engine)(gnucash app-utils))
(module-use! (current-module) (resolve-interface scm-mod-name)))
(else
(issue-deprecation-warning (string-concatenate (list "* WARNING * '(gnc:module-load \"" gnc-mod-name "\" 0)' has been deprecated.")))
(issue-deprecation-warning (string-concatenate ( list "Use '(use-modules (" mod-name-str "))' instead.")))
(issue-deprecation-warning "Additional guile modules may have to be loaded depending on your specific code.")
(module-use! (current-module) (resolve-interface scm-mod-name))))))

View File

@ -1,9 +1,5 @@
# C(++) tests requiring a proper guile environment set up
add_subdirectory(mod-foo)
add_subdirectory(mod-bar)
add_subdirectory(mod-baz)
set(ENGINE_TEST_INCLUDE_DIRS
${CMAKE_SOURCE_DIR}/libgnucash/backend/xml
${CMAKE_SOURCE_DIR}/libgnucash/engine
@ -115,43 +111,6 @@ if (HAVE_SRFI64)
endif (HAVE_SRFI64)
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 (test_gnc_module_DEPENDS
scm-gnc-module
scm-test-core
scm-mod-foo
gncmod-bar
scm-mod-baz
)
gnc_add_scheme_test_targets (test-gnc-modules-scm
"${test_gnc_module_SCHEME}"
"tests"
"${test_gnc_module_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_engine_SCHEME_DIST
srfi64-extras.scm
${bindings_test_SCHEME}
@ -164,14 +123,10 @@ set_local_dist(test_guile_DIST_local
CMakeLists.txt
test-scm-query.cpp
${test_engine_SCHEME_DIST}
${test_gnc_module_SCHEME}
${test_scm_SCHEME}
)
set(test_guile_DIST
${test_guile_DIST_local}
${mod_bar_DIST}
${mod_baz_DIST}
${mod_foo_DIST}
PARENT_SCOPE
)

View File

@ -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/test
)
set_dist_list(mod_bar_DIST CMakeLists.txt bar.c gnucash/bar.scm bar.h bar.i gnc-mod-bar.c)

View File

@ -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;
}

View File

@ -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

View File

@ -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);

View File

@ -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;
}

View File

@ -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)

View File

@ -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}/bindings/guile/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/test)
set_dist_list(mod_baz_DIST CMakeLists.txt baz.c gnucash/baz.scm baz.h baz.i gnc-mod-baz.c)

View File

@ -1,34 +0,0 @@
/* 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;
}

View File

@ -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

View File

@ -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);

View File

@ -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;
}
}

View File

@ -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)

View File

@ -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/test)
set_dist_list(mod_foo_DIST CMakeLists.txt foo.i gnucash/foo.scm foo.c foo.h gnc-mod-foo.c)

View File

@ -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;
}

View File

@ -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

View File

@ -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);

View File

@ -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;
}

View File

@ -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)

View File

@ -20,12 +20,10 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(use-modules (gnucash gnc-module))
(use-modules (gnucash engine))
(define (run-test)
(setenv "GNC_UNINSTALLED" "1")
(gnc:module-system-init)
(let* ((session (qof-session-new))
(book (qof-session-get-book session))

View File

@ -1,11 +0,0 @@
(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)
(exit 0)

View File

@ -1,6 +0,0 @@
(use-modules (gnucash gnc-module))
(gnc:module-system-init)
(gnc:module-load "gnucash/foo" 0)
(exit 0)

View File

@ -1,2 +0,0 @@
(dynamic-link "libgnc-module")
(exit 0)

View File

@ -1,5 +0,0 @@
(use-modules (gnucash gnc-module))
(gnc:module-system-init)
(exit 0)

View File

@ -1,6 +0,0 @@
(use-modules (gnucash gnc-module))
(gnc:module-system-init)
(if (not (gnc:module-load "gnucash/foo" 0)) (exit -1))
(exit (foo:scheme-hello))

View File

@ -1,14 +0,0 @@
(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)
(exit 0)

View File

@ -1,5 +0,0 @@
(use-modules (gnucash gnc-module))
(gnc:module-system-init)
(gnc:module-load "gnucash/foo" 0)
(exit (eq? 10 (foo-hello)))

View File

@ -20,12 +20,10 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(use-modules (gnucash gnc-module))
(use-modules (gnucash engine))
(define (run-test)
(setenv "GNC_UNINSTALLED" "1")
(gnc:module-system-init)
(display "\tTesting the Query Import interface... \n")
(display "\tYou may see \"Error: xaccQueryAddGUIDMatch: Invalid match type\".\n")

View File

@ -32,9 +32,6 @@ function(get_guile_env)
list(APPEND env "GUILE=${GUILE_EXECUTABLE}")
set(guile_load_paths "")
list(APPEND guile_load_paths "${CMAKE_CURRENT_SOURCE_DIR}/mod-foo")
list(APPEND guile_load_paths "${CMAKE_CURRENT_SOURCE_DIR}/mod-bar")
list(APPEND guile_load_paths "${CMAKE_CURRENT_SOURCE_DIR}/mod-baz")
#list(APPEND guile_load_paths "${CMAKE_BINARY_DIR}/${GUILE_REL_SITEDIR}")
list(APPEND guile_load_paths "${CMAKE_BINARY_DIR}/${GUILE_REL_SITEDIR}/gnucash/deprecated") # Path to gnucash' deprecated modules
set(guile_load_path "${guile_load_paths}")

View File

@ -1,14 +1,21 @@
(define exit-code 0)
(setenv "GNC_UNINSTALLED" "1")
(use-modules (gnucash gnc-module))
(gnc:module-system-init)
(display " testing gnome-utils module load ... ")
(if (gnc:module-load "gnucash/gnome-utils" 0)
(use-modules (gnucash gnome-utils))
(begin
(display "ok\n")
(exit 0))
(begin
(display "failed\n")
(exit 1)))
(cond
((defined? 'gnc:make-menu)
(display "Procedure gnc:make-menu found\n"))
(else
(display "Failed - procedure gnc:make-menu not found\n")
(set! exit-code -1)))
(cond
((defined? 'gnc:set-ui-status)
(display "Procedure gnc:set-ui-status found\n"))
(else
(display "Failed - procedure gnc:set-ui-status not found\n")
(set! exit-code -1)))
(exit exit-code)

View File

@ -1,17 +1,21 @@
(debug-enable 'backtrace)
(debug-set! stack 500000)
(define exit-code 0)
(setenv "GNC_UNINSTALLED" "1")
(display " testing report module load ... ")
(setenv "GNC_UNINSTALLED" "1")
(use-modules (gnucash gnc-module))
(use-modules (gnucash report))
(gnc:module-system-init)
(cond
((defined? 'gnc:define-report)
(display "Procedure gnc:define-report found\n"))
(else
(display "Failed - procedure gnc:define-report not found\n")
(set! exit-code -1)))
(if (gnc:module-load "gnucash/report" 0)
(begin
(display "ok\n")
(exit 0))
(begin
(display "failed\n")
(exit -1)))
(cond
((defined? 'gnc:make-html-chart)
(display "Procedure gnc:make-html-chart found\n"))
(else
(display "Failed - procedure gnc:make-html-chart not found\n")
(set! exit-code -1)))
(exit exit-code)