← Back to team overview

linuxdcpp-team team mailing list archive

[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2702: avoid rebuilding the dcpp lib on rev number changes

 

------------------------------------------------------------
revno: 2702
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Tue 2011-12-06 20:24:42 +0100
message:
  avoid rebuilding the dcpp lib on rev number changes
added:
  dcpp/gen_revno.py
modified:
  .bzrignore
  dcpp/SConscript
  dcpp/version.cpp
  dcpp/version.h


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

Your team Dcplusplus-team is subscribed to branch lp:dcplusplus.
To unsubscribe from this branch go to https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk/+edit-subscription
=== modified file '.bzrignore'
--- .bzrignore	2011-10-16 23:06:25 +0000
+++ .bzrignore	2011-12-06 19:24:42 +0000
@@ -6,6 +6,7 @@
 custom.py
 *.lib
 *.pdb
+./dcpp/version-revno.inc
 ./htmlhelp/include/htmlhelp.h
 ./htmlhelp/lib/htmlhelp.lib
 natupnp.h

=== modified file 'dcpp/SConscript'
--- dcpp/SConscript	2011-11-12 19:36:12 +0000
+++ dcpp/SConscript	2011-12-06 19:24:42 +0000
@@ -1,39 +1,22 @@
 # vim: set filetype=py
 
-def getRevision(env):
-	try:
-		import bzrlib
-		import bzrlib.builtins
-
-		tree = bzrlib.builtins.WorkingTree.open_containing(env.Dir("#").abspath)[0]
-
-		return tree.branch.revision_id_to_revno(tree.last_revision())
-
-	except:
-		f = None
-		try:
-			f = open(env.Dir("#").abspath+"/.bzr/branch/last-revision",'r')
-			line = f.read()
-			pos = line.find(' ')
-			if pos > 0:
-				return int(line[:pos])
-		except:
-			pass
-		finally:
-			if f:
-				f.close()
-		return 0
-
 Import('dev source_path')
 
 env, target, sources = dev.prepare_build(source_path, 'dcpp', in_bin = False, precompiled_header = 'stdinc')
 
 env.Append(CPPPATH = ['#/openssl/include', '#/bzip2', '#/zlib', '#/geoip'])
 
-env.Append(CPPDEFINES = ['BUILDING_DCPP=1', 'DCPP_REVISION=' + str(getRevision(env))])
+env.Append(CPPDEFINES = ['BUILDING_DCPP=1'])
 
 headers=dev.get_sources(source_path, "*.h")
 dev.i18n(source_path, env, [sources, headers], 'libdcpp')
 
 ret = dev.build_lib(env, target, sources, dev.cpp_lib)
+
+if ret:
+	revno = '#/dcpp/version-revno.inc'
+	from gen_revno import gen_revno
+	env.Command(revno, None, Action(gen_revno, 'Generating $TARGET'))
+	env.AlwaysBuild(revno)
+
 Return('ret')

=== added file 'dcpp/gen_revno.py'
--- dcpp/gen_revno.py	1970-01-01 00:00:00 +0000
+++ dcpp/gen_revno.py	2011-12-06 19:24:42 +0000
@@ -0,0 +1,28 @@
+def get_revision(env):
+	try:
+		import bzrlib
+		import bzrlib.builtins
+
+		tree = bzrlib.builtins.WorkingTree.open_containing(env.Dir("#").abspath)[0]
+
+		return tree.branch.revision_id_to_revno(tree.last_revision())
+
+	except:
+		f = None
+		try:
+			f = open(env.Dir("#").abspath+"/.bzr/branch/last-revision",'r')
+			line = f.read()
+			pos = line.find(' ')
+			if pos > 0:
+				return int(line[:pos])
+		except:
+			pass
+		finally:
+			if f:
+				f.close()
+		return 0
+
+def gen_revno(target, source, env):
+	f = open(str(target[0]), 'wb')
+	f.write('#define DCPP_REVISION ' + str(get_revision(env)) + '\n')
+	f.close()

=== modified file 'dcpp/version.cpp'
--- dcpp/version.cpp	2011-01-27 23:11:24 +0000
+++ dcpp/version.cpp	2011-12-06 19:24:42 +0000
@@ -17,18 +17,13 @@
  */
 
 #include "stdinc.h"
-#include "DCPlusPlus.h"
-
 #include "version.h"
 
-#ifndef DCPP_REVISION
-#define DCPP_REVISION 0
-#endif
+#include "version-revno.inc" // should #define DCPP_REVISION
 
 #define xstrver(s) strver(s)
 #define strver(s) #s
 
 namespace dcpp {
-const string fullVersionString(APPNAME " v" VERSIONSTRING " (r" xstrver(DCPP_REVISION) ")");
+const std::string fullVersionString(APPNAME " v" VERSIONSTRING " (r" xstrver(DCPP_REVISION) ")");
 }
-

=== modified file 'dcpp/version.h'
--- dcpp/version.h	2011-02-01 20:32:13 +0000
+++ dcpp/version.h	2011-12-06 19:24:42 +0000
@@ -16,6 +16,8 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
 
+#include <string>
+
 #define APPNAME "DC++"
 
 // don't forget to update the .rc file as well!
@@ -23,5 +25,5 @@
 #define VERSIONFLOAT 0.785
 
 namespace dcpp {
-extern const string fullVersionString;
+extern const std::string fullVersionString;
 }