Skip to content

Commit

Permalink
misc: add ARAVIS_CHECK_VERSION macro
Browse files Browse the repository at this point in the history
  • Loading branch information
EmmanuelP committed Oct 12, 2016
1 parent d618ec6 commit f7027f8
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 3 deletions.
11 changes: 11 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
AC_SUBST([ARAVIS_API_VERSION], [0.6])
AC_SUBST([ARAVIS_API_VERSION_U],[AS_TR_SH([$ARAVIS_API_VERSION])])

ARAVIS_MAJOR_VERSION=aravis_version_major
ARAVIS_MINOR_VERSION=aravis_version_minor
ARAVIS_MICRO_VERSION=aravis_version_micro
ARAVIS_VERSION=aravis_version

AC_SUBST(ARAVIS_MAJOR_VERSION)
AC_SUBST(ARAVIS_MINOR_VERSION)
AC_SUBST(ARAVIS_MICRO_VERSION)
AC_SUBST(ARAVIS_VERSION)

AC_SEARCH_LIBS([strerror],[cposix])
AC_PROG_CC
AC_PROG_CXX
Expand Down Expand Up @@ -245,6 +255,7 @@ AC_CONFIG_FILES([
Makefile
src/Makefile
src/arvfeatures.h
src/arvversion.h
viewer/Makefile
viewer/data/Makefile
viewer/data/arv-viewer.desktop.in
Expand Down
6 changes: 5 additions & 1 deletion docs/reference/aravis/aravis-sections.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
<SECTION>
<FILE>arvcamera</FILE>
<TITLE>ArvCamera</TITLE>
ARAVIS_CHECK_VERSION
ARAVIS_MAJOR_VERSION
ARAVIS_MICRO_VERSION
ARAVIS_MINOR_VERSION
ARAVIS_HAS_PACKET_SOCKET
ARAVIS_HAS_USB
ArvAuto
arv_auto_from_string
arv_auto_to_string
Expand Down Expand Up @@ -247,7 +252,6 @@ ARV_FAKE_INTERFACE_SOCKET_BUFFER_SIZE
<SECTION>
<FILE>arvuvinterface</FILE>
<TITLE>ArvUvInterface</TITLE>
ARAVIS_HAS_USB
<SUBSECTION Standard>
ArvUvInterface
ARV_IS_UV_INTERFACE
Expand Down
1 change: 1 addition & 0 deletions src/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ arvenumtypes.h
arvconfig.h
arvconfig.h.in
arvfeatures.h
arvversion.h
4 changes: 2 additions & 2 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ AM_CFLAGS = -Wall

lib_LTLIBRARIES = libaravis-@[email protected]

BUILT_SOURCES = arvenumtypes.h arvenumtypes.c arvfeatures.h
BUILT_SOURCES = arvenumtypes.h arvenumtypes.c arvfeatures.h arvversion.h

EXTRA_DIST += arvenumtypes.h.template \
arvenumtypes.c.template
Expand Down Expand Up @@ -195,7 +195,7 @@ libaravis_@ARAVIS_API_VERSION@_ladir = $(includedir)/aravis-@ARAVIS_API_VERSION@
libaravis_@ARAVIS_API_VERSION@_la_HEADERS = $(ARAVIS_HDRS) $(ARAVIS_HDRS_NO_INTRO)
libaravis_@ARAVIS_API_VERSION@_la_HEADERS += arvenumtypes.h

nodist_libaravis_@ARAVIS_API_VERSION@_la_HEADERS = arvfeatures.h
nodist_libaravis_@ARAVIS_API_VERSION@_la_HEADERS = arvfeatures.h arvversion.h

arvenumtypes.h: arvenumtypes.h.template $(ARAVIS_HDRS) $(ARAVIS_HDRS_NO_INTRO) $(GLIB_MKENUMS)
$(AM_V_GEN) (cd $(srcdir) && $(GLIB_MKENUMS) --template arvenumtypes.h.template $(libaravis_@ARAVIS_API_VERSION@_la_HEADERS)) > $@
Expand Down
2 changes: 2 additions & 0 deletions src/arv.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

#include <arvtypes.h>

#include <arvfeatures.h>
#include <arvversion.h>
#include <arvdebug.h>
#include <arvmisc.h>
#include <arvzip.h>
Expand Down
83 changes: 83 additions & 0 deletions src/arvversion.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/* Aravis - Digital camera library
*
* Copyright © 2009-2016 Emmanuel Pacaud
*
* 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., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
* Author: Emmanuel Pacaud <[email protected]>
*/

#ifndef ARV_VERSION_H
#define ARV_VERSION_H

#include <arvtypes.h>

G_BEGIN_DECLS

/**
* ARAVIS_MAJOR_VERSION:
*
* The major version of the Aravis library.
*
* Since: 0.6.0
*/

#define ARAVIS_MAJOR_VERSION @ARAVIS_MAJOR_VERSION@

/**
* ARAVIS_MINOR_VERSION:
*
* The minor version of the Aravis library.
*
* Since: 0.6.0
*/

#define ARAVIS_MINOR_VERSION @ARAVIS_MINOR_VERSION@

/**
* ARAVIS_MICRO_VERSION:
*
* The micor version of the Aravis library.
*
* Since: 0.6.0
*/

#define ARAVIS_MICRO_VERSION @ARAVIS_MICRO_VERSION@

/**
* ARAVIS_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 Aravis library that is being compiled
* against.
*
* Returns: %TRUE if the version of the Aravis header files
* is the same as or newer than the passed-in version.
*
* Since: 0.6.0
*/

#define ARAVIS_CHECK_VERSION(major,minor,micro) \
(ARAVIS_MAJOR_VERSION > (major) || \
(ARAVIS_MAJOR_VERSION == (major) && ARAVIS_MINOR_VERSION > (minor)) || \
(ARAVIS_MAJOR_VERSION == (major) && ARAVIS_MINOR_VERSION == (minor) && \
ARAVIS_MICRO_VERSION >= (micro)))

G_END_DECLS

#endif
4 changes: 4 additions & 0 deletions tests/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
#include <arvstr.h>
#include <string.h>

#if !ARAVIS_CHECK_VERSION (ARAVIS_MAJOR_VERSION, ARAVIS_MINOR_VERSION, ARAVIS_MICRO_VERSION)
#error
#endif

static void
unaligned_from_le_ptr_test (void)
{
Expand Down

0 comments on commit f7027f8

Please sign in to comment.