← Back to team overview

linuxdcpp-team team mailing list archive

[Branch ~linuxdcpp-team/linuxdcpp/trunk] Rev 365: Use bzrlib to get revno

 

------------------------------------------------------------
revno: 365
committer: Steven Sheehy <steven.sheehy@xxxxxxxxx>
branch nick: trunk
timestamp: Wed 2010-03-24 01:29:10 -0500
message:
  Use bzrlib to get revno
modified:
  SConstruct
  linux/SConscript
  linux/version.cc


--
lp:linuxdcpp
https://code.launchpad.net/~linuxdcpp-team/linuxdcpp/trunk

Your team LinuxDC++ Team is subscribed to branch lp:linuxdcpp.
To unsubscribe from this branch go to https://code.launchpad.net/~linuxdcpp-team/linuxdcpp/trunk/+edit-subscription.
=== modified file 'SConstruct'
--- SConstruct	2010-03-24 00:41:52 +0000
+++ SConstruct	2010-03-24 06:29:10 +0000
@@ -5,6 +5,11 @@
 import commands
 import string
 
+try:
+	from bzrlib import branch
+except ImportError:
+	print "bzrlib not installed"
+
 EnsureSConsVersion(0, 98, 1)
 
 APP_NAME = 'linuxdcpp'
@@ -43,14 +48,14 @@
 
 def CheckBZRRevision():
 	print "Checking tree revision...",
-	ret = commands.getoutput('bzr revno')
-	print ret
-	retval = 0
+	retval = ''
+
 	try:
-		if string.atoi(ret) > 0:
-			retval = string.atoi(ret)
-	except ValueError:
-		print "Error while getting revision number"
+		b = branch.Branch.open('.')
+		retval = b.revno()
+		print retval
+	except:
+		print "failed"
 
 	return retval
 
@@ -218,14 +223,6 @@
 	if conf.CheckHeader(['sys/types.h', 'sys/socket.h', 'ifaddrs.h', 'net/if.h']):
 		conf.env['HAVE_IFADDRS_H'] = True
 
-	rev = CheckBZRRevision()
-	if rev != 0: 	
-		conf.env['LDCPP_BZRREV'] = rev
-	else:
-		conf.env['LDCPP_BZRREV'] = 0
-		print 'Revision number will not be included'
-
-
 	env = conf.Finish()
 
 
@@ -233,6 +230,8 @@
 # Compile and link flags
 # ----------------------------------------------------------------------
 
+	env['LDCPP_BZRREV'] = CheckBZRRevision()
+
 	# todo: remove -fpermissive and fix the errors
 	env.Append(CXXFLAGS = ['-I.', '-D_GNU_SOURCE', '-D_LARGEFILE_SOURCE', '-D_FILE_OFFSET_BITS=64', '-D_REENTRANT', '-fpermissive'])
 

=== modified file 'linux/SConscript'
--- linux/SConscript	2010-03-24 02:00:27 +0000
+++ linux/SConscript	2010-03-24 06:29:10 +0000
@@ -12,8 +12,9 @@
 # Build the gui_files
 for i, source in enumerate(gui_files):
 	#define LDCPP_BZRREV for linux/version.cc
-	if env['LDCPP_BZRREV'] != 0 and str(source).find("version.cc") != -1:
-		obj_files.append(env.Object(source, CXXFLAGS=env['CXXFLAGS'] + str('-DLDCPP_BZRREV=\\"'+str(env['LDCPP_BZRREV'])+'\\"'))) 
+	if str(source).find("version.cc") != -1:
+		ldcpp_bzrrev = '-DLDCPP_BZRREV=\\"%s\\"' % env['LDCPP_BZRREV']
+		obj_files.append(env.Object(source, CPPDEFINES=ldcpp_bzrrev)) 
 	else:
 		obj_files.append(env.Object(source))
 

=== modified file 'linux/version.cc'
--- linux/version.cc	2010-03-24 02:00:27 +0000
+++ linux/version.cc	2010-03-24 06:29:10 +0000
@@ -21,11 +21,5 @@
 
 #include "version.hh"
 
-#ifndef LDCPP_BZRREV
-	const char* LINUXDCPP_VERSION_STRING = "1.0.3+bzr";
-#else
-	const char* LINUXDCPP_VERSION_STRING = "1.0.3-r" LDCPP_BZRREV;
-#endif
-
-
+const char* LINUXDCPP_VERSION_STRING = "1.0.3-bzr" LDCPP_BZRREV;