[gnome-games] build: Can build without gamepad support



commit eca45336506000a44239d6e85a473962226f3cdb
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Mon Aug 8 17:36:03 2016 +0200

    build: Can build without gamepad support
    
    This allows to build the application even if libraries required to
    support gamepads aren't available.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=769638

 configure.ac                                     |    8 +++++-
 src/Makefile.am                                  |   23 +++++++++++++++++----
 src/gamepad/gamepad-monitor.vala                 |    2 +
 src/gamepad/linux/linux-raw-gamepad-monitor.vala |    5 ++++
 src/gamepad/linux/linux-raw-gamepad.vala         |    5 ++++
 5 files changed, 36 insertions(+), 7 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 015190e..b31d0f4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -52,13 +52,17 @@ PKG_CHECK_MODULES(GNOME_GAMES, [
        glib-2.0 >= $GLIB_MIN_VERSION
        grilo-0.3
        gtk+-3.0
-       gudev-1.0
-       libevdev
        retro-gobject-0.6
        retro-gtk-0.6
        tracker-sparql-1.0
 ])
 
+PKG_CHECK_MODULES(GAMEPADS, [
+       gudev-1.0
+       libevdev
+], [enable_gamepads=yes], [enable_gamepads=no])
+AM_CONDITIONAL([ENABLE_GAMEPADS], [test x$enable_gamepads != xno])
+
 AC_CONFIG_FILES([
        Makefile
        data/Makefile
diff --git a/src/Makefile.am b/src/Makefile.am
index 5dde43b..17a9c79 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -62,8 +62,6 @@ gnome_games_SOURCES = \
        gamepad/gamepad-mapping-error.vala \
        gamepad/gamepad-mappings-manager.vala \
        gamepad/gamepad-monitor.vala \
-       gamepad/linux/linux-raw-gamepad.vala \
-       gamepad/linux/linux-raw-gamepad-monitor.vala \
        gamepad/raw-gamepad.vala \
        gamepad/raw-gamepad-monitor.vala \
        gamepad/standard-gamepad-axis.vala \
@@ -125,9 +123,15 @@ gnome_games_SOURCES = \
        $(BUILT_SOURCES) \
        $(NULL)
 
+if ENABLE_GAMEPADS
+gnome_games_SOURCES += \
+       gamepad/linux/linux-raw-gamepad.vala \
+       gamepad/linux/linux-raw-gamepad-monitor.vala \
+       $(NULL)
+endif
+
 gnome_games_VALAFLAGS = \
        --target-glib=@GLIB_MIN_VERSION@ \
-       --vapidir=gamepad/linux/ \
        --pkg gio-2.0 \
        --pkg glib-2.0 \
        --pkg grilo-0.3 \
@@ -135,8 +139,6 @@ gnome_games_VALAFLAGS = \
        --pkg tracker-sparql-1.0 \
        --pkg retro-gobject-0.6 \
        --pkg retro-gtk-0.6 \
-       --pkg gudev-1.0 \
-       --pkg libevdev \
        --pkg linux \
        --pkg posix \
        --gresources $(gresource_file) \
@@ -144,8 +146,18 @@ gnome_games_VALAFLAGS = \
        -H $(header_file) \
        $(NULL)
 
+if ENABLE_GAMEPADS
+gnome_games_VALAFLAGS += \
+       --vapidir=gamepad/linux/ \
+       --pkg gudev-1.0 \
+       --pkg libevdev \
+       --define ENABLE_LINUX_GAMEPADS
+       $(NULL)
+endif
+
 gnome_games_CFLAGS = \
        $(GNOME_GAMES_CFLAGS) \
+       $(GAMEPADS_CFLAGS) \
        -DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
        -DGAMES_PLUGINS_DIR=\"$(libdir)/gnome-games/plugins\" \
        $(NULL)
@@ -157,6 +169,7 @@ gnome_games_CPPFLAGS = \
 
 gnome_games_LDADD = \
        $(GNOME_GAMES_LIBS) \
+       $(GAMEPADS_LIBS) \
        $(NULL)
 
 gnome_gamesincludedir = $(includedir)
diff --git a/src/gamepad/gamepad-monitor.vala b/src/gamepad/gamepad-monitor.vala
index 1016bc9..185ecdc 100644
--- a/src/gamepad/gamepad-monitor.vala
+++ b/src/gamepad/gamepad-monitor.vala
@@ -20,9 +20,11 @@ private class Games.GamepadMonitor : Object {
 
        private GamepadMonitor () {
                gamepads = new GenericSet<Gamepad?> (direct_hash, direct_equal);
+#if ENABLE_LINUX_GAMEPADS
                var raw_gamepad_monitor = LinuxRawGamepadMonitor.get_instance ();
                raw_gamepad_monitor.gamepad_plugged.connect (on_raw_gamepad_plugged);
                raw_gamepad_monitor.foreach_gamepad ((raw_gamepad) => add_gamepad (raw_gamepad));
+#endif
        }
 
        public static GamepadMonitor get_instance () {
diff --git a/src/gamepad/linux/linux-raw-gamepad-monitor.vala 
b/src/gamepad/linux/linux-raw-gamepad-monitor.vala
index aaebf31..908ad5c 100644
--- a/src/gamepad/linux/linux-raw-gamepad-monitor.vala
+++ b/src/gamepad/linux/linux-raw-gamepad-monitor.vala
@@ -1,5 +1,8 @@
 // This file is part of GNOME Games. License: GPLv3
 
+// FIXME Workaround the autotools working poorly with Vala.
+#if ENABLE_LINUX_GAMEPADS
+
 private class Games.LinuxRawGamepadMonitor : Object, RawGamepadMonitor {
        private static LinuxRawGamepadMonitor instance;
 
@@ -94,3 +97,5 @@ private class Games.LinuxRawGamepadMonitor : Object, RawGamepadMonitor {
                        (device.has_property (".INPUT_CLASS") && device.get_property (".INPUT_CLASS") == 
"joystick"));
        }
 }
+
+#endif
diff --git a/src/gamepad/linux/linux-raw-gamepad.vala b/src/gamepad/linux/linux-raw-gamepad.vala
index 38ca20d..e83c0ce 100644
--- a/src/gamepad/linux/linux-raw-gamepad.vala
+++ b/src/gamepad/linux/linux-raw-gamepad.vala
@@ -1,5 +1,8 @@
 // This file is part of GNOME Games. License: GPLv3
 
+// FIXME Workaround the autotools working poorly with Vala.
+#if ENABLE_LINUX_GAMEPADS
+
 // FIXME This should be in LinuxRawGamepad but a bug in valac prevent us from using it in 'requires' 
statements.
 const int GUID_LENGTH = 8;
 
@@ -158,3 +161,5 @@ private class Games.LinuxRawGamepad : Object, RawGamepad {
                return builder.str;
        }
 }
+
+#endif


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]