[gnome-online-accounts] goa: Add version definitions



commit b12727912ab62bb456a8439efdab3cc5c5963fd3
Author: Debarshi Ray <debarshir gnome org>
Date:   Sun Oct 21 16:22:27 2012 +0200

    goa: Add version definitions
    
    Based on GLib.
    
    Fixes: https://bugzilla.gnome.org/686561

 configure.ac                |   72 +++++++++++++++++++++-
 doc/goa-docs.xml            |    1 +
 doc/goa-sections.txt        |   14 ++++
 src/daemon/Makefile.am      |    1 +
 src/examples/Makefile.am    |    1 +
 src/goa/Makefile.am         |   18 +++++-
 src/goa/goa-1.0.pc.in       |    2 +-
 src/goa/goa.h               |    1 +
 src/goa/goaversion.c        |  145 +++++++++++++++++++++++++++++++++++++++++++
 src/goa/goaversion.h        |   51 +++++++++++++++
 src/goabackend/Makefile.am  |    1 +
 src/goaidentity/Makefile.am |    1 +
 12 files changed, 305 insertions(+), 3 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 37492b7..b1eaa46 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,5 +1,16 @@
+m4_define([goa_major_version], [3])
+m4_define([goa_minor_version], [7])
+m4_define([goa_micro_version], [1])
+m4_define([goa_nano_version], [0])
+
+m4_define([goa_base_version],
+          [goa_major_version.goa_minor_version.goa_micro_version])
+m4_define([goa_version],
+          [m4_if(goa_nano_version, 0, [goa_base_version],
+                 [goa_base_version].[goa_nano_version])])
+
 AC_INIT([GNOME Online Accounts],
-        [3.7.1],
+        [goa_version],
         [https://bugzilla.gnome.org/enter_bug.cgi?product=gnome-online-accounts],
         [gnome-online-accounts])
 
@@ -16,6 +27,24 @@ AC_PROG_LIBTOOL
 
 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
 
+GOA_MAJOR_VERSION=goa_major_version
+GOA_MINOR_VERSION=goa_minor_version
+GOA_MICRO_VERSION=goa_micro_version
+
+AC_SUBST(GOA_MAJOR_VERSION)
+AC_SUBST(GOA_MINOR_VERSION)
+AC_SUBST(GOA_MICRO_VERSION)
+
+AC_DEFINE(GOA_MAJOR_VERSION,
+          [goa_major_version],
+          [Define to the GOA major version])
+AC_DEFINE(GOA_MINOR_VERSION,
+          [goa_minor_version],
+          [Define to the GOA minor version])
+AC_DEFINE(GOA_MICRO_VERSION,
+          [goa_micro_version],
+          [Define to the GOA micro version])
+
 # Initialization
 #
 
@@ -333,6 +362,47 @@ AC_SUBST([GETTEXT_PACKAGE])
 AM_GLIB_GNU_GETTEXT
 AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE],["$GETTEXT_PACKAGE"],[gettext domain])
 
+# goaconfig.h
+#
+
+AC_CONFIG_COMMANDS([src/goa/goaconfig.h],
+[
+	outfile=src/goa/goaconfig.h-tmp
+	cat > $outfile <<\_______EOF
+/* goaconfig.h
+ *
+ * This is a generated file.  Please modify 'configure.ac'
+ */
+
+#ifndef __GOA_CONFIG_H__
+#define __GOA_CONFIG_H__
+
+G_BEGIN_DECLS
+
+_______EOF
+	echo "#define GOA_MAJOR_VERSION $GOA_MAJOR_VERSION" >> $outfile
+	echo "#define GOA_MINOR_VERSION $GOA_MINOR_VERSION" >> $outfile
+	echo "#define GOA_MICRO_VERSION $GOA_MICRO_VERSION" >> $outfile
+	cat >> $outfile <<\_______EOF
+
+G_END_DECLS
+
+#endif /* __GOA_CONFIG_H__ */
+_______EOF
+
+
+	if cmp -s $outfile src/goa/goaconfig.h; then
+	  AC_MSG_NOTICE([src/goa/goaconfig.h is unchanged])
+	  rm -f $outfile
+	else
+	  mv $outfile src/goa/goaconfig.h
+	fi
+],[
+	GOA_MAJOR_VERSION=$GOA_MAJOR_VERSION
+	GOA_MINOR_VERSION=$GOA_MINOR_VERSION
+	GOA_MICRO_VERSION=$GOA_MICRO_VERSION
+])
+
 # Generate
 #
 
diff --git a/doc/goa-docs.xml b/doc/goa-docs.xml
index 3a8b0dc..0fa1ddd 100644
--- a/doc/goa-docs.xml
+++ b/doc/goa-docs.xml
@@ -120,6 +120,7 @@
     <title>Client Library API Reference</title>
     <xi:include href="xml/goaclient.xml"/>
     <xi:include href="xml/goaerror.xml"/>
+    <xi:include href="xml/goaversion.xml"/>
     <chapter id="ref-library-generated">
       <title>Generated Code</title>
       <xi:include href="xml/GoaObject.xml"/>
diff --git a/doc/goa-sections.txt b/doc/goa-sections.txt
index 29b1fba..406a4c7 100644
--- a/doc/goa-sections.txt
+++ b/doc/goa-sections.txt
@@ -385,6 +385,20 @@ goa_error_get_type
 </SECTION>
 
 <SECTION>
+<TITLE>Version Information</TITLE>
+<FILE>goaversion</FILE>
+goa_major_version
+goa_minor_version
+goa_micro_version
+goa_check_version
+<SUBSECTION>
+GOA_MAJOR_VERSION
+GOA_MINOR_VERSION
+GOA_MICRO_VERSION
+GOA_CHECK_VERSION
+</SECTION>
+
+<SECTION>
 <FILE>goaprovider</FILE>
 GoaProvider
 GoaProviderClass
diff --git a/src/daemon/Makefile.am b/src/daemon/Makefile.am
index 7aa53c6..dcb4e7e 100644
--- a/src/daemon/Makefile.am
+++ b/src/daemon/Makefile.am
@@ -2,6 +2,7 @@ NULL =
 
 INCLUDES = 							\
 	-I$(top_builddir)/src -I$(top_srcdir)/src		\
+	-I$(top_builddir)/src/goa				\
 	-I$(top_builddir)/goaidentity				\
 	-I$(top_srcdir)/goaidentity				\
 	-DPACKAGE_LIBEXEC_DIR=\""$(libexecdir)"\" 		\
diff --git a/src/examples/Makefile.am b/src/examples/Makefile.am
index b96a5b9..1b2b2d9 100644
--- a/src/examples/Makefile.am
+++ b/src/examples/Makefile.am
@@ -3,6 +3,7 @@ NULL =
 
 INCLUDES = 							\
 	-I$(top_builddir)/src -I$(top_srcdir)/src		\
+	-I$(top_builddir)/src/goa				\
 	-DPACKAGE_LIBEXEC_DIR=\""$(libexecdir)"\" 		\
 	-DPACKAGE_SYSCONF_DIR=\""$(sysconfdir)"\" 		\
 	-DPACKAGE_DATA_DIR=\""$(pkgdatadir)"\" 			\
diff --git a/src/goa/Makefile.am b/src/goa/Makefile.am
index 64682b1..aacaab1 100644
--- a/src/goa/Makefile.am
+++ b/src/goa/Makefile.am
@@ -1,10 +1,13 @@
 
 NULL =
+BUILT_SOURCES =
 CLEANFILES =
+DISTCLEANFILES =
 EXTRA_DIST =
 
 INCLUDES = 							\
 	-I$(top_builddir)/src -I$(top_srcdir)/src		\
+	-I$(top_builddir)/src/goa				\
 	-DPACKAGE_LIBEXEC_DIR=\""$(libexecdir)"\" 		\
 	-DPACKAGE_SYSCONF_DIR=\""$(sysconfdir)"\" 		\
 	-DPACKAGE_DATA_DIR=\""$(pkgdatadir)"\" 			\
@@ -18,8 +21,19 @@ INCLUDES = 							\
 
 # ----------------------------------------------------------------------------------------------------
 
+DISTCLEANFILES += goaconfig-stamp goaconfig.h
+BUILT_SOURCES += goaconfig-stamp
+configexecincludedir = $(libdir)/goa-1.0/include
+nodist_configexecinclude_HEADERS = goaconfig.h
+goaconfig-stamp: ../../config.status
+	$(AM_V_GEN) cd $(top_builddir) && \
+	  $(SHELL) ./config.status src/goa/goaconfig.h
+	@touch goaconfig-stamp
+
+# ----------------------------------------------------------------------------------------------------
+
 dbus_built_sources = goa-generated.c goa-generated.h goa-generated-doc-org.gnome.OnlineAccounts.Account.xml
-BUILT_SOURCES = $(dbus_built_sources)
+BUILT_SOURCES += $(dbus_built_sources)
 
 $(dbus_built_sources) : Makefile.am $(top_srcdir)/data/dbus-interfaces.xml
 	gdbus-codegen							                \
@@ -62,6 +76,7 @@ libgoa_1_0_la_HEADERS =						\
 	goatypes.h						\
 	goaenums.h						\
 	goaenumtypes.h						\
+	goaversion.h						\
 	goa-generated.h						\
 	$(NULL)
 
@@ -73,6 +88,7 @@ libgoa_1_0_la_SOURCES =						\
 	goatypes.h						\
 	goaenums.h						\
 	goaenumtypes.h			goaenumtypes.c		\
+	goaversion.h			goaversion.c		\
 	$(NULL)
 
 libgoa_1_0_la_CPPFLAGS =					\
diff --git a/src/goa/goa-1.0.pc.in b/src/goa/goa-1.0.pc.in
index 92b1f62..cec1023 100644
--- a/src/goa/goa-1.0.pc.in
+++ b/src/goa/goa-1.0.pc.in
@@ -8,4 +8,4 @@ Description: GNOME Online Accounts Library
 Version: @VERSION@
 Requires: gio-2.0
 Libs: -L${libdir} -lgoa-1.0
-Cflags: -I${includedir}/goa-1.0
+Cflags: -I${includedir}/goa-1.0 -I${libdir}/goa-1.0/include
diff --git a/src/goa/goa.h b/src/goa/goa.h
index ff3cc7f..f7fe76c 100644
--- a/src/goa/goa.h
+++ b/src/goa/goa.h
@@ -31,6 +31,7 @@
 #include <goa/goatypes.h>
 #include <goa/goaclient.h>
 #include <goa/goaerror.h>
+#include <goa/goaversion.h>
 #include <goa/goa-generated.h>
 #undef __GOA_INSIDE_GOA_H__
 
diff --git a/src/goa/goaversion.c b/src/goa/goaversion.c
new file mode 100644
index 0000000..172c480
--- /dev/null
+++ b/src/goa/goaversion.c
@@ -0,0 +1,145 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+/*
+ * Copyright (C) 2012 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author: Debarshi Ray <debarshir gnome org>
+ */
+
+#include "config.h"
+#include "goaversion.h"
+
+/**
+ * SECTION:goaversion
+ * @Title: Version Information
+ * @Short_description: variables and functions to check the GOA version
+ *
+ * GOA provides version information, primarily useful in configure
+ * checks for builds that have a configure script. Applications will
+ * not typically use the features described here.
+ */
+
+/**
+ * GOA_MAJOR_VERSION:
+ *
+ * The major version number of the GOA daemon and library.
+ *
+ * Like #goa_major_version, but from the headers used at
+ * application compile time, rather than from the library
+ * linked against at application run time.
+ *
+ * Since: 3.8
+ */
+
+/**
+ * GOA_MINOR_VERSION:
+ *
+ * The minor version number of the GOA daemon and library.
+ *
+ * Like #goa_minor_version, but from the headers used at
+ * application compile time, rather than from the library
+ * linked against at application run time.
+ *
+ * Since: 3.8
+ */
+
+/**
+ * GOA_MICRO_VERSION:
+ *
+ * The micro version number of the GOA daemon and library.
+ *
+ * Like #goa_micro_version, but from the headers used at
+ * application compile time, rather than from the library
+ * linked against at application run time.
+ *
+ * Since: 3.8
+ */
+
+/**
+ * GOA_CHECK_VERSION:
+ * @major: the major version to check for
+ * @minor: the minor version to check for
+ * @micro: the micro version to check for
+ *
+ * Checks the version of the GOA library that is being compiled
+ * against.
+ *
+ * <example>
+ * <title>Checking the version of the GOA library</title>
+ * <programlisting>
+ *   if (!GOA_CHECK_VERSION (3, 8, 0))
+ *     g_error ("GOA version 3.8.0 or above is needed");
+ * </programlisting>
+ * </example>
+ *
+ * See goa_check_version() for a runtime check.
+ *
+ * Returns: %TRUE if the version of the GOA header files
+ * is the same as or newer than the passed-in version.
+ *
+ * Since: 3.8
+ */
+
+const guint goa_major_version = GOA_MAJOR_VERSION;
+const guint goa_minor_version = GOA_MINOR_VERSION;
+const guint goa_micro_version = GOA_MICRO_VERSION;
+
+/**
+ * goa_check_version:
+ * @required_major: the required major version.
+ * @required_minor: the required minor version.
+ * @required_micro: the required micro version.
+ *
+ * Checks that the GOA library in use is compatible with the
+ * given version. Generally you would pass in the constants
+ * #GOA_MAJOR_VERSION, #GOA_MINOR_VERSION, #GOA_MICRO_VERSION
+ * as the three arguments to this function; that produces
+ * a check that the library in use is compatible with
+ * the version of GOA the application or module was compiled
+ * against.
+ *
+ * Compatibility is defined by two things: first the version
+ * of the running library is newer than the version
+ * @required_major  required_minor @required_micro. Second
+ * the running library must be binary compatible with the
+ * version @required_major  required_minor @required_micro
+ * (same major and minor version).
+ *
+ * Return value: %NULL if the GOA library is compatible with the
+ *   given version, or a string describing the version mismatch.
+ *   The returned string is owned by GOA and must not be modified
+ *   or freed.
+ *
+ * Since: 3.8
+ */
+const gchar *
+goa_check_version (guint required_major,
+                   guint required_minor,
+                   guint required_micro)
+{
+  if (required_major > GOA_MAJOR_VERSION)
+    return "GOA version too old (major mismatch)";
+  if (required_major < GOA_MAJOR_VERSION)
+    return "GOA version too new (major mismatch)";
+  if (required_minor > GOA_MINOR_VERSION)
+    return "GOA version too old (minor mismatch)";
+  if (required_minor < GOA_MINOR_VERSION)
+    return "GOA version too new (minor mismatch)";
+  if (required_micro > GOA_MICRO_VERSION)
+    return "GOA version too old (micro mismatch)";
+  return NULL;
+}
diff --git a/src/goa/goaversion.h b/src/goa/goaversion.h
new file mode 100644
index 0000000..d21a29b
--- /dev/null
+++ b/src/goa/goaversion.h
@@ -0,0 +1,51 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+/*
+ * Copyright (C) 2012 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author: Debarshi Ray <debarshir gnome org>
+ */
+
+#if !defined (__GOA_INSIDE_GOA_H__) && !defined (GOA_COMPILATION)
+#error "Only <goa/goa.h> can be included directly."
+#endif
+
+#ifndef __GOA_VERSION_H__
+#define __GOA_VERSION_H__
+
+#include <glib.h>
+#include <goaconfig.h>
+
+G_BEGIN_DECLS
+
+extern const guint goa_major_version;
+extern const guint goa_minor_version;
+extern const guint goa_micro_version;
+
+const gchar * goa_check_version (guint required_major,
+                                 guint required_minor,
+                                 guint required_micro);
+
+#define GOA_CHECK_VERSION(major,minor,micro)    \
+    (GOA_MAJOR_VERSION > (major) || \
+     (GOA_MAJOR_VERSION == (major) && GOA_MINOR_VERSION > (minor)) || \
+     (GOA_MAJOR_VERSION == (major) && GOA_MINOR_VERSION == (minor) && \
+      GOA_MICRO_VERSION >= (micro)))
+
+G_END_DECLS
+
+#endif /* __GOA_VERSION_H__ */
diff --git a/src/goabackend/Makefile.am b/src/goabackend/Makefile.am
index 3b93250..e9a2c29 100644
--- a/src/goabackend/Makefile.am
+++ b/src/goabackend/Makefile.am
@@ -6,6 +6,7 @@ EXTRA_DIST =
 INCLUDES = 							\
 	-I$(top_builddir)/src -I$(top_srcdir)/src		\
 	-I$(top_builddir)/src -I$(top_srcdir)/src		\
+	-I$(top_builddir)/src/goa				\
 	-I$(top_srcdir)/src/goaidentity				\
 	-DPACKAGE_LIBEXEC_DIR=\""$(libexecdir)"\" 		\
 	-DPACKAGE_SYSCONF_DIR=\""$(sysconfdir)"\" 		\
diff --git a/src/goaidentity/Makefile.am b/src/goaidentity/Makefile.am
index 89d8428..ab31a56 100644
--- a/src/goaidentity/Makefile.am
+++ b/src/goaidentity/Makefile.am
@@ -5,6 +5,7 @@ CLEANFILES= $(NULL)
 
 INCLUDES = 							\
 	-I$(top_builddir)/src -I$(top_srcdir)/src		\
+	-I$(top_builddir)/src/goa				\
 	-I$(top_srcdir)/src/goabackend				\
 	-DPACKAGE_LIBEXEC_DIR=\""$(libexecdir)"\" 		\
 	-DPACKAGE_SYSCONF_DIR=\""$(sysconfdir)"\" 		\



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