Blame docs/development.txt

Packit Service 2781ba
Development
Packit Service 2781ba
===========
Packit Service 2781ba
Packit Service 2781ba
image::images/GEGL.png[GEGL]
Packit Service 2781ba
*#Development#*
Packit Service 2781ba
Packit Service 2781ba
This document describes some handy things to know when developing the gegl internals.
Packit Service 2781ba
Parts of it is copy-paste of emails on the gegl developer list.
Packit Service 2781ba
Packit Service 2781ba
== Setting up
Packit Service 2781ba
Packit Service 2781ba
=== Ubuntu 8.10
Packit Service 2781ba
Setup instructions for Ubuntu 8.10 Intrepid Ibex
Packit Service 2781ba
Packit Service 2781ba
To install the mandatory dependencies:
Packit Service 2781ba
Packit Service 2781ba
 $ sudo apt-get install libtool automake glib libglib2.0-dev libpng12-dev libgtk2.0-dev git
Packit Service 2781ba
Packit Service 2781ba
Some of the other dependencies:
Packit Service 2781ba
Packit Service 2781ba
 $ sudo apt-get install asciidoc enscript libjpeg62 libopenraw graphviz-dev
Packit Service 2781ba
Packit Service 2781ba
For running gegl the GEGL_PATH, which is used for dynamically loading the 
Packit Service 2781ba
operations, has to be set:
Packit Service 2781ba
Packit Service 2781ba
 $ export GEGL_PATH=~/Dev/gegl-dev/operations/
Packit Service 2781ba
Packit Service 2781ba
=== BABL
Packit Service 2781ba
Packit Service 2781ba
When using a development version of babl, gegl has to know from where to get it.
Packit Service 2781ba
This is done by setting the BABL_LIBS environment variable before (or during
Packit Service 2781ba
as shown below) running gegl's autogen.sh:
Packit Service 2781ba
Packit Service 2781ba
 $ ./autogen.sh BABL_LIBS=~/Dev/babl/babl/.libs/libbabl-0.0.so.0.23.0 CFLAGS="-O0"
Packit Service 2781ba
Packit Service 2781ba
Then when running the program, the babl library automatically loads extensions
Packit Service 2781ba
that are either located in the BABL_HOME directory or in the default installation
Packit Service 2781ba
directory, in mentioned order of preference.
Packit Service 2781ba
Packit Service 2781ba
 $ export BABL_HOME=~/Dev/babl/extensions
Packit Service 2781ba
Packit Service 2781ba
=== Netbeans 6.5
Packit Service 2781ba
Packit Service 2781ba
There are some key points to consider when setting up GEGL in an IDE
Packit Service 2781ba
(tested on Netbeans):
Packit Service 2781ba
Packit Service 2781ba
- have to configure the IDE to use the autogen.sh as configure script
Packit Service 2781ba
- normally have to use gegl/bin/.libs/gegl as the executable,
Packit Service 2781ba
 not gegl/bin/gegl which is a script.
Packit Service 2781ba
- in some (?) case has to use bin/.libs/lt-gegl as the executable, which is some
Packit Service 2781ba
 kind of relinked gegl binary
Packit Service 2781ba
Packit Service 2781ba
== Debugging
Packit Service 2781ba
Packit Service 2781ba
By default gegl and babl uses the flag -g for debug instrumentation, but however
Packit Service 2781ba
it doesn't use the -O0 flag for turning off optimisations. This leads to unexpected
Packit Service 2781ba
jumps in the code when stepping in a debugger. You have to feed this flag to
Packit Service 2781ba
autogen:
Packit Service 2781ba
Packit Service 2781ba
 $ ./autogen.sh CFLAGS="-O0"
Packit Service 2781ba
 $ make
Packit Service 2781ba
Packit Service 2781ba
=== Debug output
Packit Service 2781ba
Packit Service 2781ba
GEGL has built in mechanisms for logging debug information.
Packit Service 2781ba
Packit Service 2781ba
 GEGL_NOTE (CACHE, "foo %s", bar);
Packit Service 2781ba
 GEGL_TIMESTAMP(PROCESSOR);
Packit Service 2781ba
 GEGL_MARK()
Packit Service 2781ba
Packit Service 2781ba
Where CACHE and PROCESSOR is used the following logging domains are available:
Packit Service 2781ba
Packit Service 2781ba
 PROCESS, CACHE, BUFFER_LOAD, BUFFER_SAVE, TILE_BACKEND and PROCESSOR
Packit Service 2781ba
Packit Service 2781ba
Actual printing of these can be enabled by setting the GEGL_DEBUG
Packit Service 2781ba
environment variable like:
Packit Service 2781ba
Packit Service 2781ba
 GEGL_DEBUG=processor,cache
Packit Service 2781ba
Packit Service 2781ba
or even
Packit Service 2781ba
Packit Service 2781ba
 GEGL_DEBUG=all
Packit Service 2781ba
Packit Service 2781ba
There are also a few functions that are useful as you debug from
Packit Service 2781ba
within a debugger such as GDB. In GDB for example, you call a function
Packit Service 2781ba
interactively in the prompt, while a breakpoint is hit for example, by
Packit Service 2781ba
typing
Packit Service 2781ba
Packit Service 2781ba
  print function_name(args)
Packit Service 2781ba
Packit Service 2781ba
Some useful functions are:
Packit Service 2781ba
Packit Service 2781ba
* *gegl_dot_node_to_png_default()* Writes a PNG to /tmp/node.png with
Packit Service 2781ba
  the dependency graph for the passed node
Packit Service 2781ba
* *gegl_node_dump_depends_on()* Dumps to stdout the nodes that the
Packit Service 2781ba
  passed node depends on. With this you can work yourself backwards in
Packit Service 2781ba
  a dependency graph.
Packit Service 2781ba
* *gegl_node_get_debug_name()* Prints a debug string representation of
Packit Service 2781ba
   a node.
Packit Service 2781ba
Packit Service 2781ba
=== Graphviz export
Packit Service 2781ba
The gegl library has a utility that permits to export the DAG into a graphviz
Packit Service 2781ba
format. Graphviz is a library that converts graph descriptions in textual format
Packit Service 2781ba
into an image. See http://www.graphviz.org/[graphviz website]
Packit Service 2781ba
Packit Service 2781ba
It is done using:
Packit Service 2781ba
Packit Service 2781ba
 #include "../gegl/gegl-dot.h"
Packit Service 2781ba
 /* for printing the dot output, note that gegl_node is a GeglNode pointer */
Packit Service 2781ba
 gchar *dot_output = gegl_to_dot( gegl_node );
Packit Service 2781ba
 printf( "%s\n", dot_output );
Packit Service 2781ba
 g_free( dot_output );
Packit Service 2781ba
Packit Service 2781ba
For creating the graph image:
Packit Service 2781ba
Packit Service 2781ba
 $ gegl --file gaussian-blur.xml --output out.png | dot -Tpng > gb.png
Packit Service 2781ba
Packit Service 2781ba
This is the gaussian-blur.xml file:
Packit Service 2781ba
Packit Service 2781ba
 
Packit Service 2781ba
 <gegl>
Packit Service 2781ba
 	<node operation='gegl:gaussian-blur'>
Packit Service 2781ba
 		<params>
Packit Service 2781ba
 			<param name='std-dev-x'>0.999</param>
Packit Service 2781ba
 			<param name='std-dev-y'>0.999</param>
Packit Service 2781ba
 		</params>
Packit Service 2781ba
 	</node>
Packit Service 2781ba
 	<node operation='gegl:load'>
Packit Service 2781ba
 		<params>
Packit Service 2781ba
 			<param name='path'>in.png</param>
Packit Service 2781ba
 		</params>
Packit Service 2781ba
 	</node>
Packit Service 2781ba
 </gegl>
Packit Service 2781ba
Packit Service 2781ba
link:images/gaussian-blur-graph.png[Resulting graph].
Packit Service 2781ba
Packit Service 2781ba
You can also just call the function gegl_dot_node_to_png() directly
Packit Service 2781ba
from within gdb to show the graphviz graph of a node and its
Packit Service 2781ba
dependencies.
Packit Service 2781ba
Packit Service 2781ba
== Tests
Packit Service 2781ba
Packit Service 2781ba
There are regression tests in the subfolder `tests`. These are run
Packit Service 2781ba
with `make check`
Packit Service 2781ba
Packit Service 2781ba
=== Composition tests
Packit Service 2781ba
Packit Service 2781ba
The tests under `tests/compositions` are easy-to-write high-level
Packit Service 2781ba
system tests for GEGL and its operations. Together with our
Packit Service 2781ba
http://gimptest.flamingtext.com:8080/job/gegl-distcheck/[Jenkins
Packit Service 2781ba
server] that runs all our tests each night, the composition tests make
Packit Service 2781ba
a powerful framework for detecting regressions.
Packit Service 2781ba
Packit Service 2781ba
==== Adding a composition test
Packit Service 2781ba
Packit Service 2781ba
To add a composition test for a operation called `gegl:new-operation`,
Packit Service 2781ba
do the following:
Packit Service 2781ba
Packit Service 2781ba
. Create a GEGL XML file `tests/compositions/new-operation.xml` (will
Packit Service 2781ba
  typically look approximately like `tests/compositions/pixelise.xml`)
Packit Service 2781ba
. Produce a reference image: `cd tests/compositions; gegl -o
Packit Service 2781ba
  /tmp/new-operation.png new-operation.xml` (make sure your operation
Packit Service 2781ba
  is installed so `gegl` finds it)
Packit Service 2781ba
. Manually inspect the reference image `/tmp/new-operation.png` and
Packit Service 2781ba
  move it to `tests/compositions/reference` if it looks like you expect
Packit Service 2781ba
. Add `run-new-operation.xml.sh` to the `TESTS` variable in
Packit Service 2781ba
  `tests/compositions/Makefile.am`
Packit Service 2781ba
. Run `make check` in `tests/compositions` to verify that your test
Packit Service 2781ba
  works (note that you must have configured GEGL with `autogen.sh` in
Packit Service 2781ba
  order for your change to the `TESTS` variable to be taken into
Packit Service 2781ba
  account)
Packit Service 2781ba
Packit Service 2781ba
And you're done. Do not manually create `run-new-operation.xml.sh`, it
Packit Service 2781ba
will be created automatically for you during build time. It will run
Packit Service 2781ba
`gegl` with `tests/compositions/new-operation.xml` and compare the
Packit Service 2781ba
result with `tests/compositions/reference/new-operation.png`. If the
Packit Service 2781ba
result differs, the test will fail, and mails will be sent to the GEGL
Packit Service 2781ba
maintainers. As stated above, this test will run each night, so if
Packit Service 2781ba
someone breaks your contributed GEGL operation, it will be discovered
Packit Service 2781ba
at most 24 hours later, making it easy to fix, either by reverting the
Packit Service 2781ba
bogus commit or by adjusting it.
Packit Service 2781ba
Packit Service 2781ba
An example of a commit that adds a composition test for a GEGL
Packit Service 2781ba
operation is
Packit Service 2781ba
http://git.gnome.org/browse/gegl/commit/?id=13e17712529fb714edcfd67e559bf46b622ff31d[Add
Packit Service 2781ba
composition test for gegl:gamma].
Packit Service 2781ba
Packit Service 2781ba
== Documentation
Packit Service 2781ba
Packit Service 2781ba
This document describes how to document GEGL using it's build system.
Packit Service 2781ba
Packit Service 2781ba
There are three utilities used:
Packit Service 2781ba
Packit Service 2781ba
. http://www.methods.co.nz/asciidoc/[asciidoc] - used for generating html from text files
Packit Service 2781ba
. http://www.codento.com/people/mtr/genscript/[enscript] - used for converting source files (.c/.h) to html
Packit Service 2781ba
. a home-made ruby script - used for generating api documentation (not yet documented here)
Packit Service 2781ba
Packit Service 2781ba
All documentation resources are placed in /doc and the generation is controlled by the file Makefile.am
Packit Service 2781ba
Packit Service 2781ba
=== asciidoc
Packit Service 2781ba
Packit Service 2781ba
This example will show how this howto was added.
Packit Service 2781ba
Packit Service 2781ba
- Add in `Makefile.am` a new target named `documentation-howto.html` in
Packit Service 2781ba
the existing list of html files to generate:
Packit Service 2781ba
Packit Service 2781ba
  if HAVE_ASCIIDOC
Packit Service 2781ba
  	HTML_FILES += index.html documentation-howto.html
Packit Service 2781ba
  endif
Packit Service 2781ba
Packit Service 2781ba
- Add in `Makefile.am` the target:
Packit Service 2781ba
Packit Service 2781ba
 documentation-howto.html: documentation-howto.txt
Packit Service 2781ba
 if HAVE_ASCIIDOC
Packit Service 2781ba
 	@echo "HTML: $@"
Packit Service 2781ba
 	cp $< $@
Packit Service 2781ba
 	$(ASCIIDOC) --unsafe  -o $@ -a stylesdir=`pwd` -a toc -a theme=gegl -a quirks! $<
Packit Service 2781ba
 else
Packit Service 2781ba
 	@echo "*** asciidoc must be available in order to make dist"
Packit Service 2781ba
 	@false
Packit Service 2781ba
 endif
Packit Service 2781ba
Packit Service 2781ba
- Create a new `documentation-howto.txt` file with this content:
Packit Service 2781ba
Packit Service 2781ba
 == Documentation howto
Packit Service 2781ba
Packit Service 2781ba
 This document describes how to document GEGL using it's build system.
Packit Service 2781ba
Packit Service 2781ba
- Type `make` and the `documentation-howto.txt` will be converted into `documentation-howto.html`
Packit Service 2781ba
Packit Service 2781ba
=== enscript
Packit Service 2781ba
Packit Service 2781ba
TODO
Packit Service 2781ba
This example will show how a new c/h file is converted into html using enscript
Packit Service 2781ba
Packit Service 2781ba
== Inheritance tree
Packit Service 2781ba
Packit Service 2781ba
Here is an automatically generated inheritance tree of the gobjects used by gegl:
Packit Service 2781ba
link:images/inheritance.png[GEGL inheritance tree]
Packit Service 2781ba
Note that the operations are also gobjects, but they are not included in the inheritance tree.