Vala itself would not be responsible for compiling your schemas; that is up to your build system (e.g. CMake or Meson). When your app is packaged, the packaging system would then use your build system to build the package.
In order for your build system to compile them, you need to include your schemas as an XML file, for example:
<?xml version="1.0" encoding="UTF-8"?>
<schemalist>
<schema path="/com/github/yourusername/yourrepositoryname/" id="com.github.yourusername.yourrepositoryname">
<key name="useless-setting" type="b">
<default>false</default>
<summary>Useless Setting</summary>
<description>Whether the useless switch is toggled</description>
</key>
</schema>
</schemalist>
Then in your build system, install the schema files. For example, in Meson:
install_data (
'gschema.xml',
install_dir: join_paths (get_option ('datadir'), 'glib-2.0', 'schemas'),
rename: meson.project_name () + '.gschema.xml'
)
meson.add_install_script('post_install.py')
With Meson you can then also include a post_install.py
to compile the schemas when installing with the build system, which makes development easier:
#!/usr/bin/env python3
import os
import subprocess
schemadir = os.path.join(os.environ['MESON_INSTALL_PREFIX'], 'share', 'glib-2.0', 'schemas')
# Packaging tools define DESTDIR and this isn't needed for them
if 'DESTDIR' not in os.environ:
print('Compiling gsettings schemas...')
subprocess.call(['glib-compile-schemas', schemadir])