build: loop until all object reductions are complete
authorAndrew Tridgell <tridge@samba.org>
Fri, 2 Apr 2010 07:16:23 +0000 (18:16 +1100)
committerAndrew Tridgell <tridge@samba.org>
Tue, 6 Apr 2010 10:27:23 +0000 (20:27 +1000)
we will issue a warning if any object duplication remains

buildtools/wafsamba/samba_deps.py

index a05092f525b7a79653384416a31ebfbc53753646..08a24db5bb27d998661d1a0104226120ffeb90ef 100644 (file)
@@ -582,6 +582,8 @@ def reduce_objects(bld, tgt_list):
     for t in tgt_list:
         t.extended_objects = None
 
+    changed = False
+
     for type in ['BINARY', 'PYTHON', 'LIBRARY']:
         for t in tgt_list:
             if t.samba_type != type: continue
@@ -601,11 +603,16 @@ def reduce_objects(bld, tgt_list):
                     rely_on[l] = rely_on[l].union(dup)
             t.final_objects = new
 
+    if not changed:
+        return False
+
     # add back in any objects that were relied upon by the reduction rules
     for r in rely_on:
         t = bld.name_to_obj(r, bld.env)
         t.final_objects = t.final_objects.union(rely_on[r])
 
+    return True
+
 
 def calculate_final_deps(bld, tgt_list, loops):
     '''calculate the final library and object dependencies'''
@@ -655,8 +662,13 @@ def calculate_final_deps(bld, tgt_list, loops):
                         t.final_libs = t.final_libs.union(diff)
 
     # remove objects that are also available in linked libs
-    reduce_objects(bld, tgt_list)
-    reduce_objects(bld, tgt_list)
+    count = 0
+    while reduce_objects(bld, tgt_list):
+        count += 1
+        if count > 100:
+            print("WARNING: Unable to remove all inter-target object duplicates")
+            break
+    debug('deps: Object reduction took %u iterations', count)
 
     # add in any syslib dependencies
     for t in tgt_list: