ldb:wscript: provide LDB_VERSION_{MAJOR,MINOR,RELEASE} in ldb_version.h
authorStefan Metzmacher <metze@samba.org>
Fri, 23 Jun 2017 08:50:54 +0000 (10:50 +0200)
committerStefan Metzmacher <metze@samba.org>
Sun, 2 Jul 2017 15:35:19 +0000 (17:35 +0200)
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
lib/ldb/wscript

index 1fce3b3ba576071c1d64bc4b7a6d807401e0382e..d827775f5be0db52b72138bd7ae1b95fe00d52a3 100644 (file)
@@ -205,8 +205,24 @@ def build(bld):
                           abi_match = abi_match)
 
         # generate a include/ldb_version.h
+        def generate_ldb_version_h(t):
+            '''generate a vscript file for our public libraries'''
+
+            tgt = t.outputs[0].bldpath(t.env)
+
+            v = t.env.LDB_VERSION.split('.')
+
+            f = open(tgt, mode='w')
+            try:
+                f.write('#define LDB_VERSION "%s"\n' % t.env.LDB_VERSION)
+                f.write('#define LDB_VERSION_MAJOR %d\n' % int(v[0]))
+                f.write('#define LDB_VERSION_MINOR %d\n' % int(v[1]))
+                f.write('#define LDB_VERSION_RELEASE %d\n' % int(v[2]))
+            finally:
+                f.close()
+            return
         t = bld.SAMBA_GENERATOR('ldb_version.h',
-                                rule='echo "#define LDB_VERSION \\"${LDB_VERSION}\\"" > ${TGT}',
+                                rule=generate_ldb_version_h,
                                 dep_vars=['LDB_VERSION'],
                                 target='include/ldb_version.h',
                                 public_headers='include/ldb_version.h',