The Build System
Understanding what GNOME builder does to run your application
Meson has a concept of using files which end with
.buildas the build configuration for that directory. Let us go through the default build configuration.
meson.buildat the root of the project. Here is what it contains
meson_version: '>= 0.50.0',
default_options: [ 'warning_level=2',
i18n = import('i18n')
- Line 1-5 : We are creating a new meson project with the name of the project as splash and the version to be 0.1.0.
- Line 11, 12, 13 : Adding sub directories
po, this in turn triggers meson build inside those directories
- Line 15: Runs a python script at the end of the build
Let us now open the
datadirectory, these are the contents of the file
desktop_file = i18n.merge_file(
install_dir: join_paths(get_option('datadir'), 'applications')
desktop_utils = find_program('desktop-file-validate', required: false)
test('Validate desktop file', desktop_utils,
appstream_file = i18n.merge_file(
install_dir: join_paths(get_option('datadir'), 'appdata')
appstream_util = find_program('appstream-util', required: false)
test('Validate appstream file', appstream_util,
args: ['validate', appstream_file]
install_dir: join_paths(get_option('datadir'), 'glib-2.0/schemas')
compile_schemas = find_program('glib-compile-schemas', required: false)
test('Validate schema file', compile_schemas,
args: ['--strict', '--dry-run', meson.current_source_dir()]
i18n is responsible for internationalization. It takes
com.yourusername.splash.desktop.infile as input and outputs the desktop file and installs it. Desktop files are responsible for the content you see on your launcher and task bar. Let us see what it contains. Open
The desktop file currently contains the Name, Exec(Executable to run), Terminal(Is it a terminal appplication?), Type, Categories and StartupNotify. This file decides what text should be shown in the launcher etc.. You can read more about the spec here. This file will be finally installed at
get_optionfunction gets the appropriate folder path's for the input. Some common outputs for get option are as follows
get_option('prefix') -> /usr
get_option('bindir') -> bin
get_option('datadir') -> /usr/share
One concept prevalent here is the idea of
.infiles which are the input to a function. Which in turn generates files without the
.insuffix and installs in a particular directory
There is a program called
desktop-file-validatewhich checks for errors in desktop files. Line 10 is trying to find the application. If it exists, then we use it to validate the generated desktop file and make sure there are no errors
Appstream is a freedesktop specification which specifies metadata for applications. This is distro agnostic and a commonly agreed upon spec. The appstream file is what is used to display information about the application in software centers.
Appstream is stored in
.xmlformat. The procedure is same as the desktop file. We take in the
.infile and output the translated versions using i18n.
Again, a very similar piece of code to the desktop file validator. If the executable is found, meson runs the executable with the appstream file to make sure there are no errors.
.gschema.xmlfile is responsible for managing GSettings for your application. GSettings are the settings you can define for your application. This is useful for persistent state and settings. For example, an application's window size and position can be stored in GSettings and retrieved whenever a new window is opened.
This file is installed in
Similar to above validations.
.gschema.xmlto make sure there are no errors.
We have covered what is in the
This directory contains the build file for the translations, we will look into it later.
Here are the contents of this file
pkgdatadir = join_paths(get_option('prefix'), get_option('datadir'), meson.project_name())
moduledir = join_paths(pkgdatadir, 'splash')
gnome = import('gnome')
python = import('python')
conf = configuration_data()
conf.set('localedir', join_paths(get_option('prefix'), get_option('localedir')))
splash_sources = [
install_data(splash_sources, install_dir: moduledir)
Line1-3 : Imports and declaring some constants
A Gresource file is responsible for listing out the resources required for your GTK Application. The file currently contains a pointer to one file as of now.
<?xml version="1.0" encoding="UTF-8"?>
Two important things to note, this file specifies a prefix under which files are stored and a list of files which will be stored.
The python file
splash.py.inis given as an input to a function which meson will process and return back a processed
splashfile which will be installed as an executable file in the bin directory.
All the other python files which are used by the application are listed out in an array and then installed to the module directory.
That's it. Congratulations! With this knowledge it will be easier to understand how an application works.
Next up, let us look into widgets!