wafsamba: Don't allow circular dependencies involving libraries by
authorJelmer Vernooij <jelmer@samba.org>
Wed, 13 Oct 2010 11:58:25 +0000 (13:58 +0200)
committerJelmer Vernooij <jelmer@samba.org>
Wed, 13 Oct 2010 12:10:42 +0000 (14:10 +0200)
default.

buildtools/wafsamba/samba_deps.py

index 8bd8ad31cef72cfdcc76c24ac4b3048ecee83df7..553a91a81adc30bde91c2512dc9442eb1febf71a 100644 (file)
@@ -13,6 +13,12 @@ def ADD_GLOBAL_DEPENDENCY(ctx, dep):
     ctx.env.GLOBAL_DEPENDENCIES.append(dep)
 
 
+@conf
+def BREAK_CIRCULAR_LIBRARY_DEPENDENCIES(ctx):
+    '''indicate that circular dependencies between libraries should be broken.'''
+    ctx.env.ALLOW_CIRCULAR_LIB_DEPENDENCIES = True
+
+
 def TARGET_ALIAS(bld, target, alias):
     '''define an alias for a target name'''
     cache = LOCAL_CACHE(bld, 'TARGET_ALIAS')
@@ -706,13 +712,17 @@ def calculate_final_deps(bld, tgt_list, loops):
             for l in t.final_libs.copy():
                 t2 = bld.name_to_obj(l, bld.env)
                 if t.sname in t2.final_libs:
-                    # we could break this in either direction. If one of the libraries
-                    # has a version number, and will this be distributed publicly, then
-                    # we should make it the lower level library in the DAG
-                    Logs.warn('deps: removing library loop %s from %s' % (t.sname, t2.sname))
-                    dependency_loop(loops, t, t2.sname)
-                    t2.final_libs.remove(t.sname)
-
+                    if getattr(bld.env, "ALLOW_CIRCULAR_LIB_DEPENDENCIES", False):
+                        # we could break this in either direction. If one of the libraries
+                        # has a version number, and will this be distributed publicly, then
+                        # we should make it the lower level library in the DAG
+                        Logs.warn('deps: removing library loop %s from %s' % (t.sname, t2.sname))
+                        dependency_loop(loops, t, t2.sname)
+                        t2.final_libs.remove(t.sname)
+                    else:
+                        Logs.error('ERROR: circular library dependency between %s and %s'
+                            % (t.sname, t2.sname))
+                        sys.exit(1)
 
     for loop in loops:
         debug('deps: Found dependency loops for target %s : %s', loop, loops[loop])