s3-waf: use git to calculate the version if available
authorStefan Metzmacher <metze@samba.org>
Mon, 25 Oct 2010 06:33:39 +0000 (06:33 +0000)
committerStefan Metzmacher <metze@samba.org>
Mon, 25 Oct 2010 08:16:28 +0000 (08:16 +0000)
metze

source3/wscript
source3/wscript_build

index 20975f7189872df98d7c1696fa9d40bb48ffdeef..96571748a5b1b9d6713eeea91c2f9c35ae0bcf4d 100644 (file)
@@ -3,6 +3,9 @@
 srcdir = '..'
 blddir = 'bin'
 
+APPNAME='samba'
+VERSION=None
+
 import sys, os
 from optparse import SUPPRESS_HELP
 sys.path.insert(0, srcdir+"/buildtools/wafsamba")
@@ -11,9 +14,16 @@ import build.charset
 import samba_utils
 import samba3
 
-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
 
 def set_options(opt):
     opt.BUILTIN_DEFAULT('NONE')
@@ -57,16 +67,12 @@ def set_options(opt):
 def configure(conf):
     from samba_utils import TO_LIST
 
-    conf.DEFINE('PACKAGE_NAME', 'Samba', quote=True)
-    conf.DEFINE('PACKAGE_STRING', 'Samba %s' % version.MAJOR, quote=True)
-    conf.DEFINE('PACKAGE_TARNAME',  'samba', quote=True)
-    conf.DEFINE('PACKAGE_URL', "", quote=True)
-    conf.DEFINE('PACKAGE_VERSION', "%s" % version.MAJOR, quote=True)
-    conf.DEFINE('PACKAGE_BUGREPORT', 'samba-technical@samba.org', quote=True)
+    version = load_version(have_git=True)
 
     conf.DEFINE('CONFIG_H_IS_FROM_SAMBA', 1)
     conf.DEFINE('_SAMBA_BUILD_', version.MAJOR, add_to_cflags=True)
     conf.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags=True)
+
     if Options.options.developer:
         conf.ADD_CFLAGS('-DDEVELOPER -DDEBUG_PASSWORD')
         conf.env['developer'] = True
index 3abcd178e659960f03ceccd0679e39dd683e15e8..0a0588096038f23bb3d57ca09842bdfb0a76f4aa 100644 (file)
@@ -904,6 +904,8 @@ t.env.BUILDDIR = bld.path.abspath()
 
 bld.SETUP_BUILD_GROUPS()
 
+bld.SAMBA_MKVERSION('include/version.h')
+
 bld.RECURSE('../lib/replace')
 bld.RECURSE('../libcli/smbreadline')
 print "SBINDIR=%s" % bld.env.SBINDIR
@@ -914,8 +916,6 @@ bld.RECURSE('librpc/idl')
 bld.RECURSE('librpc')
 bld.RECURSE('../libcli/security')
 
-bld.SAMBA_MKVERSION('include/version.h')
-
 ######################## SUBSYSTEMS #################################
 
 bld.SAMBA_SUBSYSTEM('WBCOMMON',