| 
									
										
										
										
											2000-08-22 23:43:56 +00: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 11:17:12 +01:00
										 |  |  | explains the details of getting the git source, building GnuCash, | 
					
						
							| 
									
										
										
										
											2000-08-22 23:43:56 +00:00
										 |  |  | and creating patches for submission. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Coding Style Conventions | 
					
						
							|  |  |  | ------------------------ | 
					
						
							| 
									
										
										
										
											2022-02-19 09:49:01 -08:00
										 |  |  | Please refer to https://wiki.gnucash.org/wiki/CodingStandard. | 
					
						
							| 
									
										
										
										
											2002-11-04 07:47:03 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-03-09 02:46:04 +00:00
										 |  |  | ============== | 
					
						
							| 
									
										
										
										
											2003-09-12 13:31:04 +00:00
										 |  |  | TIPS AND HINTS | 
					
						
							| 
									
										
										
										
											2007-03-09 02:46:04 +00:00
										 |  |  | ============== | 
					
						
							| 
									
										
										
										
											2002-11-04 07:47:03 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-26 16:06:29 +01: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 19:39:12 +00:00
										 |  |  | Starting GnuCash from the build tree | 
					
						
							| 
									
										
										
										
											2003-09-12 13:31:04 +00:00
										 |  |  | ------------------------------------ | 
					
						
							| 
									
										
										
										
											2018-01-26 16:06:29 +01: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 13:31:04 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-03-09 02:46:04 +00:00
										 |  |  | Getting Trace Messages From GnuCash | 
					
						
							|  |  |  | ----------------------------------- | 
					
						
							| 
									
										
										
										
											2018-01-26 16:06:29 +01:00
										 |  |  | See the doxygen comments in libgnucash/engine/qoflog.h (and .c) | 
					
						
							| 
									
										
										
										
											2003-09-12 13:31:04 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-08-17 17:20:29 +00:00
										 |  |  | Starting GnuCash in GDB | 
					
						
							| 
									
										
										
										
											2003-08-17 20:29:25 +00:00
										 |  |  | ----------------------- | 
					
						
							| 
									
										
										
										
											2006-01-15 22:19:13 +00:00
										 |  |  | To run gdb on an installed version of gnucash (installed in /opt/gnc/unstable:) | 
					
						
							| 
									
										
										
										
											2003-08-17 17:20:29 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-06-30 20:42:02 +00:00
										 |  |  |     % gdb /opt/gnc/unstable/bin/gnucash | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-11-02 03:32:36 +00:00
										 |  |  | You'll also probably want to know about these: | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-06-14 22:30:38 +00:00
										 |  |  |     gdb> catch fork | 
					
						
							|  |  |  |     gdb> set follow-fork-mode child | 
					
						
							| 
									
										
										
										
											2005-11-02 03:32:36 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | ----- | 
					
						
							|  |  |  | It may be the case that running GDB from within emacs doesn't work for you, | 
					
						
							|  |  |  | with the following error: | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-06-30 20:42:02 +00:00
										 |  |  | [C-u M-x gdb /opt/gnucash-cvs/bin/gnucash | 
					
						
							| 
									
										
										
										
											2005-11-02 03:32:36 +00:00
										 |  |  |  ...in buffer *gud-gdb*:] | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-06-14 22:30:38 +00:00
										 |  |  |     (gdb) attach <pid> | 
					
						
							| 
									
										
										
										
											2005-11-02 03:32:36 +00: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 15:28:18 +00:00
										 |  |  | jsled does not need the above with emacs-22, thankfully.  It was getting quite tiresome. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-08-17 17:20:29 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-08-17 20:29:25 +00:00
										 |  |  | Using Electric Fence with GnuCash | 
					
						
							|  |  |  | --------------------------------- | 
					
						
							| 
									
										
										
										
											2018-01-26 16:06:29 +01:00
										 |  |  | There are currently no rules in our build system to build and run gnucash | 
					
						
							|  |  |  | or unit tests with Electric Fence. | 
					
						
							| 
									
										
										
										
											2003-08-17 20:29:25 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-10 19:39:20 +01:00
										 |  |  | It should probably be relatively straightforward to add this as all it | 
					
						
							| 
									
										
										
										
											2018-01-26 16:06:29 +01:00
										 |  |  | needs is to link with libefence.so (-lefence). | 
					
						
							| 
									
										
										
										
											2003-08-17 20:29:25 +00: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 20:26:03 -04: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 16:06:29 +01: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 20:29:25 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-09-12 13:31:04 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-23 15:43:38 +02:00
										 |  |  | Using Valgrind/Callgrind with GnuCash | 
					
						
							|  |  |  | ------------------------------------- | 
					
						
							|  |  |  | This section has been moved to | 
					
						
							|  |  |  | https://wiki.gnucash.org/wiki/Coder_Tools | 
					
						
							| 
									
										
										
										
											2024-05-21 14:48:44 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-03-16 15:38:46 +00: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 16:06:29 +01:00
										 |  |  | Note "lib64" below should be "lib" for a 32-bit build. | 
					
						
							| 
									
										
										
										
											2006-03-16 15:38:46 +00: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 16:06:29 +01:00
										 |  |  | A=lib64/libgnc-module.so && echo "$A requirements:" \ | 
					
						
							| 
									
										
										
										
											2006-03-16 15:38:46 +00:00
										 |  |  |   && nm $A | grep ' U ' | sed 's/^.* \([^ ]*\)$/\1/' | \ | 
					
						
							|  |  |  |   grep -wFf- exportedsymbols | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # For a particular library, check import requirements,  | 
					
						
							|  |  |  | # summarized by library | 
					
						
							| 
									
										
										
										
											2018-01-26 16:06:29 +01:00
										 |  |  | A=lib64/libgnc-module.so && echo "$A requirements:" \ | 
					
						
							| 
									
										
										
										
											2006-03-16 15:38:46 +00: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 16:06:29 +01: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 15:38:46 +00:00
										 |  |  |   && nm $A | grep ' U ' | sed 's/^.* \([^ ]*\)$/\1/' | \ | 
					
						
							|  |  |  |   grep -wFf- exportedsymbols | cut -d: -f1 | sort | uniq | \ | 
					
						
							| 
									
										
										
										
											2018-01-26 16:06:29 +01:00
										 |  |  |   sed 's!.*/lib!  !' | sed 's/.so$//' | 
					
						
							| 
									
										
										
										
											2006-03-16 15:38:46 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | # List all import requirements summarized by library for a full | 
					
						
							|  |  |  | # recursive directory tree | 
					
						
							| 
									
										
										
										
											2018-01-26 16:06:29 +01:00
										 |  |  | for A in `find lib64 -name '*.so'`; do \ | 
					
						
							| 
									
										
										
										
											2006-03-16 15:38:46 +00:00
										 |  |  |   echo -e "\n##$A requirements:" && nm $A | grep ' U ' | \ | 
					
						
							|  |  |  |   sed 's/^.* \([^ ]*\)$/\1/' | grep -wFf- exportedsymbols | \ | 
					
						
							|  |  |  |   cut -d: -f1 | sort | uniq; done |