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

[or-cvs] r9976: A hack I've been wanting for a while: when building a -dev v (in tor/trunk: . doc src/or)



Author: nickm
Date: 2007-04-16 19:56:31 -0400 (Mon, 16 Apr 2007)
New Revision: 9976

Modified:
   tor/trunk/ChangeLog
   tor/trunk/doc/TODO
   tor/trunk/src/or/Makefile.am
   tor/trunk/src/or/config.c
   tor/trunk/src/or/router.c
   tor/trunk/src/or/test.c
   tor/trunk/src/or/tor_main.c
Log:
A hack I've been wanting for a while: when building a -dev version
from an SVN repository, use the current svn revision in the platform
string and in the output of --version.



Modified: tor/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog	2007-04-16 21:37:21 UTC (rev 9975)
+++ tor/trunk/ChangeLog	2007-04-16 23:56:31 UTC (rev 9976)
@@ -23,6 +23,8 @@
     - When warning about missing headers, tell the user to let us
       know if the compile succeeds anyway, so we can downgrade the
       warning.
+    - If we're building from a subversion repository, include the current
+      SVN revision as part of the version string.
 
   o Minor features (logging):
     - Always prepend "Bug: " to any log message about a bug.

Modified: tor/trunk/doc/TODO
===================================================================
--- tor/trunk/doc/TODO	2007-04-16 21:37:21 UTC (rev 9975)
+++ tor/trunk/doc/TODO	2007-04-16 23:56:31 UTC (rev 9976)
@@ -357,8 +357,9 @@
     such errors recently, then don't warn about it.
   - More consistent error checking in router_parse_entry_from_string().
     I can say "banana" as my bandwidthcapacity, and it won't even squeak.
-  - Include the output of svn info/svk info output into the binary, so
-    it's trivial to see what version a binary was built from.
+  o Include the output of svn info in the binary, so it's trivial to see what
+    version a binary was built from.
+    - Do the same for svk info.
   - Add a doxygen style checker to make check-spaces so nick doesn't drift
     too far from arma's undocumented styleguide.  Also, document that
     styleguide in HACKING.  (See r9634 for example.)

Modified: tor/trunk/src/or/Makefile.am
===================================================================
--- tor/trunk/src/or/Makefile.am	2007-04-16 21:37:21 UTC (rev 9975)
+++ tor/trunk/src/or/Makefile.am	2007-04-16 23:56:31 UTC (rev 9976)
@@ -28,3 +28,17 @@
 
 noinst_HEADERS = or.h eventdns.h eventdns_tor.h
 
+tor_main.o: micro-revision.i
+
+micro-revision.i: FORCE
+	rm -f micro-revision.i;					\
+	if test -d ../../.svn ; then 				\
+	  svn info ../.. |              			\
+	  sed -n 's/^Revision: \([0-9][0-9]*\).*/"\1"/p' > micro-revision.i \
+	     || true; \
+	fi;							\
+	if test ! -f micro-revision.i; then			\
+	  echo '""' > micro-revision.i;				\
+	fi
+
+FORCE:

Modified: tor/trunk/src/or/config.c
===================================================================
--- tor/trunk/src/or/config.c	2007-04-16 21:37:21 UTC (rev 9975)
+++ tor/trunk/src/or/config.c	2007-04-16 23:56:31 UTC (rev 9976)
@@ -2982,6 +2982,8 @@
   return r;
 }
 
+extern const char tor_svn_revision[]; /* from main.c */
+
 /** Read a configuration file into <b>options</b>, finding the configuration
  * file location based on the command line.  After loading the options,
  * validate them for consistency, then take actions based on them.
@@ -3018,7 +3020,13 @@
   }
 
   if (argc > 1 && (!strcmp(argv[1],"--version"))) {
-    printf("Tor version %s.\n",VERSION);
+    char vbuf[128];
+    if (tor_svn_revision && strlen(tor_svn_revision)) {
+      tor_snprintf(vbuf, sizeof(vbuf), " (r%s)", tor_svn_revision);
+    } else {
+      vbuf[0] = 0;
+    }
+    printf("Tor version %s%s.\n",VERSION,vbuf);
     if (argc > 2 && (!strcmp(argv[2],"--version"))) {
       print_svn_version();
     }

Modified: tor/trunk/src/or/router.c
===================================================================
--- tor/trunk/src/or/router.c	2007-04-16 21:37:21 UTC (rev 9975)
+++ tor/trunk/src/or/router.c	2007-04-16 23:56:31 UTC (rev 9976)
@@ -1172,6 +1172,8 @@
   return -1;
 }
 
+extern const char tor_svn_revision[]; /* from main.c */
+
 /** Set <b>platform</b> (max length <b>len</b>) to a NUL-terminated short
  * string describing the version of Tor and the operating system we're
  * currently running on.
@@ -1179,8 +1181,17 @@
 void
 get_platform_str(char *platform, size_t len)
 {
-  tor_snprintf(platform, len, "Tor %s on %s",
-           VERSION, get_uname());
+  char svn_version_buf[128];
+  if (!strcmpend(VERSION, "-dev") &&
+      tor_svn_revision && strlen(tor_svn_revision)) {
+    tor_snprintf(svn_version_buf, sizeof(svn_version_buf), " (r%s)",
+                 tor_svn_revision);
+  } else {
+    svn_version_buf[0] = 0;
+  }
+
+  tor_snprintf(platform, len, "Tor %s%s on %s",
+               VERSION, svn_version_buf, get_uname());
   return;
 }
 

Modified: tor/trunk/src/or/test.c
===================================================================
--- tor/trunk/src/or/test.c	2007-04-16 21:37:21 UTC (rev 9975)
+++ tor/trunk/src/or/test.c	2007-04-16 23:56:31 UTC (rev 9976)
@@ -5,6 +5,8 @@
 const char test_c_id[] =
   "$Id$";
 
+const char tor_svn_revision[] = "";
+
 /**
  * \file test.c
  * \brief Unit tests for many pieces of the lower level Tor modules.

Modified: tor/trunk/src/or/tor_main.c
===================================================================
--- tor/trunk/src/or/tor_main.c	2007-04-16 21:37:21 UTC (rev 9975)
+++ tor/trunk/src/or/tor_main.c	2007-04-16 23:56:31 UTC (rev 9976)
@@ -5,6 +5,10 @@
 const char tor_main_c_id[] =
   "$Id$";
 
+const char tor_svn_revision[] =
+#include "micro-revision.i"
+  "";
+
 /**
  * \file tor_main.c
  * \brief Stub module containing a main() function. Allows unit