<page xmlns="http://projectmallard.org/1.0/" type="guide" id="vala">
<info>
    <link type="guide" xref="index#programs-and-libraries"/>
</info>

<title>Vala Language Support</title>

<p>
Bake supports <link xref="programs">programs</link> and <link xref="libraries">libraries</link> written in the Vala language.
</p>
<p>
Vala programs and libraries can set the following program <link xref="variables">variables</link> to control compiling:
</p>
<table frame="all" shade="rows">
<thead>
<tr>
  <td><p>Name</p></td>
  <td><p>Description</p></td>
</tr>
</thead>
<tr>
  <td><p>vala-api-version</p></td>
  <td><p>Minimum API version required (optional)</p></td>
</tr>
<tr>
  <td><p>so-version</p></td>
  <td><p>Shared object version for library (libraries only, optional)</p></td>
</tr>
<tr>
  <td><p>symbol-filter</p></td>
  <td><p>Symbols that will be exported (libraries only, optional)</p></td>
</tr>
<tr>
  <td><p>vala-compile-flags</p></td>
  <td><p>Additional command line flags passed to Vala compiler</p></td>
</tr>
<tr>
  <td><p>vala-packages</p></td>
  <td><p>Vala packages to use</p></td>
</tr>
<tr>
  <td><p>libraries</p></td>
  <td><p>Libraries to use (see below for details)</p></td>
</tr>
<tr>
  <td><p>packages</p></td>
  <td><p>pkg-config packages to use in C compile stage</p></td>
</tr>
<tr>
  <td><p>compile-flags</p></td>
  <td><p>Additional command line flags passed to C compiler</p></td>
</tr>
<tr>
  <td><p>link-flags</p></td>
  <td><p>Additional command line flags passed to linker</p></td>
</tr>
<tr>
  <td><p>vala-vapi-name</p></td>
  <td><p>Name to use for .vapi file generated for libraries (optional)</p></td>
</tr>
<tr>
  <td><p>vala-header-name</p></td>
  <td><p>Name to use for .h file generated for libraries (optional)</p></td>
</tr>
<tr>
  <td><p>header-install-directory</p></td>
  <td><p>Directory to install headers (libraries only, defaults to <file>/usr/include</file>)</p></td>
</tr>
<tr>
  <td><p>debug</p></td>
  <td><p>If debugging symbols should be generated</p></td>
</tr>
<tr>
  <td><p>gir-namespace</p></td>
  <td><p>Namespace to use to generate gobject introspection metadata (libraries only, optional)</p></td>
</tr>
<tr>
  <td><p>gir-namespace-version</p></td>
  <td><p>Namespace version to use in gobject introspection metadata (libraries only, defaults to 0)</p></td>
</tr>
</table>
<example>
<p>
The following shows a recipe for a two file Vala program that requires API version 0.24 or greater:
</p>
<code>
programs.example-program {
  vala-api-version = 0.24
  sources = main.vala module.vala
  vala-packages = gtk+-3.0
  packages = gtk+-3.0
  debug = true
}
</code>
</example>
<p>
Libraries are specified using the <code>libraries</code> variable.
By default each library name listed is searched for in the system paths and dynamically linked to.
Static linking is performed by following the library with <code>(static)</code>.
If the library is built inside the project then it will be searched for if the library name is followed with <code>(local)</code>.
</p>
<example>
<p>
The following shows a recipe that builds a program and a library and statically links them together.
</p>
<code>
programs.example-program {
  sources = main.vala
  libraries = example-library (local) (static)
}

libraries.example-library {
  sources = module.vala
}
</code>
</example>
<p>
The symbols exported into a library can be limited by using a symbol filter.
A symbol filter contains one or more symbols that should be exported.
If a symbol should be hidden (not exported) follow it with <code>(hide)</code>.
Symbols can be specified using a regular expression.
</p>
<example>
<p>
This library exports only the symbols for the <code>foo()</code> and <code>bar()</code> functions:
</p>
<code>
libraries.example-library {
  sources = module.vala
  symbol-filter = foo bar
}
</code>
</example>
<example>
<p>
This library exports all symbols with the prefix <code>test_</code> but not the prefix <code>test_priv_</code>
</p>
<code>
libraries.example-library {
  sources = module.vala
  symbol-filter = test_priv_.* (hide) \
                  test_.*
}
</code>
</example>
</page>
