build: only use the git version on install, not in the build tree
authorAndrew Tridgell <tridge@samba.org>
Fri, 17 Jun 2011 05:21:39 +0000 (15:21 +1000)
committerAndrew Tridgell <tridge@samba.org>
Fri, 17 Jun 2011 06:37:06 +0000 (08:37 +0200)
having the git version in our version.h in the build tree is annoying
for developers, as every time you commit or rebase you need to spend
several minutes re-linking. This changes it to use the git version
only on install, which is much more useful as when you actually
install the binaries you may be using them in a way that reporting the
version is useful

Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>

Autobuild-User: Andrew Tridgell <tridge@samba.org>
Autobuild-Date: Fri Jun 17 08:37:06 CEST 2011 on sn-devel-104

buildtools/wafsamba/samba_patterns.py
buildtools/wafsamba/samba_version.py
wscript
wscript_build

index 37ef4198a680dbd8810127dcaf47a0049b5b2d02..f064608f3a3051818fb7ddba9c42d10b8296402d 100644 (file)
@@ -10,7 +10,7 @@ def write_version_header(task):
     src = task.inputs[0].srcpath(task.env)
     tgt = task.outputs[0].bldpath(task.env)
 
-    version = samba_version_file(src, task.env.srcdir, env=task.env)
+    version = samba_version_file(src, task.env.srcdir, env=task.env, is_install=task.env.is_install)
     string = str(version)
 
     f = open(tgt, 'w')
@@ -26,4 +26,5 @@ def SAMBA_MKVERSION(bld, target):
                             source= 'VERSION',
                             target=target,
                             always=True)
+    t.env.is_install = bld.is_install
 Build.BuildContext.SAMBA_MKVERSION = SAMBA_MKVERSION
index 0b0c159f55ff5ec8b361caf3c98df9ed6eb32b95..0c39ed44ecdf938a2ec867b96b7f642bf657d418 100644 (file)
@@ -90,7 +90,7 @@ def git_version_summary(path, env=None):
 
 class SambaVersion(object):
 
-    def __init__(self, version_dict, path, env=None):
+    def __init__(self, version_dict, path, env=None, is_install=True):
         '''Determine the version number of samba
 
 See VERSION for the format.  Entries on that file are 
@@ -152,7 +152,10 @@ also accepted as dictionary entries here
             SAMBA_VERSION_STRING += ("rc%u" % self.RC_RELEASE)
 
         if self.IS_SNAPSHOT:
-            if os.path.exists(os.path.join(path, ".git")):
+            if not is_install:
+                suffix = "DEVELOPERBUILD"
+                self.vcs_fields = {}
+            elif os.path.exists(os.path.join(path, ".git")):
                 suffix, self.vcs_fields = git_version_summary(path, env=env)
             elif os.path.exists(os.path.join(path, ".bzr")):
                 suffix, self.vcs_fields = bzr_version_summary(path)
@@ -234,7 +237,7 @@ also accepted as dictionary entries here
         return string
 
 
-def samba_version_file(version_file, path, env=None):
+def samba_version_file(version_file, path, env=None, is_install=True):
     '''Parse the version information from a VERSION file'''
 
     f = open(version_file, 'r')
@@ -254,16 +257,16 @@ def samba_version_file(version_file, path, env=None):
             print("Failed to parse line %s from %s" % (line, version_file))
             raise
 
-    return SambaVersion(version_dict, path, env=env)
+    return SambaVersion(version_dict, path, env=env, is_install=is_install)
 
 
 
-def load_version(env=None):
+def load_version(env=None, is_install=True):
     '''load samba versions either from ./VERSION or git
     return a version object for detailed breakdown'''
     if not env:
         env = samba_utils.LOAD_ENVIRONMENT()
 
-    version = samba_version_file("./VERSION", ".", env)
+    version = samba_version_file("./VERSION", ".", env, is_install=is_install)
     Utils.g_module.VERSION = version.STRING
     return version
diff --git a/wscript b/wscript
index 92c2594f3ebbc8f163c83a681884b27037012650..8e1e9a6305b18060eedccba4fa0b63ab0c1d220c 100755 (executable)
--- a/wscript
+++ b/wscript
@@ -157,7 +157,7 @@ def ctags(ctx):
 # of commands in --help
 def build(bld):
     '''build all targets'''
-    samba_version.load_version(env=bld.env)
+    samba_version.load_version(env=bld.env, is_install=bld.is_install)
     pass
 
 
index 43e69a5904260271ce897f6119594478dd1f4032..20437577461c35120a9d67647e3ab5b69a81d435 100644 (file)
@@ -27,7 +27,7 @@ bld.env.public_headers_skip = ['param/param_proto.h', 'lib/ldb_compat.h']
 # force headers to use SAMBA4 rules
 bld.env.public_headers_replace = { '#if _SAMBA_BUILD_ == 4' : '#if 1 /* _SAMBA_BUILD_ == 4 */' }
 
-samba_version.load_version(bld.env)
+samba_version.load_version(bld.env, is_install=bld.is_install)
 bld.SAMBA_MKVERSION('version.h')
 
 # bld.ENABLE_MAGIC_ORDERING()