The attached is a patch that I plan to push later on that splits our versioning between version.h and version_nano.h.

One issue we have is that because configure.ac processes version.h (but not the LIBUSB_NANO part of it) is that every time someone issues a git pull against our tree, they will go through a reconf, regardless of whether needed or not. By moving the nano away from version.h we can avoid that, and it also removes the dependency on sed in the git hooks (though this only matters for maintainers anyway).

Regards,

/Pete

>From a221271c67414ad5372431dced352fc2b1e15cbc Mon Sep 17 00:00:00 2001
From: Pete Batard <p...@akeo.ie>
Date: Thu, 10 May 2012 15:56:51 +0100
Subject: [PATCH] Misc: Separate nano from version.h

* As version.h processed by autotools, the automatic updating of the
  nano there can result in unneeded reconfs (eg. after issuing a git
  pull, regardless of whether the conf is still valid)
* Avoid this by placing the nano in its own file, as it won't be
  processed by autoconf. This also simplifies the versioning git hooks
  and removes the sed dependency.
---
 .private/pre-commit.sh |   12 ++----------
 libusb/version.h       |    3 ++-
 libusb/version_nano.h  |    1 +
 3 files changed, 5 insertions(+), 11 deletions(-)
 create mode 100644 libusb/version_nano.h

diff --git a/.private/pre-commit.sh b/.private/pre-commit.sh
index c62fb35..7c95674 100755
--- a/.private/pre-commit.sh
+++ b/.private/pre-commit.sh
@@ -26,14 +26,8 @@
 BRANCH_OFFSET=10000
 
################################################################################
 
-type -P sed &>/dev/null || { echo "sed command not found. Aborting." >&2; exit 
1; }
 type -P git &>/dev/null || { echo "git command not found. Aborting." >&2; exit 
1; }
 
-# The -b option of sed, which we use to prevent CRLF conversions on Windows
-# was only introduced recently, and Linux distros may not have it
-SED_CMD='sed -b'
-$SED_CMD --version > /dev/null 2>&1 || SED_CMD='sed'
-
 NANO=`git log --oneline | wc -l`
 NANO=`expr $NANO + $BRANCH_OFFSET`
 # Amended commits need to have the nano corrected. Current versions of git 
hooks
@@ -44,7 +38,5 @@ if [ -f .amend ]; then
   NANO=`expr $NANO - 1`
 fi
 echo "setting nano to $NANO"
-# -i option of sed is useless on Windows.
-$SED_CMD -e "s/^#define LIBUSB_NANO.*/#define LIBUSB_NANO $NANO/" 
libusb/version.h > libusb/version.h~
-mv libusb/version.h~ libusb/version.h
-git add libusb/version.h
+echo "#define LIBUSB_NANO $NANO" > libusb/version_nano.h
+git add libusb/version_nano.h
diff --git a/libusb/version.h b/libusb/version.h
index a31d435..4a6d028 100644
--- a/libusb/version.h
+++ b/libusb/version.h
@@ -1,4 +1,5 @@
 /* This file is parsed by m4 and windres and RC.EXE so please keep it simple. 
*/
+#include "version_nano.h"
 #ifndef LIBUSB_MAJOR
 #define LIBUSB_MAJOR 1
 #endif
@@ -9,7 +10,7 @@
 #define LIBUSB_MICRO 11
 #endif
 #ifndef LIBUSB_NANO
-#define LIBUSB_NANO 10502
+#define LIBUSB_NANO 0
 #endif
 /* LIBUSB_RC is the release candidate suffix. Should normally be empty. */
 #ifndef LIBUSB_RC
diff --git a/libusb/version_nano.h b/libusb/version_nano.h
new file mode 100644
index 0000000..925479e
--- /dev/null
+++ b/libusb/version_nano.h
@@ -0,0 +1 @@
+#define LIBUSB_NANO 10503
-- 
1.7.9.msysgit.0

------------------------------------------------------------------------------
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