diff options
author | Guillaume Poirier-Morency <guillaumepoiriermorency@gmail.com> | 2017-04-27 14:33:29 -0400 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2017-04-28 23:01:06 +0300 |
commit | 4c35b4b79193033eb6b123e98019e88dc4b29697 (patch) | |
tree | 03342702dac8d2bb17a3eba24491e969c2f7f261 /docs/markdown | |
parent | 6944d06116bf3ed691faf991dbfa0478c8c2d345 (diff) | |
download | meson-4c35b4b79193033eb6b123e98019e88dc4b29697.zip meson-4c35b4b79193033eb6b123e98019e88dc4b29697.tar.gz meson-4c35b4b79193033eb6b123e98019e88dc4b29697.tar.bz2 |
Update Vala documentation with most recent changes
Cover installation using the `install_dir` array and the additional arguments for specifying the C header, VAPI and GIR names.
Diffstat (limited to 'docs/markdown')
-rw-r--r-- | docs/markdown/Vala.md | 81 |
1 files changed, 39 insertions, 42 deletions
diff --git a/docs/markdown/Vala.md b/docs/markdown/Vala.md index 00df371..0a6bc81 100644 --- a/docs/markdown/Vala.md +++ b/docs/markdown/Vala.md @@ -9,70 +9,67 @@ Meson has support for compiling Vala programs. A skeleton Vala file looks like t ```meson project('valaprog', ['vala', 'c']) -glib = dependency('glib-2.0') -gobject = dependency('gobject-2.0') +glib_dep = dependency('glib-2.0') +gobject_dep = dependency('gobject-2.0') executable('valaprog', 'prog.vala', - dependencies : [glib, gobject]) + dependencies : [glib_dep, gobject_dep]) ``` -You must always specify `glib` and `gobject` as dependencies, because all Vala applications use them. +You must always specify `glib-2.0` and `gobject-2.0` as dependencies, because all Vala applications use them. ## Using a custom VAPI -When dealing with libraries that are not providing Vala bindings, you can point --vapidir to a directory relative to meson.current_source_dir containing the binding and include a --pkg flag. +When dealing with libraries that are not providing Vala bindings, a `--vapidir` flag can be added to extend the search path for the current project. ```meson -glib = dependency('glib-2.0') -gobject = dependency('gobject-2.0') -foo = dependency('foo') +project('vala app', 'c', 'vala') -executable('app', - dependencies: [glib, gobject, foo] - vala_args: ['--pkg=foo', '--vapidir=' + meson.current_source_dir()]) +add_project_arguments(['--vapidir', join_paths(meson.current_source_dir(), 'vapi')], + language: 'vala') + +glib_dep = dependency('glib-2.0') +gobject_dep = dependency('gobject-2.0') +foo_dep = dependency('foo') # 'foo.vapi' will be resolved in './vapi/foo.vapi' + +executable('app', 'app.vala', dependencies: [glib_dep, gobject_dep, foo_dep]) ``` -## GObject Introspection +## Custom output names -To generate GObject Introspection metadata, the --gir flags has to be set explicitly in vala_args. +If a library target is used, Meson automatically output the C header and the VAPI. They can be renamed by setting the `vala_header` and `vala_vapi` arguments respectively. In this case, the second and third elements of the `install_dir` array indicate the destination with `true` to indicate default directories. ```meson -foo_lib = library('foo', - dependencies: [glib, gobject], - vala_args: ['--gir=Foo-1.0.gir']) +foo_lib = library('foo', 'foo.vala', + vala_header: 'foo.h', + vala_vapi: 'foo-1.0.vapi', + dependencies: [glib_dep, gobject_dep], + install: true, + install_dir: [true, true, true]) ``` -For the typelib, use a custom_target depending on the library: - -```meson - g_ir_compiler = find_program('g_ir_compiler') - custom_target('foo-typelib', - command: [g_ir_compiler, '--output', '@OUTPUT@', meson.current_build_dir() + '/foo@sha/Foo-1.0.gir'], - output: 'Foo-1.0.typelib', - depends: foo_lib, - install: true, - install_dir: get_option('libdir') + '/girepository-1.0') -``` +## GObject Introspection -## Installing VAPI and GIR files +To generate GObject Introspection metadata, the `vala_gir` option has to be set with the desired name. -To install generated VAPI and GIR files, it is necessary to add a custom install script. +The fourth element in the `install_dir` array indicate where the GIR file will be installed. The `true` value tells Meson to use the default directory (i.e. `share/gir-1.0`). ```meson -meson.add_install_script('install.sh') +foo_lib = library('foo', 'foo.vala', + vala_gir: 'Foo-1.0.gir', + dependencies: [glib_dep, gobject_dep], + install: true, + install_dir: [true, true, true, true]) ``` -```bash -#!/bin/sh - -mkdir -p "${DESTDIR}${MESON_INSTALL_PREFIX}/share/vala/vapi" -mkdir -p "${DESTDIR}${MESON_INSTALL_PREFIX}/share/gir-1.0" +For the typelib, use a custom target depending on the library: -install -m 0644 \ - "${MESON_BUILD_ROOT}/foo-1.0.vapi" \ - $"{DESTDIR}${MESON_INSTALL_PREFIX}/share/vala/vapi" - -install -m 0644 \ - "${MESON_BUILD_ROOT}/foo@sha/Foo-1.0.gir" \ - "${DESTDIR}${MESON_INSTALL_PREFIX}/share/gir-1.0" +```meson +g_ir_compiler = find_program('g-ir-compiler') +custom_target('foo typelib', command: [g_ir_compiler, '--output', '@OUTPUT@', '@INPUT@'], + input: join_paths(meson.current_build_dir(), 'Foo-1.0.gir'), + output: 'Foo-1.0.typelib', + depends: foo_lib, + install: true, + install_dir: join_paths(get_option('libdir'), 'girepository-1.0')) ``` |