Build.BuildContext.TARGET_ALIAS = TARGET_ALIAS
+@conf
+def SET_SYSLIB_DEPS(conf, target, deps):
+ '''setup some implied dependencies for a SYSLIB'''
+ cache = LOCAL_CACHE(conf, 'SYSLIB_DEPS')
+ cache[target] = deps
+
+
def EXPAND_ALIAS(bld, target):
'''expand a target name via an alias'''
aliases = LOCAL_CACHE(bld, 'TARGET_ALIAS')
the full dependency list for a target until we have all of the targets declared.
'''
- # we need to link against:
-
- # 1) any direct system libs
- # 2) any indirect system libs that come from subsystem dependencies
- # 3) any direct local libs
- # 4) any indirect local libs that come from subsystem dependencies
- # 5) any direct objects
- # 6) any indirect objects that come from subsystem dependencies
-
if self.samba_type in ['LIBRARY', 'BINARY', 'PYTHON']:
self.uselib = list(self.final_syslibs)
self.uselib_local = list(self.final_libs)
# extra link flags from pkg_config
libs = self.final_syslibs.copy()
- libs = libs.union(self.indirect_libs)
(ccflags, ldflags) = library_flags(self, list(libs))
new_ldflags = getattr(self, 'ldflags', [])
# this is needed for the ccflags of libs that come from pkg_config
self.uselib = list(self.direct_syslibs)
-
+ if getattr(self, 'uselib', None):
+ up_list = []
+ for l in self.uselib:
+ up_list.append(l.upper())
+ self.uselib = up_list
def build_includes(self):
seen = set()
- '''
- # this was useful for finding problems with the autogenerated rules
- for t in tgt_list:
- base_list = set()
- sources = TO_LIST(getattr(t, 'source', ''))
- for s in sources:
- bname = os.path.basename(s)
- if bname in base_list:
- print "Suspicious duplicate name %s in %s" % (bname, t.sname)
- continue
- base_list.add(bname)
- '''
-
-
for t in tgt_list:
obj_sources = getattr(t, 'source', '')
tpath = os_path_relpath(t.path.abspath(bld.env), t.env['BUILD_DIRECTORY'] + '/default')
'''build the direct_objects and direct_libs sets for each target'''
targets = LOCAL_CACHE(bld, 'TARGET_TYPE')
+ syslib_deps = LOCAL_CACHE(bld, 'SYSLIB_DEPS')
global_deps = bld.env.GLOBAL_DEPENDENCIES
for t in tgt_list:
continue
if targets[d] == 'SYSLIB':
t.direct_syslibs.add(d)
+ if d in syslib_deps:
+ for implied in TO_LIST(syslib_deps[d]):
+ t.direct_libs.add(implied)
continue
t2 = bld.name_to_obj(d, bld.env)
if t2 is None:
return ret
-def indirect_syslibs(bld, t, chain, loops):
- '''recursively calculate the indirect system library dependencies for a target
-
- An indirect syslib results from a subsystem dependency
- '''
-
- ret = getattr(t, 'indirect_syslibs', None)
- if ret is not None:
- return ret
-
- ret = set()
- for obj in t.direct_objects:
- if obj in chain:
- dependency_loop(loops, t, obj)
- continue
- chain.add(obj)
- t2 = bld.name_to_obj(obj, bld.env)
- r2 = indirect_syslibs(bld, t2, chain, loops)
- chain.remove(obj)
- ret = ret.union(t2.direct_syslibs)
- ret = ret.union(r2)
-
- t.indirect_syslibs = ret
- return ret
-
-
def indirect_objects(bld, t, chain, loops):
'''recursively calculate the indirect object dependencies for a target
debug('deps: setting %s %s to %s', t.sname, attr, objs)
setattr(t, attr, objs)
- # now calculate the indirect syslibs, which can change from the loop expansion
- for t in tgt_list:
- indirect_syslibs(bld, t, set(), loops)
-
-
def calculate_final_deps(bld, tgt_list, loops):
'''calculate the final library and object dependencies'''
for t in tgt_list:
# start with the maximum possible list
- t.final_syslibs = t.direct_syslibs.union(indirect_syslibs(bld, t, set(), loops))
t.final_libs = t.direct_libs.union(indirect_libs(bld, t, set(), loops))
t.final_objects = t.direct_objects.union(indirect_objects(bld, t, set(), loops))
debug('deps: Expanded target %s by loop %s libraries %s', t.sname, loop, diff)
t.final_libs = t.final_libs.union(diff)
+ # add in any syslib dependencies
+ for t in tgt_list:
+ if not t.samba_type in ['BINARY','PYTHON','LIBRARY']:
+ continue
+ syslibs = set()
+ for d in t.final_objects:
+ t2 = bld.name_to_obj(d, bld.env)
+ syslibs = syslibs.union(t2.direct_syslibs)
+ # this adds the indirect syslibs as well, which may not be needed
+ # depending on the linker flags
+ for d in t.final_libs:
+ t2 = bld.name_to_obj(d, bld.env)
+ syslibs = syslibs.union(t2.direct_syslibs)
+ t.final_syslibs = syslibs
+
debug('deps: removed duplicate dependencies')
+
######################################################################
# this provides a way to save our dependency calculations between runs
savedeps_version = 3
savedeps_inputs = ['samba_deps', 'samba_includes', 'local_include', 'local_include_first', 'samba_cflags', 'source']
savedeps_outputs = ['uselib', 'uselib_local', 'add_objects', 'includes', 'ccflags']
savedeps_outenv = ['INC_PATHS']
-savedeps_caches = ['GLOBAL_DEPENDENCIES', 'TARGET_ALIAS', 'TARGET_TYPE', 'INIT_FUNCTIONS']
+savedeps_caches = ['GLOBAL_DEPENDENCIES', 'TARGET_ALIAS', 'TARGET_TYPE', 'INIT_FUNCTIONS', 'SYSLIB_DEPS']
savedeps_files = ['buildtools/wafsamba/samba_deps.py']
def save_samba_deps(bld, tgt_list):