From c741b073529b24d1d74b08ad89754228cff46f45 Mon Sep 17 00:00:00 2001 From: Geert Janssens Date: Sun, 29 Aug 2010 19:02:57 +0000 Subject: [PATCH] Calculate standard-reports dir internally instead of reading it from the environment. This is a step to make gnucash more run-time relocatable. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@19505 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/bin/Makefile.am | 2 -- src/bin/environment.in | 2 -- src/core-utils/core-utils.i | 3 +++ src/core-utils/core-utils.scm | 1 + src/core-utils/gnc-path.c | 17 ++++++++++++++++- src/core-utils/gnc-path.h | 9 ++++++++- .../standard-reports/standard-reports.scm | 9 +++++---- 7 files changed, 33 insertions(+), 10 deletions(-) diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am index 712fb81b34..6c9c1d7b89 100644 --- a/src/bin/Makefile.am +++ b/src/bin/Makefile.am @@ -101,7 +101,6 @@ gnucash-setup-env: gnucash-setup-env-osx.in ${top_builddir}/config.status Makefi sed < $< > $@.tmp \ -e 's#@-BIN_DIR-@#${bindir}#g' \ -e 's#@-GNC_DBD_DIR-@#${GNC_DBD_DIR}#g' \ - -e 's#@-GNC_STANDARD_REPORTS_DIR-@#${GNC_SHAREDIR}/guile-modules/gnucash/report/standard-reports#g' \ -e 's#@-GNC_GUILE_MODULE_DIR-@#${GNC_SHAREDIR}/guile-modules#g' \ -e 's#@-GNC_SCM_INSTALL_DIR-@#${GNC_SCM_INSTALL_DIR}#g' \ -e 's#@-GNC_LIB_INSTALLDIR-@#${libdir}#' \ @@ -116,7 +115,6 @@ environment: ${GNUCASH_ENVIRONMENT}.in ${top_builddir}/config.status Makefile rm -f $@.tmp sed < $< > $@.tmp \ -e 's#@-BIN_DIR-@#${bindir}#g' \ - -e 's#@-GNC_STANDARD_REPORTS_DIR-@#${GNC_SHAREDIR}/guile-modules/gnucash/report/standard-reports#g' \ -e 's#@-GNC_GUILE_MODULE_DIR-@#${GNC_SHAREDIR}/guile-modules#g' \ -e 's#@-GNC_SCM_INSTALL_DIR-@#${GNC_SCM_INSTALL_DIR}#g' \ -e 's#@-GNC_LIB_INSTALLDIR-@#${libdir}#' \ diff --git a/src/bin/environment.in b/src/bin/environment.in index 8f26fcbb43..b1deecb196 100644 --- a/src/bin/environment.in +++ b/src/bin/environment.in @@ -22,5 +22,3 @@ GUILE_LOAD_PATH={EXTRA_PATH};{GUILE_LOAD_PATH} EXTRA_LIBS={GNC_MODULE_PATH};@-GNC_LIB_INSTALLDIR-@;@-GNC_PKGLIB_INSTALLDIR-@ LD_LIBRARY_PATH={EXTRA_LIBS};{LD_LIBRARY_PATH} DYLD_LIBRARY_PATH={EXTRA_LIBS};{DYLD_LIBRARY_PATH} - -GNC_STANDARD_REPORTS_DIR=@-GNC_STANDARD_REPORTS_DIR-@ diff --git a/src/core-utils/core-utils.i b/src/core-utils/core-utils.i index 6f05cda12b..aede7f62dd 100644 --- a/src/core-utils/core-utils.i +++ b/src/core-utils/core-utils.i @@ -3,6 +3,7 @@ #include #include #include +#include #include SCM scm_init_sw_core_utils_module (void); @@ -15,6 +16,8 @@ gchar * g_find_program_in_path(const gchar *); gboolean gnc_is_debugging(void); +gchar * gnc_path_get_stdreportsdir(void); + void gnc_scm_log_warn(const gchar *); void gnc_scm_log_error(const gchar *); void gnc_scm_log_msg(const gchar *); diff --git a/src/core-utils/core-utils.scm b/src/core-utils/core-utils.scm index 760ff167b0..d284ad07f0 100644 --- a/src/core-utils/core-utils.scm +++ b/src/core-utils/core-utils.scm @@ -10,6 +10,7 @@ (use-modules (sw_core_utils)) (re-export gnc-is-debugging) +(re-export gnc-path-get-stdreportsdir) (re-export g-find-program-in-path) (re-export gnc-utf8?) (re-export gnc-utf8-strip-invalid-strdup) diff --git a/src/core-utils/gnc-path.c b/src/core-utils/gnc-path.c index 2c90b359c7..a8018d7593 100644 --- a/src/core-utils/gnc-path.c +++ b/src/core-utils/gnc-path.c @@ -112,7 +112,7 @@ gchar *gnc_path_get_localedir() return result; } -/** Returns the glade file path, usually +/** Returns the accounts file path, usually * "$prefix/share/gnucash/accounts". * * @returns A newly allocated string. */ @@ -125,6 +125,21 @@ gchar *gnc_path_get_accountsdir() return result; } +/** Returns the file path to the standard + * reports, usually + * "$prefix/share/gnucash/guile-modules/gnucash/report/standard-reports". + * + * @returns A newly allocated string. */ +gchar *gnc_path_get_stdreportsdir() +{ + gchar *pkgdatadir = gnc_path_get_pkgdatadir (); + gchar *result = g_build_filename (pkgdatadir, "guile-modules", + "gnucash", "report", "standard-reports", (char*)NULL); + g_free (pkgdatadir); + //printf("Returning stdreportsdir %s\n", result); + return result; +} + /** Returns the gconf schema config source path, usually * "$prefix/etc/gconf/gconf.xml.defaults". * diff --git a/src/core-utils/gnc-path.h b/src/core-utils/gnc-path.h index c54dacf942..26e36c7bd7 100644 --- a/src/core-utils/gnc-path.h +++ b/src/core-utils/gnc-path.h @@ -68,12 +68,19 @@ gchar *gnc_path_get_gladedir(void); * @returns A newly allocated string. */ gchar *gnc_path_get_localedir(void); -/** Returns the glade file path, usually +/** Returns the accounts file path, usually * "$prefix/share/gnucash/accounts". * * @returns A newly allocated string. */ gchar *gnc_path_get_accountsdir(void); +/** Returns the file path to the standard + * reports, usually + * "$prefix/share/gnucash/guile-modules/gnucash/report/standard-reports". + * + * @returns A newly allocated string. */ +gchar *gnc_path_get_stdreportsdir(void); + /** Returns the gconf schema config source path, usually * "$prefix/etc/gconf/gconf.xml.defaults". * diff --git a/src/report/standard-reports/standard-reports.scm b/src/report/standard-reports/standard-reports.scm index e9329be2f3..272225c328 100644 --- a/src/report/standard-reports/standard-reports.scm +++ b/src/report/standard-reports/standard-reports.scm @@ -9,6 +9,7 @@ (use-modules (ice-9 slib)) (use-modules (srfi srfi-13)) (use-modules (gnucash main)) ;; FIXME: delete after we finish modularizing. +(use-modules (gnucash core-utils)) (export gnc:register-report-create) (export gnc:register-report-hook) @@ -110,18 +111,18 @@ ) ) -;; Return a list of symbols representing reports in the GNC_STANDARD_REPORTS_DIR directory +;; Return a list of symbols representing reports in the standard reports directory ;; ;; Return value: ;; List of symbols for reports (define (get-report-list) (map (lambda (s) (string->symbol s)) - (process-file-list (directory-files (getenv "GNC_STANDARD_REPORTS_DIR"))) + (process-file-list (directory-files (gnc-path-get-stdreportsdir))) ) ) -(gnc:debug "dir-files=" (directory-files (getenv "GNC_STANDARD_REPORTS_DIR"))) -(gnc:debug "processed=" (process-file-list (directory-files (getenv "GNC_STANDARD_REPORTS_DIR")))) +(gnc:debug "dir-files=" (directory-files (gnc-path-get-stdreportsdir))) +(gnc:debug "processed=" (process-file-list (directory-files (gnc-path-get-stdreportsdir)))) (gnc:debug "report-list=" (get-report-list)) (for-each