[SCM] Samba Shared Repository - branch master updated

Andrew Tridgell tridge at samba.org
Mon Jun 28 22:29:25 MDT 2010


The branch, master has been updated
       via  30dc87d... build: only use git when found by configure
       via  3774ba3... build: allow LOAD_ENVIRONMENT() to pass when no configure has been run
       via  8cbd36a... build: allow always=True/False on SAMBA_GENERATOR()
      from  1e8876a... s4/repl_meta_data: remove duplicated (and commented out) log

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 30dc87dab98a864ea640fb1df693b6eb8df6a920
Author: Andrew Tridgell <tridge at samba.org>
Date:   Mon Jun 28 13:40:32 2010 +1000

    build: only use git when found by configure
    
    this rebuilds version.h whenever the git version changes, so we always
    get the right version with samba -V. That adds about 15s to the build
    time on each git commit, which shouldn't be too onerous

commit 3774ba350e6b828512e693b982e0927877cd13eb
Author: Andrew Tridgell <tridge at samba.org>
Date:   Mon Jun 28 13:39:00 2010 +1000

    build: allow LOAD_ENVIRONMENT() to pass when no configure has been run
    
    this returns an empty environment

commit 8cbd36afe84685ee1e289fee11065d3eb0cadc22
Author: Andrew Tridgell <tridge at samba.org>
Date:   Mon Jun 28 12:07:55 2010 +1000

    build: allow always=True/False on SAMBA_GENERATOR()
    
    this allows us to force a rule to always run. Will be used by
    samba_version
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 buildtools/wafsamba/samba_patterns.py |    7 +++++--
 buildtools/wafsamba/samba_utils.py    |    7 +++++--
 buildtools/wafsamba/samba_version.py  |   26 +++++++++++++-------------
 buildtools/wafsamba/wafsamba.py       |    6 +++++-
 source4/wscript                       |   19 +++++++++++++++++--
 5 files changed, 45 insertions(+), 20 deletions(-)


Changeset truncated at 500 lines:

diff --git a/buildtools/wafsamba/samba_patterns.py b/buildtools/wafsamba/samba_patterns.py
index ae0dbe2..4307bf2 100644
--- a/buildtools/wafsamba/samba_patterns.py
+++ b/buildtools/wafsamba/samba_patterns.py
@@ -10,7 +10,9 @@ def write_version_header(task):
     src = task.inputs[0].srcpath(task.env)
     tgt = task.outputs[0].bldpath(task.env)
 
-    version = samba_version_file(src)
+    have_git = 'GIT' in task.env
+
+    version = samba_version_file(src, have_git=have_git)
     string = str(version)
    
     f = open(tgt, 'w')
@@ -24,5 +26,6 @@ def SAMBA_MKVERSION(bld, target):
     t = bld.SAMBA_GENERATOR('VERSION', 
                             rule=write_version_header,
                             source= 'VERSION',
-                            target=target)
+                            target=target,
+                            always=True)
 Build.BuildContext.SAMBA_MKVERSION = SAMBA_MKVERSION
diff --git a/buildtools/wafsamba/samba_utils.py b/buildtools/wafsamba/samba_utils.py
index 79b0ca3..304264b 100644
--- a/buildtools/wafsamba/samba_utils.py
+++ b/buildtools/wafsamba/samba_utils.py
@@ -397,8 +397,11 @@ def LOAD_ENVIRONMENT():
        from new commands'''
     import Environment
     env = Environment.Environment()
-    env.load('.lock-wscript')
-    env.load(env.blddir + '/c4che/default.cache.py')
+    try:
+        env.load('.lock-wscript')
+        env.load(env.blddir + '/c4che/default.cache.py')
+    except:
+        pass
     return env
 
 
diff --git a/buildtools/wafsamba/samba_version.py b/buildtools/wafsamba/samba_version.py
index 9832c79..398f6ee 100644
--- a/buildtools/wafsamba/samba_version.py
+++ b/buildtools/wafsamba/samba_version.py
@@ -1,8 +1,7 @@
-import os;
-import subprocess;
+import Utils;
 
 class samba_version(object):
-    def __init__(self, version_dict):
+    def __init__(self, version_dict, have_git=False):
         '''Determine the version number of samba
 
 See VERSION for the format.  Entries on that file are 
@@ -63,19 +62,21 @@ also accepted as dictionary entries here
 
         if self.IS_GIT_SNAPSHOT:
             #Get version from GIT
-            try:
-                git = subprocess.Popen('git show --pretty=format:"%h%n%ct%n%H%n%cd" --stat HEAD', stdout=subprocess.PIPE, close_fds=True, shell=True)
-                (output, errors) = git.communicate()
-                lines = output.splitlines();
+            if have_git:
+                git = Utils.cmd_output('git show --pretty=format:"%h%n%ct%n%H%n%cd" --stat HEAD', silent=True)
+            else:
+                git = ''
+
+            if git == '':
+                SAMBA_VERSION_STRING += "-GIT-UNKNOWN"
+            else:
+                lines = git.splitlines();
                 self.GIT_COMMIT_ABBREV = lines[0]
                 self.GIT_COMMIT_TIME = lines[1]
                 self.GIT_COMMIT_FULLREV = lines[2]
                 self.GIT_COMMIT_DATE = lines[3]
 
                 SAMBA_VERSION_STRING += ("-GIT-" + self.GIT_COMMIT_ABBREV)
-            except IndexError:
-                SAMBA_VERSION_STRING += "-GIT-UNKNOWN"
-                pass
 
         self.OFFICIAL_STRING=SAMBA_VERSION_STRING
 
@@ -147,7 +148,7 @@ also accepted as dictionary entries here
 
 
 class samba_version_file(samba_version):
-    def __init__(self, version_file):
+    def __init__(self, version_file, have_git=False):
         '''Parse the version information from a VERSION file'''
         f = open(version_file, 'r')
         version_dict = {}
@@ -166,5 +167,4 @@ class samba_version_file(samba_version):
                 print "Failed to parse line %s from %s" % (line, version_file)
                 raise
             
-        super(samba_version_file, self).__init__(version_dict)
-        
+        super(samba_version_file, self).__init__(version_dict, have_git=have_git)
diff --git a/buildtools/wafsamba/wafsamba.py b/buildtools/wafsamba/wafsamba.py
index 5ffe4b8..21ed001 100644
--- a/buildtools/wafsamba/wafsamba.py
+++ b/buildtools/wafsamba/wafsamba.py
@@ -484,7 +484,8 @@ def SAMBA_GENERATOR(bld, name, rule, source='', target='',
                     group='generators', enabled=True,
                     public_headers=None,
                     header_path=None,
-                    vars=None):
+                    vars=None,
+                    always=False):
     '''A generic source generator target'''
 
     if not SET_TARGET_TYPE(bld, name, 'GENERATOR'):
@@ -504,6 +505,9 @@ def SAMBA_GENERATOR(bld, name, rule, source='', target='',
         ext_out='.c',
         name=name)
 
+    if always:
+        t.always = True
+
     if public_headers is not None:
         bld.PUBLIC_HEADERS(public_headers, header_path=header_path)
     return t
diff --git a/source4/wscript b/source4/wscript
index e973d6f..6bf8663 100644
--- a/source4/wscript
+++ b/source4/wscript
@@ -4,14 +4,24 @@ srcdir = '..'
 blddir = 'bin'
 
 APPNAME='samba'
+VERSION=None
 
 import sys, os
 sys.path.insert(0, srcdir+"/buildtools/wafsamba")
 import wafsamba, Options, samba_dist, Scripting
 
-version = wafsamba.samba_version_file("./VERSION")
 
-VERSION=version.STRING
+def load_version(have_git=False):
+    '''load samba versions either from ./VERSION or git
+    return a version object for detailed breakdown'''
+    import samba_utils, Utils
+    if not have_git:
+        env = samba_utils.LOAD_ENVIRONMENT()
+        have_git = 'GIT' in env
+    version = wafsamba.samba_version_file("./VERSION", have_git=have_git)
+    Utils.g_module.VERSION = version.STRING
+    return version
+
 
 samba_dist.DIST_DIRS('.')
 
@@ -51,6 +61,8 @@ def set_options(opt):
 
 
 def configure(conf):
+    version = load_version(have_git=True)
+
     conf.DEFINE('PACKAGE_NAME', 'samba', quote=True)
     conf.DEFINE('PACKAGE_STRING', 'Samba ' + version.STRING, quote=True)
     conf.DEFINE('PACKAGE_TARNAME',  'samba', quote=True)
@@ -129,6 +141,7 @@ def ctags(ctx):
 # of commands in --help
 def build(bld):
     '''build all targets'''
+    load_version()
     pass
 
 
@@ -154,10 +167,12 @@ def wafdocs(ctx):
 
 def dist():
     '''makes a tarball for distribution'''
+    load_version()
     samba_dist.dist()
 
 def distcheck():
     '''test that distribution tarball builds and installs'''
+    load_version()
     import Scripting
     d = Scripting.distcheck
     d(subdir='source4')


-- 
Samba Shared Repository


More information about the samba-cvs mailing list