Vala 本身不负责编译你的模式;这取决于您的构建系统(例如 CMake 或 Meson)。打包您的应用程序后,打包系统将使用您的构建系统来构建包。
为了让您的构建系统编译它们,您需要将您的模式作为 XML 文件包含在内,例如:
<?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>
然后在您的构建系统中,安装架构文件。例如,在介子中:
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')
使用 Meson,您还可以post_install.py
在使用构建系统安装时包含一个来编译模式,这使得开发更容易:
#!/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])