waf: display the paths in library loops
authorAndrew Tridgell <tridge@samba.org>
Fri, 29 Oct 2010 00:51:17 +0000 (11:51 +1100)
committerAndrew Tridgell <tridge@samba.org>
Sat, 30 Oct 2010 12:49:00 +0000 (23:49 +1100)
when we detect a library loop, try to display the paths between the
two libraries. This should make it easier to fix.

Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>

buildtools/wafsamba/samba_deps.py

index faac03ef5723144437f9c5b617b61924db773749..bbd945210b5530b8d45c781cced7e52839d4fd6e 100644 (file)
@@ -754,6 +754,25 @@ def reduce_objects(bld, tgt_list):
     return True
 
 
+def show_library_loop(bld, lib1, lib2, path, seen):
+    '''show the detailed path of a library loop between lib1 and lib2'''
+
+    t = bld.name_to_obj(lib1, bld.env)
+    if not lib2 in getattr(t, 'final_libs', set()):
+        return
+
+    for d in t.samba_deps_extended:
+        if d in seen:
+            continue
+        seen.add(d)
+        path2 = path + '=>' + d
+        if d == lib2:
+            Logs.warn('library loop path: ' + path2)
+            return
+        show_library_loop(bld, d, lib2, path2, seen)
+        seen.remove(d)
+
+
 def calculate_final_deps(bld, tgt_list, loops):
     '''calculate the final library and object dependencies'''
     for t in tgt_list:
@@ -798,6 +817,8 @@ def calculate_final_deps(bld, tgt_list, loops):
                     else:
                         Logs.error('ERROR: circular library dependency between %s and %s'
                             % (t.sname, t2.sname))
+                        show_library_loop(bld, t.sname, t2.sname, t.sname, set())
+                        show_library_loop(bld, t2.sname, t.sname, t2.sname, set())
                         sys.exit(1)
 
     for loop in loops: