wafsamba: the symbol version string of private libraries should be based on the tople...
[gd/samba-autobuild/.git] / buildtools / wafsamba / samba_abi.py
index bf82fc5fe1fc806c1996e179a2682ca769109bb0..b0a8b02cf2152b9737240cf4d2fbb494799d56a2 100644 (file)
@@ -142,7 +142,7 @@ def abi_check(self):
     abi_gen = os.path.join(topsrc, 'buildtools/scripts/abi_gen.sh')
 
     abi_file = "%s/%s-%s.sigs" % (self.abi_directory, self.version_libname,
-                                  self.vnum)
+                                  self.abi_vnum)
 
     tsk = self.create_task('abi_check', self.link_task.outputs[0])
     tsk.ABI_FILE = abi_file
@@ -214,21 +214,32 @@ def abi_build_vscript(task):
 
     symmap = {}
     versions = []
+    abi_match = list(task.env.ABI_MATCH)
     for f in task.inputs:
         fname = f.abspath(task.env)
         basename = os.path.basename(fname)
         version = basename[len(task.env.LIBNAME)+1:-len(".sigs")]
         versions.append(version)
         abi_process_file(fname, version, symmap)
+    if task.env.PRIVATE_LIBRARY:
+        # For private libraries we need to inject
+        # each public symbol explicitly into the
+        # abi match array and remove all explicit
+        # versioning so that each exported symbol
+        # is tagged with the private library tag.
+        for s in symmap:
+            abi_match.append(s)
+        symmap = {}
+        versions = []
     f = open(tgt, mode='w')
     try:
         abi_write_vscript(f, task.env.LIBNAME, task.env.VERSION, versions,
-            symmap, task.env.ABI_MATCH)
+            symmap, abi_match)
     finally:
         f.close()
 
 
-def ABI_VSCRIPT(bld, libname, abi_directory, version, vscript, abi_match=None):
+def ABI_VSCRIPT(bld, libname, abi_directory, version, vscript, abi_match=None, private_library=False):
     '''generate a vscript file for our public libraries'''
     if abi_directory:
         source = bld.path.ant_glob('%s/%s-[0-9]*.sigs' % (abi_directory, libname), flat=True)
@@ -238,6 +249,9 @@ def ABI_VSCRIPT(bld, libname, abi_directory, version, vscript, abi_match=None):
     else:
         source = ''
 
+    if private_library is None:
+        private_library = False
+
     libname = os.path.basename(libname)
     version = os.path.basename(version)
     libname = libname.replace("-", "_").replace("+","_").upper()
@@ -255,5 +269,6 @@ def ABI_VSCRIPT(bld, libname, abi_directory, version, vscript, abi_match=None):
     t.env.ABI_MATCH = abi_match
     t.env.VERSION = version
     t.env.LIBNAME = libname
-    t.vars = ['LIBNAME', 'VERSION', 'ABI_MATCH']
+    t.env.PRIVATE_LIBRARY = private_library
+    t.vars = ['LIBNAME', 'VERSION', 'ABI_MATCH', 'PRIVATE_LIBRARY']
 Build.BuildContext.ABI_VSCRIPT = ABI_VSCRIPT