diff --git a/CMakeLists.txt b/CMakeLists.txt index 169ecd43d6..4ff9a2e204 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -868,7 +868,7 @@ configure_file( add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake) -set(_MODULES gnc-core-utils gnc-engine gnc-app-utils gnc-module gnc-backend-xml-utils gnucash-guile) +set(_MODULES gnc-core-utils gnc-engine gnc-app-utils gnc-module gnc-locale-tax gnc-backend-xml-utils gnucash-guile) if (WITH_SQL) list(APPEND _MODULES gnc-backend-sql) diff --git a/gnucash/gnome/CMakeLists.txt b/gnucash/gnome/CMakeLists.txt index c8e319e45f..5bb7551171 100644 --- a/gnucash/gnome/CMakeLists.txt +++ b/gnucash/gnome/CMakeLists.txt @@ -145,6 +145,7 @@ target_link_libraries(gnc-gnome gncmod-register-core gncmod-gnome-utils gnc-engine + gnc-locale-tax gnucash-guile ${Boost_LIBRARIES} PkgConfig::GTK3 diff --git a/gnucash/gnome/dialog-tax-info.c b/gnucash/gnome/dialog-tax-info.c index 464c693955..787ba6e2a7 100644 --- a/gnucash/gnome/dialog-tax-info.c +++ b/gnucash/gnome/dialog-tax-info.c @@ -36,6 +36,7 @@ #include "Account.h" #include "gnc-ui-util.h" #include "dialog-utils.h" +#include "gnc-locale-tax.h" #include "gnc-prefs.h" #include "gnc-tree-view-account.h" #include "gnc-component-manager.h" @@ -145,10 +146,8 @@ typedef struct static void initialize_getters (void) { - if (!gnc_module_load("gnucash/locale/tax", 0)) - { - return; - } + gnc_locale_tax_init(); + getters.payer_name_source = scm_c_eval_string ("gnc:txf-get-payer-name-source"); getters.form = scm_c_eval_string ("gnc:txf-get-form"); getters.description = scm_c_eval_string ("gnc:txf-get-description"); diff --git a/libgnucash/app-utils/CMakeLists.txt b/libgnucash/app-utils/CMakeLists.txt index 81562e4f7b..96eafc2c01 100644 --- a/libgnucash/app-utils/CMakeLists.txt +++ b/libgnucash/app-utils/CMakeLists.txt @@ -74,6 +74,7 @@ set(app_utils_ALL_SOURCES ${app_utils_SOURCES} ${app_utils_HEADERS} ${app_utils_ set(app_utils_ALL_LIBRARIES gnc-engine gnc-module + gnc-locale-tax gnucash-guile ${GIO_LDFLAGS} ${LIBXML2_LDFLAGS} diff --git a/libgnucash/app-utils/gnc-ui-util.c b/libgnucash/app-utils/gnc-ui-util.c index 924119bf8d..483d532bf9 100644 --- a/libgnucash/app-utils/gnc-ui-util.c +++ b/libgnucash/app-utils/gnc-ui-util.c @@ -53,6 +53,7 @@ #include "gnc-engine.h" #include "gnc-euro.h" #include "gnc-hooks.h" +#include "gnc-locale-tax.h" #include "gnc-session.h" #include "engine-helpers.h" #include "gnc-locale-utils.h" @@ -625,14 +626,9 @@ gnc_ui_account_get_tax_info_string (const Account *account) if (get_form == SCM_UNDEFINED) { - GNCModule module; const gchar *tax_module; - /* load the tax info - Note that the module "gnucash/locale/tax" will handle selecting - the proper locale specific tax info */ - module = gnc_module_load ("gnucash/locale/tax", 0); - - g_return_val_if_fail (module, NULL); + /* load the tax info */ + gnc_locale_tax_init (); get_form = scm_c_eval_string ("(false-if-exception gnc:txf-get-form)"); diff --git a/libgnucash/tax/CMakeLists.txt b/libgnucash/tax/CMakeLists.txt index 82751602e1..b0f0560fa0 100644 --- a/libgnucash/tax/CMakeLists.txt +++ b/libgnucash/tax/CMakeLists.txt @@ -1,23 +1,24 @@ add_subdirectory(test) -set(locale_tax_SOURCES gncmod-locale-tax.c) +set(locale_tax_SOURCES gnc-locale-tax.c gnc-locale-tax.h) # Add dependency on config.h set_source_files_properties (${locale_tax_SOURCES} PROPERTIES OBJECT_DEPENDS ${CONFIG_H}) -add_library(gncmod-locale-tax ${locale_tax_SOURCES}) -target_link_libraries(gncmod-locale-tax gnc-module ${GLIB2_LDFLAGS} ${GUILE_LDFLAGS}) +add_library(gnc-locale-tax ${locale_tax_SOURCES}) +target_link_libraries(gnc-locale-tax gnc-module ${GLIB2_LDFLAGS} ${GUILE_LDFLAGS}) -target_include_directories(gncmod-locale-tax +target_include_directories(gnc-locale-tax + PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_BINARY_DIR}/common ${GUILE_INCLUDE_DIRS}) if (APPLE) - set_target_properties (gncmod-locale-tax PROPERTIES INSTALL_NAME_DIR "${CMAKE_INSTALL_FULL_LIBDIR}/gnucash") + set_target_properties (gnc-locale-tax PROPERTIES INSTALL_NAME_DIR "${CMAKE_INSTALL_FULL_LIBDIR}") endif() -install(TARGETS gncmod-locale-tax - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/gnucash - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/gnucash +install(TARGETS gnc-locale-tax + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) # No headers to install diff --git a/libgnucash/tax/gnc-locale-tax.c b/libgnucash/tax/gnc-locale-tax.c index 10751575e9..f40e223186 100644 --- a/libgnucash/tax/gnc-locale-tax.c +++ b/libgnucash/tax/gnc-locale-tax.c @@ -1,8 +1,8 @@ /********************************************************************* - * gncmod-locale-tax.c - * module definition/initialization for us tax info + * gnc-locale-tax.c + * hack to load the proper guile based tax system * - * Copyright (c) 2001 Linux Developers Group, Inc. + * Copyright (c) 2019 Geert Janssens *********************************************************************/ /********************************************************************\ * This program is free software; you can redistribute it and/or * @@ -28,45 +28,15 @@ #include #include #include -#include #include +#include -#include "gnc-module.h" -#include "gnc-module-api.h" +#include "gnc-locale-tax.h" -GNC_MODULE_API_DECL(libgncmod_locale_tax) -/* version of the gnc module system interface we require */ -int libgncmod_locale_tax_gnc_module_system_interface = 0; -/* module versioning uses libtool semantics. */ -int libgncmod_locale_tax_gnc_module_current = 0; -int libgncmod_locale_tax_gnc_module_revision = 0; -int libgncmod_locale_tax_gnc_module_age = 0; - - -char * -libgncmod_locale_tax_gnc_module_path(void) -{ - return g_strdup("gnucash/locale/tax"); -} - -char * -libgncmod_locale_tax_gnc_module_description(void) -{ - return g_strdup("Locale dependent income tax information. Currently supported are 'us' and 'de_DE'. Default is 'us'"); -} - -static void -lmod(char * mn) -{ - char * form = g_strdup_printf("(use-modules %s)\n", mn); - scm_c_eval_string(form); - g_free(form); -} - -int -libgncmod_locale_tax_gnc_module_init(int refcount) +void +gnc_locale_tax_init(void) { /* This is a very simple hack that loads the (new, special) German tax definition file in a German locale, or (default) loads the @@ -80,14 +50,7 @@ libgncmod_locale_tax_gnc_module_init(int refcount) gboolean is_de_DE = (strncmp(thislocale, "de_DE", 5) == 0); # endif /* G_OS_WIN32 */ if (is_de_DE) - lmod("(gnucash locale de_DE tax)"); + scm_c_use_module("gnucash locale de_DE tax"); else - lmod("(gnucash locale us tax)"); - return TRUE; -} - -int -libgncmod_locale_tax_gnc_module_end(int refcount) -{ - return TRUE; + scm_c_use_module("gnucash locale us tax"); } diff --git a/libgnucash/tax/gnc-locale-tax.h b/libgnucash/tax/gnc-locale-tax.h new file mode 100644 index 0000000000..0e6de189a5 --- /dev/null +++ b/libgnucash/tax/gnc-locale-tax.h @@ -0,0 +1,30 @@ +/********************************************************************* + * gnc-locale-tax.h - + * a simple hack to load the proper guile base tax system + * + * Copyright 2019 Geert Janssens + * + * 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 GNC_LOCALE_TAX_H_ +#define GNC_LOCALE_TAX_H_ + +void gnc_locale_tax_init (void); + +#endif diff --git a/libgnucash/tax/test/CMakeLists.txt b/libgnucash/tax/test/CMakeLists.txt index 5156048a74..eceeced2a8 100644 --- a/libgnucash/tax/test/CMakeLists.txt +++ b/libgnucash/tax/test/CMakeLists.txt @@ -1,22 +1,10 @@ -set(LOCALE_TAX_TEST_INCLUDE_DIRS "") -set(LOCALE_TAX_TEST_LIBS "") +set(LOCALE_TAX_TEST_INCLUDE_DIRS ${GUILE_INCLUDE_DIRS}) +set(LOCALE_TAX_TEST_LIBS + gnc-engine + gnc-locale-tax + ${GUILE_LDFLAGS}) -gnc_add_test(test-link-module-tax-us test-link-module.c - LOCALE_TAX_TEST_INCLUDE_DIRS LOCALE_TAX_TEST_LIBS -) +gnc_add_test_with_guile(test-link-module-tax-us test-link-module.c +LOCALE_TAX_TEST_INCLUDE_DIRS LOCALE_TAX_TEST_LIBS) -# FIXME why is this test not run ? -#set(GUILE_DEPENDS -# gnc-core-utils -# scm-gnc-module -#) -# -#gnc_add_scheme_test_targets(scm-test-load-tax-us-module -# "test-load-locale-tax-module.scm" -# "tests" -# "${GUILE_DEPENDS}" -# FALSE -#) -#gnc_add_scheme_test(test-load-locale-tax-module.scm) - -set_dist_list(test_locale_tax_DIST CMakeLists.txt test-link-module.c test-load-locale-tax-module.scm) +set_dist_list(test_locale_tax_DIST CMakeLists.txt test-link-module.c) diff --git a/libgnucash/tax/test/test-link-module.c b/libgnucash/tax/test/test-link-module.c index e1c54dcc55..58e07e944b 100644 --- a/libgnucash/tax/test/test-link-module.c +++ b/libgnucash/tax/test/test-link-module.c @@ -18,9 +18,30 @@ * * \********************************************************************/ +#include "gnc-locale-tax.h" + +#include +#include +#include +#include + +static void +guile_main (void *closure, int argc, char **argv) +{ + gnc_locale_tax_init(); + + scm_c_lookup ("gnc:txf-get-description"); +} + int -main(int argc, char ** argv) +main (int argc, char *argv[]) { + qof_init (); /* Initialize the GObject system */ + qof_log_init_filename_special ("stderr"); /* Init the log system */ + g_test_init (&argc, &argv, NULL); /* initialize test program */ + //qof_log_set_level("gnc", G_LOG_LEVEL_DEBUG); + g_test_bug_base("https://bugs.gnucash.org/show_bug.cgi?id="); /* init the bugzilla URL */ + g_setenv ("GNC_UNINSTALLED", "1", TRUE); + scm_boot_guile (argc, argv, guile_main, NULL); return 0; } - diff --git a/libgnucash/tax/test/test-load-locale-tax-module.scm b/libgnucash/tax/test/test-load-locale-tax-module.scm deleted file mode 100755 index 336142ba33..0000000000 --- a/libgnucash/tax/test/test-load-locale-tax-module.scm +++ /dev/null @@ -1,11 +0,0 @@ -(display " testing locale tax info module load ... ") -(use-modules (gnucash gnc-module)) -(gnc:module-system-init) - -(if (gnc:module-load "gnucash/locale/tax" 0) - (begin - (display "ok\n") - (exit 0)) - (begin - (display "failed\n") - (exit -1))) diff --git a/libgnucash/tax/us/txf.scm b/libgnucash/tax/us/txf.scm index c08866132b..7065a826df 100644 --- a/libgnucash/tax/us/txf.scm +++ b/libgnucash/tax/us/txf.scm @@ -41,6 +41,7 @@ (use-modules (gnucash engine)) +(use-modules (gnucash core-utils)) (use-modules (gnucash app-utils)) (use-modules (srfi srfi-2)) diff --git a/po/POTFILES.in b/po/POTFILES.in index c54d4bbf63..511f81b1c6 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -690,7 +690,7 @@ libgnucash/gnc-module/gnc-module.c libgnucash/tax/de_DE/tax.scm libgnucash/tax/de_DE/txf-help.scm libgnucash/tax/de_DE/txf.scm -libgnucash/tax/gncmod-locale-tax.c +libgnucash/tax/gnc-locale-tax.c libgnucash/tax/us/tax.scm libgnucash/tax/us/txf-help.scm libgnucash/tax/us/txf.scm