Commit bb23e468 authored by Alexander Mikhaylenko's avatar Alexander Mikhaylenko Committed by Alexander Mikhaylenko

build: Port to meson

Also change config.vala to config.vapi to match autogenerated header.

Requires meson >= 0.46.1 because older versions have a bug that prevents
building plugins.
parent f4b5cc52
#!/usr/bin/python3
import os
import subprocess
import sys
destdir = os.environ.get('DESTDIR', '')
if not destdir and len(sys.argv) > 1:
datadir = sys.argv[1]
print('Compiling gsettings schemas...')
subprocess.call(['glib-compile-schemas', os.path.join(datadir, 'glib-2.0', 'schemas')])
print('Updating icon cache...')
subprocess.call(['gtk-update-icon-cache', '-qtf', os.path.join(datadir, 'icons', 'hicolor')])
subprocess.call(['gtk-update-icon-cache', '-qtf', os.path.join(datadir, 'icons', 'HighContrast')])
print('Updating desktop database...')
subprocess.call(['update-desktop-database', '-q', os.path.join(datadir, 'icons', 'applications')])
icon_sizes = ['16x16', '22x22', '24x24', '32x32', '48x48', '256x256', '512x512']
foreach icon_size: icon_sizes
hicolor_dir = join_paths('hicolor', icon_size, 'apps')
highcontrast_dir = join_paths('HighContrast', icon_size, 'apps')
install_data(
join_paths(hicolor_dir, 'org.gnome.Games.png'),
install_dir: join_paths(datadir, 'icons', hicolor_dir)
)
install_data(
join_paths(highcontrast_dir, 'org.gnome.Games.png'),
install_dir: join_paths(datadir, 'icons', highcontrast_dir)
)
endforeach
hicolor_dir = join_paths('hicolor', 'scalable', 'apps')
install_data(
join_paths(hicolor_dir, 'org.gnome.Games-symbolic.svg'),
install_dir: join_paths(datadir, 'icons', hicolor_dir)
)
resources = gnome.compile_resources(
'org.gnome.Games',
'org.gnome.Games.gresource.xml',
c_name: 'resources'
)
i18n.merge_file ('desktop-file',
type: 'desktop',
input: 'org.gnome.Games.desktop.in',
output: 'org.gnome.Games.desktop',
po_dir: podir,
install: true,
install_dir: join_paths (datadir, 'applications')
)
i18n.merge_file ('appdata-file',
input: 'org.gnome.Games.appdata.xml.in',
output: 'org.gnome.Games.appdata.xml',
po_dir: podir,
install: true,
install_dir: join_paths (datadir, 'metainfo')
)
gsettings_conf = configuration_data ()
gsettings_conf.set ('GETTEXT_PACKAGE', meson.project_name ())
configure_file (
input: 'org.gnome.Games.gschema.xml',
output: 'org.gnome.Games.gschema.xml',
configuration: gsettings_conf,
install: true,
install_dir: join_paths(datadir, 'glib-2.0', 'schemas'),
)
subdir ('icons')
subdir ('options')
options_files = [
'desmume.options',
'desmume2015.options'
]
install_data (options_files, install_dir: options_dir)
project('gnome-games',
['vala', 'c'],
version: '3.29.1',
license: 'GPL3+',
meson_version: '>= 0.46.1'
)
gnome = import ('gnome')
i18n = import('i18n')
cc = meson.get_compiler ('c')
valac = meson.get_compiler ('vala')
glib_min_version = '2.38'
manette_min_version = '0.2.0'
retro_gtk_min_version = '0.13.2'
gio_dep = dependency ('gio-2.0', version: '>=' + glib_min_version)
glib_dep = dependency ('glib-2.0', version: '>=' + glib_min_version)
grilo_dep = dependency ('grilo-0.3')
gtk_dep = dependency ('gtk+-3.0')
manette_dep = dependency ('manette-0.2', version: '>=' + manette_min_version)
retro_gtk_dep = dependency ('retro-gtk-0.14', version: '>=' + retro_gtk_min_version)
rsvg_dep = dependency ('librsvg-2.0')
soup_dep = dependency ('libsoup-2.4')
sqlite_dep = dependency ('sqlite3')
tracker_sparql_dep = dependency ('tracker-sparql-2.0')
xml_dep = dependency ('libxml-2.0')
srcdir = join_paths (meson.source_root (), 'src')
podir = join_paths (meson.source_root (), 'po')
prefix = get_option('prefix')
datadir = join_paths (prefix, get_option ('datadir'))
libdir = join_paths (prefix, get_option ('libdir'))
localedir = join_paths (prefix, get_option ('localedir'))
options_dir = join_paths (datadir, meson.project_name(), 'options')
plugins_dir = join_paths (libdir, meson.project_name(), 'plugins')
config_h = configuration_data ()
config_h.set_quoted ('GETTEXT_PACKAGE', meson.project_name ())
config_h.set_quoted ('GNOMELOCALEDIR', localedir)
config_h.set_quoted ('OPTIONS_DIR', options_dir)
config_h.set_quoted ('PLUGINS_DIR', plugins_dir)
config_h.set_quoted ('VERSION', meson.project_version ())
configure_file (output: 'config.h', configuration: config_h)
config_dep = valac.find_library ('config', dirs: srcdir)
confinc = include_directories('.')
srcinc = include_directories('src')
add_project_arguments (
'-DGETTEXT_PACKAGE="' + meson.project_name () + '"',
'-DRETRO_GTK_USE_UNSTABLE_API',
language: 'c'
)
add_project_arguments (
'--target-glib=' + glib_min_version,
language: 'vala'
)
meson.add_install_script (
join_paths ('build-aux', 'post_install.py'),
datadir
)
# FIXME 'plugins' have to be after 'src' as the plugins depend on the
# produced VAPI file and dependency tracking doesn't work as expected.
subdir ('data')
subdir ('po')
subdir ('src')
subdir ('plugins')
# Plugins
# This must mirror the list in plugins/meson.build
option ('desktop-plugin', description: 'Support for desktop games', type: 'boolean')
option ('dreamcast-plugin', description: 'Support for Dreamcast games', type: 'boolean')
option ('game-cube-plugin', description: 'Support for GameCube games', type: 'boolean')
option ('libretro-plugin', description: 'Support for Libretro games', type: 'boolean')
option ('love-plugin', description: 'Support for LÖVE games', type: 'boolean')
option ('mame-plugin', description: 'Support for MAME games', type: 'boolean')
option ('nintendo-ds-plugin', description: 'Support for Nintendo DS games', type: 'boolean')
option ('playstation-plugin', description: 'Support for PlayStation games', type: 'boolean')
option ('sega-cd-plugin', description: 'Support for Sega CD games', type: 'boolean')
option ('sega-saturn-plugin', description: 'Support for Sega Saturn games', type: 'boolean')
option ('steam-plugin', description: 'Support for Steam games', type: 'boolean')
option ('turbografx-cd-plugin', description: 'Support for TurboGrafx-CD games', type: 'boolean')
option ('virtual-boy-plugin', description: 'Support for Virtual Boy games', type: 'boolean')
option ('wii-plugin', description: 'Support for Wii games', type: 'boolean')
install_data (plugin_name + '.plugin', install_dir: plugins_dir)
desktop_resources = gnome.compile_resources (
'desktop',
'desktop.gresource.xml',
c_name: 'resources'
)
subdir ('data')
subdir ('src')
vala_sources = [
'desktop-error.vala',
'desktop-icon.vala',
'desktop-plugin.vala',
'desktop-title.vala',
'desktop-tracker-uri-query.vala',
]
c_args = [
'-DG_LOG_DOMAIN="GamesDesktop"'
]
gio_unix_dep = dependency ('gio-unix-2.0')
dependencies = [
gnome_games_dep,
gio_unix_dep,
]
shared_module (
'games-' + plugin_name + '-plugin',
vala_sources + desktop_resources,
dependencies: dependencies,
c_args: c_args,
install: true,
install_dir: plugins_dir
)
install_data (plugin_name + '.plugin', install_dir: plugins_dir)
subdir ('data')
subdir ('src')
vala_sources = [
'dreamcast-header.vala',
'dreamcast-plugin.vala',
'dreamcast-uid.vala',
]
c_args = [
'-DG_LOG_DOMAIN="GamesDreamcast"'
]
shared_module (
'games-' + plugin_name + '-plugin',
vala_sources,
dependencies: gnome_games_dep,
c_args: c_args,
install: true,
install_dir: plugins_dir
)
install_data (plugin_name + '.plugin', install_dir: plugins_dir)
subdir ('data')
subdir ('src')
vala_sources = [
'game-cube-header.vala',
'game-cube-plugin.vala',
'game-cube-uid.vala',
]
c_args = [
'-DG_LOG_DOMAIN="GamesGameCube"'
]
shared_module (
'games-' + plugin_name + '-plugin',
vala_sources,
dependencies: gnome_games_dep,
c_args: c_args,
install: true,
install_dir: plugins_dir
)
install_data (plugin_name + '.plugin', install_dir: plugins_dir)
subdir ('data')
subdir ('src')
vala_sources = [
'libretro-error.vala',
'libretro-icon.vala',
'libretro-plugin.vala',
'libretro-title.vala',
'libretro-uid.vala',
'libretro-uri-iterator.vala',
'libretro-uri-source.vala',
]
c_args = [
'-DG_LOG_DOMAIN="GamesLibretro"'
]
shared_module (
'games-' + plugin_name + '-plugin',
vala_sources,
dependencies: gnome_games_dep,
c_args: c_args,
install: true,
install_dir: plugins_dir
)
install_data (plugin_name + '.plugin', install_dir: plugins_dir)
subdir ('data')
subdir ('src')
vala_sources = [
'love-error.vala',
'love-icon.vala',
'love-package.vala',
'love-plugin.vala',
'love-title.vala',
]
c_args = [
'-DG_LOG_DOMAIN="GamesLOVE"'
]
libarchive_dep = dependency ('libarchive')
dependencies = [
gnome_games_dep,
libarchive_dep,
]
shared_module (
'games-' + plugin_name + '-plugin',
vala_sources,
dependencies: dependencies,
c_args: c_args,
install: true,
install_dir: plugins_dir
)
install_data (plugin_name + '.plugin', install_dir: plugins_dir)
mame_resources = gnome.compile_resources (
'mame',
'mame.gresource.xml',
c_name: 'resources'
)
subdir ('data')
subdir ('src')
vala_sources = [
'mame-error.vala',
'mame-game-info.vala',
'mame-game-uri-adapter.vala',
'mame-plugin.vala',
]
c_args = [
'-DG_LOG_DOMAIN="GamesMAME"'
]
shared_module (
'games-' + plugin_name + '-plugin',
vala_sources + mame_resources,
dependencies: gnome_games_dep,
c_args: c_args,
install: true,
install_dir: plugins_dir
)
plugins = [
'desktop',
'dreamcast',
'game-cube',
'libretro',
'love',
'mame',
'nintendo-ds',
'playstation',
'sega-cd',
'sega-saturn',
'steam',
'turbografx-cd',
'virtual-boy',
'wii',
]
foreach plugin_name : plugins
if get_option (plugin_name +'-plugin')
subdir (plugin_name)
endif
endforeach
install_data (plugin_name + '.plugin', install_dir: plugins_dir)
subdir ('data')
subdir ('src')
vala_sources = [
'nintendo-ds-icon.vala',
'nintendo-ds-plugin.vala',
]
c_sources = [
'nintendo-ds-icon-extract.c',
]
c_args = [
'-DG_LOG_DOMAIN="GamesNintendoDS"'
]
shared_module (
'games-' + plugin_name + '-plugin',
vala_sources + c_sources,
dependencies: gnome_games_dep,
c_args: c_args,
install: true,
install_dir: plugins_dir
)
install_data (plugin_name + '.plugin', install_dir: plugins_dir)
sed = find_program ('sed')
# TODO Game titles in the gameinfo file are meant to be localized
gameinfo = custom_target (
'playstation.gameinfo',
output: 'playstation.gameinfo.xml',
input: 'playstation.gameinfo.xml.in',
command: [sed, '-e', 's|<_title>|<title>|g;s|</_title>|</title>|g', '@INPUT@'],
capture: true
)
playstation_resources = gnome.compile_resources (
'org.gnome.Games.plugin.playstation',
'org.gnome.Games.plugin.playstation.gresource.xml',
c_name: 'resources',
dependencies: gameinfo
)
subdir ('data')
subdir ('src')
vala_sources = [
'playstation-error.vala',
'playstation-game-factory.vala',
'playstation-header.vala',
'playstation-plugin.vala',
'playstation-uid.vala',
]
c_sources = [
'disc-file-info.c',
'disc-image.c',
'disc-image-time.c',
'playstation-disc-image.c',
]
c_args = [
'-DG_LOG_DOMAIN="GamesPlayStation"'
]
shared_module (
'games-' + plugin_name + '-plugin',
vala_sources + c_sources + playstation_resources,
dependencies: gnome_games_dep,
c_args: c_args,
install: true,
install_dir: plugins_dir
)
install_data (plugin_name + '.plugin', install_dir: plugins_dir)
subdir ('data')
subdir ('src')
vala_sources = [
'sega-cd-header.vala',
'sega-cd-plugin.vala',
'sega-cd-system.vala',
]
c_args = [
'-DG_LOG_DOMAIN="GamesSegaCD"'
]
shared_module (
'games-' + plugin_name + '-plugin',
vala_sources,
dependencies: gnome_games_dep,
c_args: c_args,
install: true,
install_dir: plugins_dir
)
install_data (plugin_name + '.plugin', install_dir: plugins_dir)
subdir ('data')
subdir ('src')
vala_sources = [
'sega-saturn-error.vala',
'sega-saturn-header.vala',
'sega-saturn-plugin.vala',
'sega-saturn-uid.vala',
]
c_args = [
'-DG_LOG_DOMAIN="GamesSegaSaturn"'
]
shared_module (
'games-' + plugin_name + '-plugin',
vala_sources,
dependencies: gnome_games_dep,
c_args: c_args,
install: true,
install_dir: plugins_dir
)
install_data (plugin_name + '.plugin', install_dir: plugins_dir)
subdir ('data')
subdir ('src')
vala_sources = [
'steam-cover.vala',
'steam-error.vala',
'steam-icon.vala',
'steam-plugin.vala',
'steam-registry.vala',
'steam-title.vala',
'steam-uri-iterator.vala',
'steam-uri-source.vala',
]
c_args = [
'-DG_LOG_DOMAIN="GamesSteam"'
]
shared_module (
'games-' + plugin_name + '-plugin',
vala_sources,
dependencies: gnome_games_dep,
c_args: c_args,
install: true,
install_dir: plugins_dir
)
install_data (plugin_name + '.plugin', install_dir: plugins_dir)
subdir ('data')
subdir ('src')
vala_sources = [
'turbografx-cd-error.vala',
'turbografx-cd-plugin.vala',
]
c_args = [
'-DG_LOG_DOMAIN="GamesTurboGrafxCD"'
]
shared_module (
'games-' + plugin_name + '-plugin',
vala_sources,
dependencies: gnome_games_dep,
c_args: c_args,
install: true,
install_dir: plugins_dir
)
install_data (plugin_name + '.plugin', install_dir: plugins_dir)
subdir ('data')
subdir ('src')
vala_sources = [
'virtual-boy-header.vala',
'virtual-boy-plugin.vala',
]
c_args = [
'-DG_LOG_DOMAIN="GamesVirtualBoy"'
]
shared_module (
'games-' + plugin_name + '-plugin',
vala_sources,
dependencies: gnome_games_dep,
c_args: c_args,
install: true,
install_dir: plugins_dir
)
install_data (plugin_name + '.plugin', install_dir: plugins_dir)
subdir ('data')
subdir ('src')
vala_sources = [
'wii-header.vala',
'wii-plugin.vala',
'wii-uid.vala',
]
c_args = [
'-DG_LOG_DOMAIN="GamesWii"'
]
shared_module (
'games-' + plugin_name + '-plugin',
vala_sources,
dependencies: gnome_games_dep,
c_args: c_args,
install: true,
install_dir: plugins_dir
)
i18n.gettext (meson.project_name (), preset: 'glib')
// This file is part of GNOME Games. License: GPL-3.0+.
namespace Games {
private extern const string OPTIONS_DIR;
private extern const string PLUGINS_DIR;
}
[CCode (cprefix = "", lower_case_cprefix = "", cheader_filename = "config.h")]
namespace Config {
public const string GETTEXT_PACKAGE;
public const string GNOMELOCALEDIR;
public const string OPTIONS_DIR;
public const string PLUGINS_DIR;
public const string VERSION;
}
......@@ -16,7 +16,7 @@ private class Games.PluginRegisterIterator {
public bool next () {
try {
var directory = File.new_for_path (PLUGINS_DIR);
var directory = File.new_for_path (Config.PLUGINS_DIR);
if (enumerator == null) {
enumerator = directory.enumerate_children (FileAttribute.STANDARD_NAME, 0);
}
......
......@@ -19,7 +19,7 @@ private class Games.PluginRegistrar : TypeModule {
var keyfile = new KeyFile ();
keyfile.load_from_file (plugin_filename, KeyFileFlags.NONE);
var module_name = keyfile.get_string ("Plugin", "Module");
module_path = Module.build_path (PLUGINS_DIR, module_name);
module_path = Module.build_path (Config.PLUGINS_DIR, module_name);
name = keyfile.get_string ("Plugin", "Name");
description = keyfile.get_string ("Plugin", "Description");
}
......
gio-2.0
glib-2.0
gtk+-3.0
retro-gtk-0.14
tracker-sparql-2.0
// This file is part of GNOME Games. License: GPL-3.0+.
private extern const string GETTEXT_PACKAGE;
private extern const string GNOMELOCALEDIR;
int main (string[] args) {
Intl.bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
Intl.bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
Intl.textdomain (GETTEXT_PACKAGE);
Intl.bindtextdomain (Config.GETTEXT_PACKAGE, Config.GNOMELOCALEDIR);
Intl.bind_textdomain_codeset (Config.GETTEXT_PACKAGE, "UTF-8");
Intl.textdomain (Config.GETTEXT_PACKAGE);
Grl.init (ref args);
......
vapi_dir = join_paths (datadir, 'vala', 'vapi')
gamepad_dir = join_paths (srcdir, 'gamepad')
vala_args = [
'--vapidir', vapi_dir,
]
c_args = [
'-I' + gamepad_dir,
'-DG_LOG_DOMAIN="Games"',
]
vala_sources = [
'command/command-error.vala',
'command/command-runner.vala',
'core/cover.vala',
'core/game.vala',
'core/game-callback.vala',
'core/game-collection.vala',
'core/game-uri-adapter.vala',
'core/icon.vala',
'core/input-capabilities.vala',
'core/media.vala',
'core/media-info.vala',
'core/media-set/media-set.vala',
'core/media-set/media-set-error.vala',
'core/plugin.vala',
'core/plugin-register.vala',
'core/plugin-register-iterator.vala',
'core/plugin-registrar.vala',
'core/runner.vala',
'core/title.vala',
'core/uid.vala',
'core/uri-game-factory.vala',
'core/uri-iterator.vala',
'core/uri-source.vala',
'database/database.vala',
'database/database-error.vala',
'database/database-uri-iterator.vala',
'database/database-uri-source.vala',
'dummy/dummy-cover.vala',
'dummy/dummy-game.vala',
'dummy/dummy-icon.vala',
'dummy/dummy-runner.vala',
'gameinfo/gameinfo-doc.vala',
'gameinfo/gameinfo-e