summaryrefslogtreecommitdiff
path: root/buildtools/wafsamba
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2010-03-21 11:04:26 +1100
committerAndrew Tridgell <tridge@samba.org>2010-04-06 20:26:59 +1000
commit69c065c719c208c5ef0fd8cb5df55621dc77a3e1 (patch)
tree3859c182289e349e0b1f26b82628cf56ed2518d0 /buildtools/wafsamba
parent064f26ea0734ad27d21d71602c2f94bc2815004c (diff)
downloadsamba-69c065c719c208c5ef0fd8cb5df55621dc77a3e1.tar.gz
samba-69c065c719c208c5ef0fd8cb5df55621dc77a3e1.tar.bz2
samba-69c065c719c208c5ef0fd8cb5df55621dc77a3e1.zip
build: optimise and re-enable check_duplicate_sources
Diffstat (limited to 'buildtools/wafsamba')
-rw-r--r--buildtools/wafsamba/samba_deps.py65
1 files changed, 47 insertions, 18 deletions
diff --git a/buildtools/wafsamba/samba_deps.py b/buildtools/wafsamba/samba_deps.py
index a475b448a2..1c9bcb75d9 100644
--- a/buildtools/wafsamba/samba_deps.py
+++ b/buildtools/wafsamba/samba_deps.py
@@ -222,6 +222,29 @@ def check_duplicate_sources(bld, tgt_list):
debug('deps: checking for duplicate sources')
targets = LOCAL_CACHE(bld, 'TARGET_TYPE')
+ ret = True
+
+ 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')
+ obj_sources = bld.SUBDIR(tpath, obj_sources)
+ t.samba_source_set = set(TO_LIST(obj_sources))
for t in tgt_list:
if not targets[t.sname] in [ 'LIBRARY', 'BINARY', 'PYTHON' ]:
@@ -230,22 +253,20 @@ def check_duplicate_sources(bld, tgt_list):
sources = []
for obj in t.add_objects:
t2 = t.bld.name_to_obj(obj, bld.env)
- obj_sources = getattr(t2, 'source', '')
- if obj_sources == '': continue
- tpath = os_path_relpath(t2.path.abspath(bld.env), t.env['BUILD_DIRECTORY'] + '/default')
- obj_sources = bld.SUBDIR(tpath, obj_sources)
- sources.append( { 'dep':obj, 'src':set(TO_LIST(obj_sources)) } )
- #debug('deps: dependency expansion for target %s add_object %s: %s',
- # t.sname, obj, obj_sources)
- for s in sources:
- for s2 in sources:
- if s['dep'] == s2['dep']: continue
- common = s['src'].intersection(s2['src'])
- if common:
- bld.ASSERT(False,
- "Target %s has duplicate source files in %s and %s : %s" % (t.sname,
- s['dep'], s2['dep'],
- common))
+ source_set = getattr(t2, 'samba_source_set', set())
+ sources.append( { 'dep':obj, 'src':source_set} )
+ for s in sources:
+ for s2 in sources:
+ if s['dep'] == s2['dep']: continue
+ common = s['src'].intersection(s2['src'])
+ if common.difference(seen):
+ print("Target %s has duplicate source files in %s and %s : %s" % (t.sname,
+ s['dep'], s2['dep'],
+ common))
+ seen = seen.union(common)
+ ret = False
+ return ret
+
def check_orpaned_targets(bld, tgt_list):
'''check if any build targets are orphaned'''
@@ -603,7 +624,7 @@ def calculate_final_deps(bld, tgt_list):
######################################################################
# 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']
+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']
@@ -740,6 +761,8 @@ def check_project_rules(bld):
if load_samba_deps(bld, tgt_list):
return
+ print "Checking project rules ..."
+
debug('deps: project rules checking started')
expand_subsystem_deps(bld)
@@ -755,7 +778,11 @@ def check_project_rules(bld):
debug('deps: project rules stage1 completed')
#check_orpaned_targets(bld, tgt_list)
- #check_duplicate_sources(bld, tgt_list)
+
+ if not check_duplicate_sources(bld, tgt_list):
+ print "Duplicate sources present - aborting"
+ sys.exit(1)
+
show_final_deps(bld, tgt_list)
debug('deps: project rules checking completed - %u targets checked',
@@ -763,6 +790,8 @@ def check_project_rules(bld):
save_samba_deps(bld, tgt_list)
+ print "Project rules pass"
+
def CHECK_PROJECT_RULES(bld):
'''enable checking of project targets for sanity'''