2000-08-22 18:43:56 -05:00
|
|
|
Hacking Guidelines
|
|
|
|
==================
|
|
|
|
|
|
|
|
This document is an introduction to hacking on GnuCash.
|
|
|
|
|
|
|
|
Related Documents
|
|
|
|
-----------------
|
|
|
|
|
|
|
|
In addition to this file, you should read the README file, which
|
2021-11-13 04:17:12 -06:00
|
|
|
explains the details of getting the git source, building GnuCash,
|
2000-08-22 18:43:56 -05:00
|
|
|
and creating patches for submission.
|
|
|
|
|
|
|
|
Coding Style Conventions
|
|
|
|
------------------------
|
2022-02-19 11:49:01 -06:00
|
|
|
Please refer to https://wiki.gnucash.org/wiki/CodingStandard.
|
2002-11-04 01:47:03 -06:00
|
|
|
|
2007-03-08 20:46:04 -06:00
|
|
|
==============
|
2003-09-12 08:31:04 -05:00
|
|
|
TIPS AND HINTS
|
2007-03-08 20:46:04 -06:00
|
|
|
==============
|
2002-11-04 01:47:03 -06:00
|
|
|
|
2018-01-26 09:06:29 -06:00
|
|
|
Building GnuCash in-tree
|
|
|
|
------------------------
|
|
|
|
This is generally discouraged. You should always use a separate build directory,
|
|
|
|
preferably outside of the source directory. If you really want a build directory
|
|
|
|
inside your source directory, make it a hidden one (starting with a '.'), to
|
|
|
|
keep intltool from incorrectly picking up translatable strings from the build directory.
|
|
|
|
|
2007-03-18 14:39:12 -05:00
|
|
|
Starting GnuCash from the build tree
|
2003-09-12 08:31:04 -05:00
|
|
|
------------------------------------
|
2018-01-26 09:06:29 -06:00
|
|
|
This should mostly work, but there may be corner cases where it behaves differently from
|
|
|
|
running gnucash from the target installation directory. You can tell cmake which
|
|
|
|
install directory to use via the command line switch '-DCMAKE_INSTALL_PREFIX='
|
|
|
|
Don't use '/usr' or '/usr/local' unless you're a package maintainer for a distro.
|
|
|
|
Instead choose /opt/gnc/git/ or even $HOME/gnc/git (or something similar).
|
2003-09-12 08:31:04 -05:00
|
|
|
|
2007-03-08 20:46:04 -06:00
|
|
|
Getting Trace Messages From GnuCash
|
|
|
|
-----------------------------------
|
2018-01-26 09:06:29 -06:00
|
|
|
See the doxygen comments in libgnucash/engine/qoflog.h (and .c)
|
2003-09-12 08:31:04 -05:00
|
|
|
|
2003-08-17 12:20:29 -05:00
|
|
|
Starting GnuCash in GDB
|
2003-08-17 15:29:25 -05:00
|
|
|
-----------------------
|
2006-01-15 16:19:13 -06:00
|
|
|
To run gdb on an installed version of gnucash (installed in /opt/gnc/unstable:)
|
2003-08-17 12:20:29 -05:00
|
|
|
|
2010-06-30 15:42:02 -05:00
|
|
|
% gdb /opt/gnc/unstable/bin/gnucash
|
|
|
|
|
2005-11-01 21:32:36 -06:00
|
|
|
You'll also probably want to know about these:
|
|
|
|
|
2006-06-14 17:30:38 -05:00
|
|
|
gdb> catch fork
|
|
|
|
gdb> set follow-fork-mode child
|
2005-11-01 21:32:36 -06:00
|
|
|
|
|
|
|
-----
|
|
|
|
It may be the case that running GDB from within emacs doesn't work for you,
|
|
|
|
with the following error:
|
|
|
|
|
2010-06-30 15:42:02 -05:00
|
|
|
[C-u M-x gdb /opt/gnucash-cvs/bin/gnucash
|
2005-11-01 21:32:36 -06:00
|
|
|
...in buffer *gud-gdb*:]
|
|
|
|
|
2006-06-14 17:30:38 -05:00
|
|
|
(gdb) attach <pid>
|
2005-11-01 21:32:36 -06:00
|
|
|
|
|
|
|
jsled needed to re-define a gud.el function as such:
|
|
|
|
|
|
|
|
(defun gud-gdb-massage-args (file args)
|
|
|
|
(let ((l (copy-list args)))
|
|
|
|
(nconc l (list "-cd" (expand-file-name default-directory) "-fullname"))))
|
|
|
|
|
2007-08-18 10:28:18 -05:00
|
|
|
jsled does not need the above with emacs-22, thankfully. It was getting quite tiresome.
|
|
|
|
|
2003-08-17 12:20:29 -05:00
|
|
|
|
2003-08-17 15:29:25 -05:00
|
|
|
Using Electric Fence with GnuCash
|
|
|
|
---------------------------------
|
2018-01-26 09:06:29 -06:00
|
|
|
There are currently no rules in our build system to build and run gnucash
|
|
|
|
or unit tests with Electric Fence.
|
2003-08-17 15:29:25 -05:00
|
|
|
|
2018-03-10 12:39:20 -06:00
|
|
|
It should probably be relatively straightforward to add this as all it
|
2018-01-26 09:06:29 -06:00
|
|
|
needs is to link with libefence.so (-lefence).
|
2003-08-17 15:29:25 -05:00
|
|
|
|
Fix typos for gnuchash/ doc/ bindings/ and misc.
Typos found via `codespell -q 3 -D ~/Projects/codespell/codespell_lib/data/dictionary.txt -S *.po,./po,*.min.js,./ChangeLog*,./NEWS,./doc/README*,./AUTHORS,./libgnucash/tax/us/txf-de*,./data/accounts -L ans,cas,dragable,gae,iff,iif,mut,nd,numer,startd,stoll`
2019-09-13 19:26:03 -05:00
|
|
|
Fedora 27 ships an ElectricFence package containing that library and also
|
|
|
|
an executable 'ef' to run an arbitrary program with Electric Fence
|
|
|
|
guarding enabled. I have given it a quick spin on gnucash but it immediately
|
2018-01-26 09:06:29 -06:00
|
|
|
crashes. I haven't investigated whether this is because I should first have
|
|
|
|
linked gnucash with -lefence or because a real problem in GnuCash code.
|
2003-08-17 15:29:25 -05:00
|
|
|
|
2003-09-12 08:31:04 -05:00
|
|
|
|
2003-08-17 15:29:25 -05:00
|
|
|
Using Valgrind with GnuCash
|
|
|
|
---------------------------
|
2007-08-18 10:28:18 -05:00
|
|
|
-- run ${prefix}/bin/gnucash-valgrind
|
2002-11-04 01:47:03 -06:00
|
|
|
|
2003-08-17 15:29:25 -05:00
|
|
|
However, I did not find valgrind to be useful. It reported a bunch of
|
2005-11-01 21:32:36 -06:00
|
|
|
guile bugs, some g_hash_table bugs, and then the program exited prematurely
|
2010-02-02 10:18:23 -06:00
|
|
|
for no apparent reason. :-(
|
2003-08-17 15:29:25 -05:00
|
|
|
|
2010-02-08 11:30:21 -06:00
|
|
|
For the moment, gnucash-valgrind uses the suppressions in
|
|
|
|
src/debug/valgrind/valgrind-*.supp
|
2004-03-10 19:17:14 -06:00
|
|
|
|
2010-02-08 11:30:21 -06:00
|
|
|
For valgrind-gnucash.supp, this comment was made (but is perhaps outdated
|
|
|
|
by now ?):
|
2004-03-10 19:17:14 -06:00
|
|
|
This file needs to be cleaned up in two ways:
|
|
|
|
|
2010-02-02 10:18:23 -06:00
|
|
|
1/ There are a bunch of duplicate suppressions in the file.
|
|
|
|
* The suppressions in place were auto-generated by valgrind itself
|
2004-03-10 19:17:14 -06:00
|
|
|
[--gen-suppressions=yes], and it makes no effort to output the
|
|
|
|
suppression only once.
|
|
|
|
|
2010-02-02 10:18:23 -06:00
|
|
|
2/ There are a bunch of suppressions which need to not be suppressions, but
|
2004-03-10 19:17:14 -06:00
|
|
|
instead just not be generated by valgrind.
|
2006-03-16 09:38:46 -06:00
|
|
|
|
|
|
|
|
|
|
|
Look up exported and imported symbols
|
|
|
|
-------------------------------------
|
|
|
|
These commands may be useful to find out the library that actually
|
|
|
|
exported a particular symbol, and to check which import symbol one
|
|
|
|
particular library depends upon and where they are imported
|
|
|
|
from. Run these from the top-level of the build tree.
|
2018-01-26 09:06:29 -06:00
|
|
|
Note "lib64" below should be "lib" for a 32-bit build.
|
2006-03-16 09:38:46 -06:00
|
|
|
|
|
|
|
# Create a table of all exported symbols and where they come from
|
|
|
|
nm -A `find . -name '*.so'` | grep ' T ' | \
|
|
|
|
sed 's/^\([^:]*\).* \([^ ]*\)$/\1: \2/' > exportedsymbols
|
|
|
|
|
|
|
|
# For a particular library, check symbol import requirements,
|
|
|
|
# listing all symbols (needs the file from above)
|
2018-01-26 09:06:29 -06:00
|
|
|
A=lib64/libgnc-module.so && echo "$A requirements:" \
|
2006-03-16 09:38:46 -06:00
|
|
|
&& nm $A | grep ' U ' | sed 's/^.* \([^ ]*\)$/\1/' | \
|
|
|
|
grep -wFf- exportedsymbols
|
|
|
|
|
|
|
|
# For a particular library, check import requirements,
|
|
|
|
# summarized by library
|
2018-01-26 09:06:29 -06:00
|
|
|
A=lib64/libgnc-module.so && echo "$A requirements:" \
|
2006-03-16 09:38:46 -06:00
|
|
|
&& nm $A | grep ' U ' | sed 's/^.* \([^ ]*\)$/\1/' | \
|
|
|
|
grep -wFf- exportedsymbols | cut -d: -f1 | sort | uniq
|
|
|
|
|
|
|
|
# For a particular library, check import requirements,
|
2018-01-26 09:06:29 -06:00
|
|
|
# summarized by library, formatted for a cmake TARGET_LINK_LIBRARIES command
|
|
|
|
A=lib64/libgnc-gnome.so && echo "$A target link libraries:" \
|
2006-03-16 09:38:46 -06:00
|
|
|
&& nm $A | grep ' U ' | sed 's/^.* \([^ ]*\)$/\1/' | \
|
|
|
|
grep -wFf- exportedsymbols | cut -d: -f1 | sort | uniq | \
|
2018-01-26 09:06:29 -06:00
|
|
|
sed 's!.*/lib! !' | sed 's/.so$//'
|
2006-03-16 09:38:46 -06:00
|
|
|
|
|
|
|
# List all import requirements summarized by library for a full
|
|
|
|
# recursive directory tree
|
2018-01-26 09:06:29 -06:00
|
|
|
for A in `find lib64 -name '*.so'`; do \
|
2006-03-16 09:38:46 -06:00
|
|
|
echo -e "\n##$A requirements:" && nm $A | grep ' U ' | \
|
|
|
|
sed 's/^.* \([^ ]*\)$/\1/' | grep -wFf- exportedsymbols | \
|
|
|
|
cut -d: -f1 | sort | uniq; done
|
|
|
|
|
2014-02-20 00:11:22 -06:00
|
|
|
XCode project
|
|
|
|
-------------
|
|
|
|
|
|
|
|
There is an XCode project available in gnucash.xcodeproj at the root of the
|
|
|
|
source tree. This project can be used with XCode on a Macintosh to debug
|
|
|
|
GnuCash. It is not set up to build GnuCash, but only to debug it. Building must
|
|
|
|
be done using the normal command line tools.
|
|
|
|
|
2018-01-26 09:06:29 -06:00
|
|
|
Note this XCode project has not been updated since the big directory restructuring
|
|
|
|
preceding the 2.7.1 release. So it will currently not find source files where
|
|
|
|
it's expecting them.
|
|
|
|
|
2014-02-20 00:11:22 -06:00
|
|
|
This project is designed to be used with the X Window version of GnuCash, not
|
|
|
|
the native Quartz version. To use it you must build and install GnuCash into
|
|
|
|
directories "build" and "install" parallel to the source directory. Furthermore
|
|
|
|
the architecture dependent parts of the install are put in a subdirectory
|
|
|
|
"install/darwin".
|
|
|
|
|
|
|
|
To build, then, if the source directory is somewhere/gnucash you must create the
|
|
|
|
directories somewhere/build/darwin and somewhere/install/darwin/bin, cd into
|
|
|
|
somewhere/build/darwin and execute
|
|
|
|
|
|
|
|
../../gnucash/configure --prefix=../../install \
|
|
|
|
--exec-prefix=../../install/bin \
|
|
|
|
--enable-debug \
|
|
|
|
...other options...
|
|
|
|
make
|
|
|
|
make install
|
|
|
|
|
|
|
|
This will build and install a copy of GnuCash that can be debugged using the
|
|
|
|
XCode project.
|
|
|
|
|
|
|
|
The debug target in the project is set with a build tool of /usr/bin/true so
|
|
|
|
building in XCode won't hurt anything, it just won't do much. It is also set to
|
|
|
|
not launch GnuCash automatically, but rather to wait for it to be launched
|
|
|
|
manually. This lets you run it from a command prompt and see the console output
|
|
|
|
which can often be useful. Hence to initiate a debugging session in XCode, tell
|
|
|
|
XCode to run GnuCash then go to a terminal window and launch install/darwin/bin/gnucash
|
|
|
|
with whatever options you want. XCode will notice that it has been launched and
|
|
|
|
attach to the process.
|
|
|
|
|
|
|
|
Since there seems to be no way to make the path to the executable a relative
|
|
|
|
path, you must make one change to the debug scheme before you can run gnucash
|
|
|
|
under XCode. In XCode 5 (other versions may be different) go to
|
|
|
|
Product->Scheme->Edit Scheme and select the "info" tab of the "Run gnucash"
|
|
|
|
pane. Select "Other..." in the "Executable" menu and select the installed binary
|
|
|
|
for gnucash in the resulting file open dialog. This should be
|
|
|
|
install/darwin/bin/gnucash as described above. This, and the act of opening the
|
|
|
|
project in XCode, will change some of the files in the XCode project directory.
|
|
|
|
You can, or course, commit these locally, but please don't push them upstream.
|