Difference between revisions of "Hacking:Building with Meson"

From GIMP Developer Wiki
Jump to: navigation, search
(Define the installation prefix)
(Merged with Hacking:Building)
Line 1: Line 1:
This page is intended to replace the content of [[Hacking:Building]] when [https://gitlab.gnome.org/GNOME/gimp/merge_requests/1 the Meson MR] is merged.
== Introduction ==
This page is a guide to build Gimp with the new Meson build system.
== Define the installation prefix ==
<ins>If you're building Gimp from <code>master</code>,</ins> you may not want to install it in your system prefix, as you may break your system Gimp installation.
You should then create another prefix directory where Gimp (and some dependencies) may be installed safely.
On Linux you could use <code>$HOME/.local</code>.
Let's name your custom prefix :
Some dependencies may be installed in this prefix too, so the build system should be able to find them :
# Used to detect the build dependencies
export PKG_CONFIG_PATH="${GIMP_PREFIX}/lib/pkgconfig:${GIMP_PREFIX}/share/pkgconfig"
# Used to find the glib-introspection dependencies
# Used to find the libraries at runtime
Note: if you don't include the default value of <code>XDG_DATA_DIRS</code>, you may get a compile error trying to read a PNG icon file. You could try using this in that case:
export XDG_DATA_DIRS="${GIMP_PREFIX}/share:/usr/local/share:/usr/share"
== Install the dependencies ==
Most dependencies from Gimp are available to install with your package manager.
Babl and Gegl are two special cases : if you're building Gimp from master, you need to build them too as they are tightly linked.
Depending on the OS or distro you're using, the package names may be different. Here are widely-used dependency install commands:
=== Archlinux and derivatives ===
<code>pacman -S --needed </code>
=== Debian ===
<code>apt install </code>
=== Windows / MinGW ===
<code>pacman -S --needed </code>
== Download the source code ==
=== Download with git ===
git clone https://gitlab.gnome.org/GNOME/babl.git
git clone https://gitlab.gnome.org/GNOME/gegl.git
git clone https://gitlab.gnome.org/GNOME/gimp.git
If your distro does not provide them, you should get the Mypaint libs too :
git clone https://github.com/mypaint/mypaint-brushes.git
git clone https://github.com/mypaint/libmypaint.git
=== Download release archives ===
Gimp also provides release archives :
Releases for mypaint can be found on their github page.
== Build the code ==
=== Mypaint ===
For both Libmypaint an Mypaint-brushes, use Autotools to install :
cd libmypaint
# Generate the configure script. That may be unnecessary with release archives :
# Configure the build (you can call ./configure --help):
./configure --prefix=${GIMP_PREFIX}
# Build the code :
make -j$(nproc) install
cd ..
=== BABL and GEGL ===
Babl and Gegl use Meson. The build needs to be out-of-source, but the process is simplified.
You can read the file meson_options.txt to find a list of options.
You may enable Link-time optimization (meson option <code>b_lto</code>)to have better performance.
cd babl
meson _build \
    --prefix=${GIMP_PREFIX} \
    --buildtype=release \
cd _build
ninja install
And the same for Gegl :
cd gegl
meson _build \
    --prefix=${GIMP_PREFIX} \
    --buildtype=release \
cd _build
ninja install
=== Gimp ===
Numerous options are available to configure the build.
You should read the file <code>meson_options.txt</code> to know the options specific to this project.
Meson also provides some useful options, such as :
* <code>warning_level=[1, 2, 3]</code> : The level of compiler warnings
* <code>b_lto=true|false</code> : Enable link-time optimizations
* <code>b_coverage=true|false</code> : Enable coverage tools.
* <code>b_pgo=off|generate|use</code> : Enable profile guided optimizations
* <code>b_sanitize=none|address|thread|undefined|memory|address,undefined</code> : Use a code sanitizer
cd gimp
meson _build \
    --prefix=${GIMP_PREFIX} \
    --buildtype=release \
    -Djavascript=always \
    -Dlua=always \
cd _build
ninja install

Latest revision as of 21:24, 11 November 2019