mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
tax - remove gncmod boilerplate
This is now an ordinary shared library * Remove test to load the gnc-module in scheme * Rewrite test to load the module in C to actually test something.
This commit is contained in:
@@ -868,7 +868,7 @@ configure_file(
|
|||||||
add_custom_target(uninstall
|
add_custom_target(uninstall
|
||||||
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
|
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)
|
if (WITH_SQL)
|
||||||
list(APPEND _MODULES gnc-backend-sql)
|
list(APPEND _MODULES gnc-backend-sql)
|
||||||
|
|||||||
@@ -145,6 +145,7 @@ target_link_libraries(gnc-gnome
|
|||||||
gncmod-register-core
|
gncmod-register-core
|
||||||
gncmod-gnome-utils
|
gncmod-gnome-utils
|
||||||
gnc-engine
|
gnc-engine
|
||||||
|
gnc-locale-tax
|
||||||
gnucash-guile
|
gnucash-guile
|
||||||
${Boost_LIBRARIES}
|
${Boost_LIBRARIES}
|
||||||
PkgConfig::GTK3
|
PkgConfig::GTK3
|
||||||
|
|||||||
@@ -36,6 +36,7 @@
|
|||||||
#include "Account.h"
|
#include "Account.h"
|
||||||
#include "gnc-ui-util.h"
|
#include "gnc-ui-util.h"
|
||||||
#include "dialog-utils.h"
|
#include "dialog-utils.h"
|
||||||
|
#include "gnc-locale-tax.h"
|
||||||
#include "gnc-prefs.h"
|
#include "gnc-prefs.h"
|
||||||
#include "gnc-tree-view-account.h"
|
#include "gnc-tree-view-account.h"
|
||||||
#include "gnc-component-manager.h"
|
#include "gnc-component-manager.h"
|
||||||
@@ -145,10 +146,8 @@ typedef struct
|
|||||||
static void
|
static void
|
||||||
initialize_getters (void)
|
initialize_getters (void)
|
||||||
{
|
{
|
||||||
if (!gnc_module_load("gnucash/locale/tax", 0))
|
gnc_locale_tax_init();
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
getters.payer_name_source = scm_c_eval_string ("gnc:txf-get-payer-name-source");
|
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.form = scm_c_eval_string ("gnc:txf-get-form");
|
||||||
getters.description = scm_c_eval_string ("gnc:txf-get-description");
|
getters.description = scm_c_eval_string ("gnc:txf-get-description");
|
||||||
|
|||||||
@@ -74,6 +74,7 @@ set(app_utils_ALL_SOURCES ${app_utils_SOURCES} ${app_utils_HEADERS} ${app_utils_
|
|||||||
set(app_utils_ALL_LIBRARIES
|
set(app_utils_ALL_LIBRARIES
|
||||||
gnc-engine
|
gnc-engine
|
||||||
gnc-module
|
gnc-module
|
||||||
|
gnc-locale-tax
|
||||||
gnucash-guile
|
gnucash-guile
|
||||||
${GIO_LDFLAGS}
|
${GIO_LDFLAGS}
|
||||||
${LIBXML2_LDFLAGS}
|
${LIBXML2_LDFLAGS}
|
||||||
|
|||||||
@@ -53,6 +53,7 @@
|
|||||||
#include "gnc-engine.h"
|
#include "gnc-engine.h"
|
||||||
#include "gnc-euro.h"
|
#include "gnc-euro.h"
|
||||||
#include "gnc-hooks.h"
|
#include "gnc-hooks.h"
|
||||||
|
#include "gnc-locale-tax.h"
|
||||||
#include "gnc-session.h"
|
#include "gnc-session.h"
|
||||||
#include "engine-helpers.h"
|
#include "engine-helpers.h"
|
||||||
#include "gnc-locale-utils.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)
|
if (get_form == SCM_UNDEFINED)
|
||||||
{
|
{
|
||||||
GNCModule module;
|
|
||||||
const gchar *tax_module;
|
const gchar *tax_module;
|
||||||
/* load the tax info
|
/* load the tax info */
|
||||||
Note that the module "gnucash/locale/tax" will handle selecting
|
gnc_locale_tax_init ();
|
||||||
the proper locale specific tax info */
|
|
||||||
module = gnc_module_load ("gnucash/locale/tax", 0);
|
|
||||||
|
|
||||||
g_return_val_if_fail (module, NULL);
|
|
||||||
|
|
||||||
get_form = scm_c_eval_string
|
get_form = scm_c_eval_string
|
||||||
("(false-if-exception gnc:txf-get-form)");
|
("(false-if-exception gnc:txf-get-form)");
|
||||||
|
|||||||
@@ -1,23 +1,24 @@
|
|||||||
add_subdirectory(test)
|
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
|
# Add dependency on config.h
|
||||||
set_source_files_properties (${locale_tax_SOURCES} PROPERTIES OBJECT_DEPENDS ${CONFIG_H})
|
set_source_files_properties (${locale_tax_SOURCES} PROPERTIES OBJECT_DEPENDS ${CONFIG_H})
|
||||||
|
|
||||||
add_library(gncmod-locale-tax ${locale_tax_SOURCES})
|
add_library(gnc-locale-tax ${locale_tax_SOURCES})
|
||||||
target_link_libraries(gncmod-locale-tax gnc-module ${GLIB2_LDFLAGS} ${GUILE_LDFLAGS})
|
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})
|
PRIVATE ${CMAKE_BINARY_DIR}/common ${GUILE_INCLUDE_DIRS})
|
||||||
|
|
||||||
if (APPLE)
|
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()
|
endif()
|
||||||
|
|
||||||
install(TARGETS gncmod-locale-tax
|
install(TARGETS gnc-locale-tax
|
||||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/gnucash
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/gnucash
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||||
# No headers to install
|
# No headers to install
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
* gncmod-locale-tax.c
|
* gnc-locale-tax.c
|
||||||
* module definition/initialization for us tax info
|
* hack to load the proper guile based tax system
|
||||||
*
|
*
|
||||||
* Copyright (c) 2001 Linux Developers Group, Inc.
|
* Copyright (c) 2019 Geert Janssens <geert@kobaltwit.be>
|
||||||
*********************************************************************/
|
*********************************************************************/
|
||||||
/********************************************************************\
|
/********************************************************************\
|
||||||
* This program is free software; you can redistribute it and/or *
|
* This program is free software; you can redistribute it and/or *
|
||||||
@@ -28,45 +28,15 @@
|
|||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#include <gmodule.h>
|
|
||||||
#include <libguile.h>
|
#include <libguile.h>
|
||||||
|
#include <glib.h>
|
||||||
|
|
||||||
#include "gnc-module.h"
|
#include "gnc-locale-tax.h"
|
||||||
#include "gnc-module-api.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 *
|
void
|
||||||
libgncmod_locale_tax_gnc_module_description(void)
|
gnc_locale_tax_init(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)
|
|
||||||
{
|
{
|
||||||
/* This is a very simple hack that loads the (new, special) German
|
/* This is a very simple hack that loads the (new, special) German
|
||||||
tax definition file in a German locale, or (default) loads the
|
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);
|
gboolean is_de_DE = (strncmp(thislocale, "de_DE", 5) == 0);
|
||||||
# endif /* G_OS_WIN32 */
|
# endif /* G_OS_WIN32 */
|
||||||
if (is_de_DE)
|
if (is_de_DE)
|
||||||
lmod("(gnucash locale de_DE tax)");
|
scm_c_use_module("gnucash locale de_DE tax");
|
||||||
else
|
else
|
||||||
lmod("(gnucash locale us tax)");
|
scm_c_use_module("gnucash locale us tax");
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
libgncmod_locale_tax_gnc_module_end(int refcount)
|
|
||||||
{
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|||||||
30
libgnucash/tax/gnc-locale-tax.h
Normal file
30
libgnucash/tax/gnc-locale-tax.h
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
/*********************************************************************
|
||||||
|
* gnc-locale-tax.h -
|
||||||
|
* a simple hack to load the proper guile base tax system
|
||||||
|
*
|
||||||
|
* Copyright 2019 Geert Janssens <geert@kobaltwit.be>
|
||||||
|
*
|
||||||
|
* 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
|
||||||
@@ -1,22 +1,10 @@
|
|||||||
set(LOCALE_TAX_TEST_INCLUDE_DIRS "")
|
set(LOCALE_TAX_TEST_INCLUDE_DIRS ${GUILE_INCLUDE_DIRS})
|
||||||
set(LOCALE_TAX_TEST_LIBS "")
|
set(LOCALE_TAX_TEST_LIBS
|
||||||
|
gnc-engine
|
||||||
|
gnc-locale-tax
|
||||||
|
${GUILE_LDFLAGS})
|
||||||
|
|
||||||
gnc_add_test(test-link-module-tax-us test-link-module.c
|
gnc_add_test_with_guile(test-link-module-tax-us test-link-module.c
|
||||||
LOCALE_TAX_TEST_INCLUDE_DIRS LOCALE_TAX_TEST_LIBS
|
LOCALE_TAX_TEST_INCLUDE_DIRS LOCALE_TAX_TEST_LIBS)
|
||||||
)
|
|
||||||
|
|
||||||
# FIXME why is this test not run ?
|
set_dist_list(test_locale_tax_DIST CMakeLists.txt test-link-module.c)
|
||||||
#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)
|
|
||||||
|
|||||||
@@ -18,9 +18,30 @@
|
|||||||
* *
|
* *
|
||||||
\********************************************************************/
|
\********************************************************************/
|
||||||
|
|
||||||
int
|
#include "gnc-locale-tax.h"
|
||||||
main(int argc, char ** argv)
|
|
||||||
|
#include <config.h>
|
||||||
|
#include <glib.h>
|
||||||
|
#include <qof.h>
|
||||||
|
#include <libguile.h>
|
||||||
|
|
||||||
|
static void
|
||||||
|
guile_main (void *closure, int argc, char **argv)
|
||||||
{
|
{
|
||||||
return 0;
|
gnc_locale_tax_init();
|
||||||
|
|
||||||
|
scm_c_lookup ("gnc:txf-get-description");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|||||||
@@ -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)))
|
|
||||||
@@ -41,6 +41,7 @@
|
|||||||
|
|
||||||
|
|
||||||
(use-modules (gnucash engine))
|
(use-modules (gnucash engine))
|
||||||
|
(use-modules (gnucash core-utils))
|
||||||
(use-modules (gnucash app-utils))
|
(use-modules (gnucash app-utils))
|
||||||
(use-modules (srfi srfi-2))
|
(use-modules (srfi srfi-2))
|
||||||
|
|
||||||
|
|||||||
@@ -690,7 +690,7 @@ libgnucash/gnc-module/gnc-module.c
|
|||||||
libgnucash/tax/de_DE/tax.scm
|
libgnucash/tax/de_DE/tax.scm
|
||||||
libgnucash/tax/de_DE/txf-help.scm
|
libgnucash/tax/de_DE/txf-help.scm
|
||||||
libgnucash/tax/de_DE/txf.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/tax.scm
|
||||||
libgnucash/tax/us/txf-help.scm
|
libgnucash/tax/us/txf-help.scm
|
||||||
libgnucash/tax/us/txf.scm
|
libgnucash/tax/us/txf.scm
|
||||||
|
|||||||
Reference in New Issue
Block a user