Skip to content

Devel GTK jhbuild

Simeon Andreev edited this page Feb 23, 2023 · 1 revision

About JHBuild

JHBuild is a tool that compiles gnome modules such as GTK as well as all of it's dependencies.

Often you can't compile the latest versions of GTK because of missing dependencies (see dependency image below). JHBuild automatically pulls required dependencies and compiles them for you. Then you can run command line applications (such as eclipse or individual snippets or the autotester or even gnome calculator) within the context of JHBuild compiled modules.

Gtkbuilddep.png

(This was generated via jhbuild dot gtk+ | dot -Tpng > dep.png

Relevant readings

The information below has been pulled together from various sources. It's useful to skim over them:

  • Getting started guide:

https://wiki.gnome.org/HowDoI/Jhbuild

  • JHbuild for gnome new commer guide:

https://wiki.gnome.org/Newcomers/BuildGnome

  • Developer configuration guide:

https://developer.gnome.org/jhbuild/unstable/config-reference.html.en

Setup

Different guides advise you to set it up slightly differently. In general once JHbuild is set up, it doesn't really matter where you put it since it will be on your PATH.

Source code

First, checkout the source code:

mkdir ~/jhbuild
cd ~/jhbuild
git clone git://git.gnome.org/jhbuild

Install tools to build jhbuild

You should install standard C development tools such as make, python3 etc in order to compile JHBuild. On Fedora you can do so via:

sudo dnf install @c-development @development-tools docbook-xsl gnome-common pygobject2 dbus-python redhat-rpm-config perl-Text-CSV perl-XML-Parser gettext-devel python3-devel xmlto ragel xorg-x11-util-macros xkeyboard config-devel libxslt-devel

(this is list may not be complete, use only as guideline. Tested on Fedora 24).

Build and install

cd jhbuild
./autogen.sh --simple-install
make install

Configure path

JHBuild should have put an executable into ~/.local/bin/jhbuild. Now you need to double check that jhbuild is on your path.

Run echo $PATH in your terminal and ensure that it contains .....:/home/YOURUSER/.local/bin:.....

If it is not, add it to your ~/.bashrc:

export PATH=$PATH:~/.local/bin

To test if you have everything set up correctly, navigate to any directory (eg cd ~/) and execute:

jhbuild sanitycheck

If nothing is printed, life is good.

Install dependencies

JHBuild needs a bunch of packages to do it's functionality properly. For some linux distributions is knows how to install them (ex fedora), for some you have to install them manually.

You can try your luck via:

jhbuild sysdeps --install

After this command, if there are any packages listed in the required section, then you should manually install them. Look for '-devel' packages. Ex for python3 install python3-devel

You can check if you have everything on your system required to build gtk+ via:

jhbuild sysdeps gtk+

Building with JHBuild

You can get JHBuild to build all of gnome if you wanted to via jhbuild build. However this takes hours, instead you want to be selective about what you build.

Common libraries

You should next build some common libraries (ex dconf is required for GTK Inspector to work).

jhbuild build adwaita-icon-theme dconf glib-networking gvfs libcanberra PackageKit

You should re-run the above from time to time.

Building GTK+

The following should automatically clone and build relevant modules and at the end compile gtk+ (about 15 modules).

jhbuild build gtk+

Running applications with compiled libraries

Next you want to run applications that will use the libs that you've just compiled. There are two ways of doing it:

1) JHBuild shell

You can invoke a sub-shell that pre-loads all of the libraries into the path. While in JHBuild shell, what ever you launch will use the compiled modules. ex:

jhbuild shell
eclipse

You can verify that you're using what you've compiled by invoking GTK inspector (CTRL+SHIFT+D) and inspect the version tab.

To exit the jhbuild shell, type exit

Customise jhbuild shell

Sometimes it's not clear if your shell is in JHBuild shell or in a regular shell. $UNDER_JHBUILD will be set to true if you are. A neat trick is to add the following to your ~/.bashrc, which will preappend [jhbuild] to the command prompt when you're in the jhbuild shell:

    if [ -n "$UNDER_JHBUILD" ]; then
            PS1="[jhbuild] $PS1"
    fi

For details, see: https://developer.gnome.org/jhbuild/unstable/command-reference.html.en#command-reference-shell

2) Run individual commands

Invoking the shell and then launching a utility requires interaction. Sometimes you want to automate things (ex run a test suite under jhbuild). In this case you can execute a one-off command that will launch something within the context of jhbuild. You can do so via the run comman ex:

jhbuild run eclipse

Building different versions of gtk (or compiling your changes)

By default JHBuild clones source into ~/jhbuild/checkout and it compiles binaries into ~/jhbuild/install

When you run jhbuild build gtk+, it will pull the newest sources and compile those. If you want to build a particular version of commit of gtk , then you can do as following:

  • navigate to ~/jhbuild/checkout/gtk+
  • checkout the version that you're interested in or add your own patches.
  • execute jhbuild buildone --force --no-network --distclean gtk+. (cleanup is needed to avoid
  • now open a jhbuild shell and launch your app
  • Note: If you just want to update gtk+ with the latest master, don't use '--no-network' option.

Note: jhbuild make is less useful. It uses the headers from your system instead of the once from the ~/jhbuild/checkout repository. This means you should be able to build older versions of a library, but not the bleeding edge stuff.

Configure JHBuild

The defaults are good enough for regular use. If you want to configure jhbuild to use alternative settings (ex different checkout/install directories, different modulesets etc) then note the following:

  • jhbuild loads it's config from: ~/.config/jhbuildrc, by default no such file is present there.
  • a sample config is located in: ~/jhbuild/jhbuild/examples/sample.jhbuildrc, you can copy it to above location and customise it.
  • the default config is located in: ~/jhbuild/jhbuild/jhbuild/defaults.jhbuildrc (don't change this file, use only to copy settings out of it into your on rc file).
  • You can configure jhbuild to build only certain modules (I haven't experimented with this, just fyi). The list of module sets can be found in: /home/lufimtse/jhbuild/jhbuild/modulesets.
  • read the documentation to find out more about the config file.

Also useful

Command line arguments

JHbuild accepts parameters, for example to clean the checkout directory:

jhbuild clean

A complete list of arguments can be found here: https://developer.gnome.org/jhbuild/stable/command-reference.html.en

Wayland

I haven't looked into this, but you can build newest gnome wayland with jhbuild. See: https://wiki.gnome.org/Initiatives/Wayland/TryingIt . If you figure it out, feel free to add a note here.

Help and support

For SWT and JHBuild questions, feel free to drop me an email : lufimtse@redhat.com.

For help with JHBuild in general, try gnome's IRC channel, see gtk+ support options: http://www.gtk.org/development.php (GIMPNet: irc.gnome.org#gtk+)

Clone this wiki locally