Meson

This page describe how to use the Meson build system to compile programs written in Vala.

The simplest project definition involve a very few lines of Meson DSL stored in meson.build:

project('foo', 'c', 'vala')

glib_dep = dependency('glib-2.0')
gobject_dep = dependency('gobject-2.0')

executable('foo', 'foo.vala', dependencies: [glib_dep, gobject_dep])

Meson only support out-of-tree builds, so a build directory must be created:

mkdir build
cd build
meson ..
ninja

Library

The common approach for building a library consist of declaring both a library object and a dependency object.

bar_lib = library('bar', 'bar.vala')
bar_dep = declare_dependency(link_with: bar_lib, 
                             include_directories: include_directories('.')

Vala targets that produce a library (i.e. library, shared_library, static_library and shared_module) suport specific arguments:

  • vala_header name for the generated C header

  • vala_gir name for the GIR introspection file which is not generated otherwise

  • vala_vapi name for the generated VAPI

library('bar-1.0', 'bar.vala'
        vala_header: 'bar.h',
        vala_vapi: 'bar-1.0.vapi',
        vala_gir: 'Bar-1.0.gir')

Installing a Vala library target is particular because it consists of multiple outputs. For installing beyond the library, the install_dir option has to be provided as an array:

library('bar', 'bar.vala', 
        install: true, 
        install_dir: ['lib64', 'include', 'share/vala/vapi', 'share/gir-1.0'])

It's simpler however to specify the default destinations:

library('bar', 'bar.vala', 
        install: true, 
        install_dir: [true, true, true, true])

Projects/Vala/Tools/Meson (last edited 2017-05-24 16:17:58 by GuillaumePoirier)