Hans de Goede wrote:
> my vote *in this case* goes to adding the 2 fields.

I pushed the attached commit to libusb-stuge.git x/version_rc_describe
which is based on current libusbx.git master.

Anyone wanting to apply the change can grab the patch, or maybe save
time with:

git fetch git://git.libusb.org/libusb-stuge.git x/version_rc_describe && \
  git cherry-pick FETCH_HEAD


//Peter
>From 41a92270fe608351a610630be3369185ce3f35ed Mon Sep 17 00:00:00 2001
From: Peter Stuge <pe...@stuge.se>
Date: Thu, 19 Apr 2012 22:55:44 +0200
Subject: [PATCH] Core: Add struct libusb_version members rc and describe

libusb.git commit df35117ce58b74fa530baaaccc30adaf432398ea
---
 libusb/Makefile.am |    3 ++-
 libusb/core.c      |    9 ++++++---
 libusb/libusb.h    |   21 +++++++++++++++++----
 msvc/config.h      |    3 +++
 4 files changed, 28 insertions(+), 8 deletions(-)

diff --git a/libusb/Makefile.am b/libusb/Makefile.am
index 0e7fc88..6b605a3 100644
--- a/libusb/Makefile.am
+++ b/libusb/Makefile.am
@@ -36,7 +36,8 @@ else
 THREADS_SRC = os/threads_windows.h os/threads_windows.c
 endif
 
-libusb_1_0_la_CFLAGS = $(VISIBILITY_CFLAGS) $(AM_CFLAGS) $(THREAD_CFLAGS)
+libusb_1_0_la_CFLAGS = $(VISIBILITY_CFLAGS) $(AM_CFLAGS) $(THREAD_CFLAGS) \
+       -DLIBUSB_DESCRIBE=\"`git --git-dir "$(top_srcdir)/.git" describe --tags 
2>/dev/null`\"
 libusb_1_0_la_LDFLAGS = $(LTLDFLAGS)
 libusb_1_0_la_SOURCES = libusbi.h core.c descriptor.c io.c sync.c $(OS_SRC) \
        os/linux_usbfs.h os/darwin_usb.h os/windows_usb.h \
diff --git a/libusb/core.c b/libusb/core.c
index b50af56..b389bc6 100644
--- a/libusb/core.c
+++ b/libusb/core.c
@@ -43,7 +43,10 @@ const struct usbi_os_backend * const usbi_backend = 
&windows_backend;
 
 struct libusb_context *usbi_default_context = NULL;
 const struct libusb_version libusb_version_internal =
-       { LIBUSB_MAJOR, LIBUSB_MINOR, LIBUSB_MICRO, LIBUSB_NANO};
+{
+       LIBUSB_MAJOR, LIBUSB_MINOR, LIBUSB_MICRO, LIBUSB_NANO, LIBUSB_RC,
+       LIBUSB_DESCRIBE
+};
 static int default_context_refcnt = 0;
 static usbi_mutex_static_t default_context_lock = USBI_MUTEX_INITIALIZER;
 
@@ -1764,8 +1767,8 @@ DEFAULT_VISIBILITY const char * LIBUSB_CALL 
libusb_error_name(int error_code)
 }
 
 /** \ingroup misc
- * Fills a libusb_version struct with the full version (major, minor,
- * micro, nano) of this library
+ * Returns a pointer to const struct libusb_version with the version
+ * (major, minor, micro, nano, rc, and describe) of the running library.
  */
 DEFAULT_VISIBILITY
 const struct libusb_version * LIBUSB_CALL libusb_get_version(void)
diff --git a/libusb/libusb.h b/libusb/libusb.h
index da4683c..e417f67 100644
--- a/libusb/libusb.h
+++ b/libusb/libusb.h
@@ -642,10 +642,23 @@ struct libusb_device_handle;
  * Structure providing the version of libusbx currently in use
  */
 struct libusb_version {
-       uint16_t major;
-       uint16_t minor;
-       uint16_t micro;
-       uint16_t nano;
+       /** Library major version. */
+       const uint16_t major;
+
+       /** Library minor version. */
+       const uint16_t minor;
+
+       /** Library micro version. */
+       const uint16_t micro;
+
+       /** Library nano version. This field is incremented on each commit. */
+       const uint16_t nano;
+
+       /** Library release candidate suffix string, e.g. "-rc4". */
+       const char *rc;
+
+       /** Output of `git describe --tags` at library build time. */
+       const char *describe;
 };
 
 /** \ingroup lib
diff --git a/msvc/config.h b/msvc/config.h
index 43b4d4e..43aa1f7 100644
--- a/msvc/config.h
+++ b/msvc/config.h
@@ -19,3 +19,6 @@
 
 /* type of second poll() argument */
 #define POLL_NFDS_TYPE unsigned int
+
+/* no way to run git describe from MSVC? */
+#define LIBUSB_DESCRIBE ""
-- 
1.7.4.1.343.ga91df.dirty

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
libusbx-devel mailing list
libusbx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusbx-devel

Reply via email to